1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21 22/** 23 * @var CView $this 24 */ 25?> 26 27jQuery(document).ready(function($) { 28 $('#email_send_to').dynamicRows({ 29 template: '#email_send_to_table_row' 30 }); 31 32 // Show/hide multiple "Send to" inputs and single "Send to" input and populate hidden "type" field. 33 $('#mediatypeid') 34 .on('change', function() { 35 var mediatypes_by_type = <?= json_encode($data['mediatypes']) ?>, 36 mediatypeid = $(this).val(); 37 38 if (mediatypes_by_type[mediatypeid] == <?= MEDIA_TYPE_EMAIL ?>) { 39 $('#mediatype_send_to').hide(); 40 $('#mediatype_email_send_to').show(); 41 } 42 else { 43 $('#mediatype_send_to').show(); 44 $('#mediatype_email_send_to').hide(); 45 } 46 47 }) 48 .trigger("change"); 49 50 overlays_stack.end().centerDialog(); 51}); 52 53/** 54 * Send media form data to server for validation before adding them to user media tab. 55 * 56 * @param {Overlay} overlay 57 */ 58function validateMedia(overlay) { 59 var $form = overlay.$dialogue.find('form'); 60 61 $form.trimValues(['#period', '#sendto', 'input[name^="sendto_emails"]']); 62 63 overlay.setLoading(); 64 overlay.xhr = jQuery.ajax({ 65 url: $form.attr('action'), 66 data: $form.serialize(), 67 success: function(ret) { 68 overlay.$dialogue.find('.msg-bad, .msg-good').remove(); 69 70 if (typeof ret.errors !== 'undefined') { 71 jQuery(ret.errors).insertBefore($form); 72 overlay.unsetLoading(); 73 } 74 else { 75 add_media(ret.dstfrm, ret.media, ret.mediatypeid, ret.sendto, ret.period, ret.active, ret.severity); 76 } 77 }, 78 dataType: 'json', 79 type: 'post' 80 }); 81} 82