|
34 | 34 | use CommonGLPI; |
35 | 35 | use Dropdown; |
36 | 36 | use Entity; |
| 37 | +use Glpi\Application\View\TemplateRenderer; |
37 | 38 | use Html; |
38 | 39 | use Session; |
39 | 40 |
|
@@ -101,159 +102,16 @@ public function showForm($ID, $options = []) |
101 | 102 | $this->check(-1, CREATE, $options); |
102 | 103 | } |
103 | 104 |
|
104 | | - // Html::requireJs("addressing"); |
105 | | - |
106 | | -// $options['formoptions'] |
107 | | -// = "onSubmit='return plugaddr_Check(\"".__('Invalid data !!', 'addressing')."\")'"; |
108 | 105 | $options['colspan'] = 1; |
109 | | - $this->showFormHeader($options); |
110 | | - |
111 | | - $addressing = new Addressing(); |
112 | | - $addressing->getFromDB($options['items_id']); |
113 | | - |
114 | | - echo "<tr class='tab_bg_1'>"; |
115 | | - |
116 | | - echo Html::hidden('id', ['value' => $ID]); |
117 | | - echo Html::hidden('plugin_addressing_addressings_id', ['value' => $options['items_id']]); |
118 | | - echo "<td>" . __('Name') . "</td>"; |
119 | | - echo "<td>"; |
120 | | - echo Html::input('name', ['value' => $this->fields['name'], 'size' => 40, 'required' => true]); |
121 | | - echo "</td>"; |
122 | | - echo "</tr>"; |
123 | | - |
124 | | - echo "<tr class='tab_bg_1'>"; |
125 | | - echo "<td>" . __('Entity') . "</td>"; |
126 | | - echo "<td>"; |
127 | | - Entity::dropdown(['name' => 'entities_id', 'value' => $this->fields["entities_id"]]); |
128 | | - echo "</td>"; |
129 | | - echo "</tr>"; |
130 | | - |
131 | | - echo "<tr class='tab_bg_1'> |
132 | | - <td>".__("Type")."</td> |
133 | | - <td>"; |
134 | | - $types = Addressing::dropdownItemtype(); |
135 | | - Dropdown::showFromArray( |
136 | | - 'type', |
137 | | - $types, |
138 | | - ['value' => $this->fields["type"]] |
139 | | - ); |
140 | | - echo "</td>"; |
141 | | - echo "</tr>"; |
142 | | - |
143 | | - echo "<tr class='tab_bg_1'>"; |
144 | | - echo "<td>".__('First IP', 'addressing')."</td>"; // Subnet |
145 | | - echo "<td>"; |
146 | | - if (empty($this->fields["begin_ip"])) { |
147 | | - $this->fields["begin_ip"] = "..."; |
148 | | - } |
149 | | - $ipexploded = explode(".", $this->fields["begin_ip"]); |
150 | | - $i = 0; |
151 | | - foreach ($ipexploded as $ipnum) { |
152 | | - if ($ipnum > 255) { |
153 | | - $ipexploded[$i] = ''; |
154 | | - } |
155 | | - $i++; |
156 | | - } |
157 | | - |
158 | | - echo Html::input('_ipdeb0', ['value' => $ipexploded[0], |
159 | | - 'id' => 'plugaddr_ipdeb0', |
160 | | - 'size' => 3, |
161 | | - 'maxlength' => 3, |
162 | | - 'class' => 'form-inline']); |
163 | | - echo Html::input('_ipdeb1', ['value' => $ipexploded[0], |
164 | | - 'id' => 'plugaddr_ipdeb1', |
165 | | - 'size' => 3, |
166 | | - 'maxlength' => 3, |
167 | | - 'class' => 'form-inline']); |
168 | | - echo Html::input('_ipdeb2', ['value' => $ipexploded[0], |
169 | | - 'id' => 'plugaddr_ipdeb2', |
170 | | - 'size' => 3, |
171 | | - 'maxlength' => 3, |
172 | | - 'class' => 'form-inline']); |
173 | | - echo Html::input('_ipdeb3', ['value' => $ipexploded[0], |
174 | | - 'id' => 'plugaddr_ipdeb3', |
175 | | - 'size' => 3, |
176 | | - 'maxlength' => 3, |
177 | | - 'class' => 'form-inline']); |
178 | | - |
179 | | - echo "</td>"; |
180 | | - |
181 | | - echo "</tr>"; |
182 | | - |
183 | | - echo "<tr class='tab_bg_1'>"; |
184 | | - echo "<td>".__('Last IP', 'addressing')."</td>"; // Mask |
185 | | - echo "<td>"; |
186 | | - |
187 | | - unset($ipexploded); |
188 | | - if (empty($this->fields["end_ip"])) { |
189 | | - $this->fields["end_ip"] = "..."; |
190 | | - } |
191 | | - $ipexploded = explode(".", $this->fields["end_ip"]); |
192 | | - $j = 0; |
193 | | - foreach ($ipexploded as $ipnum) { |
194 | | - if ($ipnum > 255) { |
195 | | - $ipexploded[$j] = ''; |
196 | | - } |
197 | | - $j++; |
198 | | - } |
199 | 106 |
|
200 | | - echo "<script type='text/javascript'> |
201 | | - function test(id) { |
202 | | - if (document.getElementById('plugaddr_ipfin' + id).value == '') { |
203 | | - if (id == 3) { |
204 | | - document.getElementById('plugaddr_ipfin' + id).value = '254'; |
205 | | - } else { |
206 | | - document.getElementById('plugaddr_ipfin' + id).value = ". |
207 | | - "document.getElementById('plugaddr_ipdeb' + id).value; |
208 | | - } |
209 | | - } |
210 | | - } |
211 | | - </script>"; |
212 | | - |
213 | | - echo Html::input('_ipfin0', ['value' => $ipexploded[0], |
214 | | - 'id' => 'plugaddr_ipfin0', |
215 | | - 'size' => 3, |
216 | | - 'maxlength' => 3, |
217 | | - 'class' => 'form-inline', |
218 | | - 'onfocus'=>'test(0)']); |
219 | | - echo Html::input('_ipfin1', ['value' => $ipexploded[0], |
220 | | - 'id' => 'plugaddr_ipfin1', |
221 | | - 'size' => 3, |
222 | | - 'maxlength' => 3, |
223 | | - 'class' => 'form-inline', |
224 | | - 'onfocus'=>'test(1)']); |
225 | | - echo Html::input('_ipfin2', ['value' => $ipexploded[0], |
226 | | - 'id' => 'plugaddr_ipfin2', |
227 | | - 'size' => 3, |
228 | | - 'maxlength' => 3, |
229 | | - 'class' => 'form-inline', |
230 | | - 'onfocus'=>'test(2)']); |
231 | | - echo Html::input('_ipfin3', ['value' => $ipexploded[0], |
232 | | - 'id' => 'plugaddr_ipfin3', |
233 | | - 'size' => 3, |
234 | | - 'maxlength' => 3, |
235 | | - 'class' => 'form-inline', |
236 | | - 'onfocus'=>'test(3)']); |
237 | | - |
238 | | - echo "</td>"; |
239 | | - echo "</tr>"; |
240 | | - |
241 | | - echo "<tr class='tab_bg_1'>"; |
242 | | - echo "<td>".__('Report for the IP Range', 'addressing')."</td>"; // Mask |
243 | | - echo "<td>"; |
244 | | - echo Html::hidden('begin_ip', ['id' => 'plugaddr_ipdeb', 'value' => $this->fields["begin_ip"]]); |
245 | | - echo Html::hidden('end_ip', ['id' => 'plugaddr_ipfin', 'value' => $this->fields["end_ip"]]); |
246 | | - echo "<div id='plugaddr_range'>-</div>"; |
247 | | - if ($ID > 0) { |
248 | | - $js = "plugaddr_Init(\"".__('Invalid data !!', 'addressing')."\");"; |
249 | | - echo Html::scriptBlock('$(document).ready(function() {'.$js.'});'); |
250 | | - } |
251 | | - echo "</td>"; |
252 | | - echo "</tr>"; |
253 | | - |
254 | | - $this->showFormButtons($options); |
| 107 | + $options['types'] = Addressing::dropdownItemtype(); |
| 108 | + TemplateRenderer::getInstance()->display('@addressing/filter.html.twig', [ |
| 109 | + 'item' => $this, |
| 110 | + 'params' => $options, |
| 111 | + ]); |
255 | 112 |
|
256 | 113 | return true; |
| 114 | + |
257 | 115 | } |
258 | 116 |
|
259 | 117 | /** |
|
0 commit comments