2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  LibreNMS 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Copyright  ( c )  2014  Neil  Lathwood  < https :// github . com / laf /  http :// www . lathwood . co . uk / fa > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  This  program  is  free  software :  you  can  redistribute  it  and / or  modify  it 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  under  the  terms  of  the  GNU  General  Public  License  as  published  by  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Free  Software  Foundation ,  either  version  3  of  the  License ,  or  ( at  your 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  option )  any  later  version .   Please  see  LICENSE . txt  at  the  top  level  of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  the  source  code  distribution  for  details . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 07:51:35 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								use  LibreNMS\Authentication\LegacyAuth ;  
						 
					
						
							
								
									
										
										
										
											2018-04-07 15:55:28 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-11 07:51:35 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( ! LegacyAuth :: user () -> hasGlobalAdmin ())  {  
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    die ( 'ERROR: You need to be admin' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								?> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< div  class = " modal fade bs-example-modal-lg "  id = " alert-template "  tabindex = " -1 "  role = " dialog "  aria - labelledby = " Create "  aria - hidden = " true " >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < div  class = " modal-dialog modal-lg " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        < div  class = " modal-content " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < div  class = " modal-header " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < button  type = " button "  class = " close "  data - dismiss = " modal "  aria - hidden = " true " >& times ; </ button > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                < h4  class = " modal-title "  id = " Create " > Alert  Template  ::  < a  href = " https://docs.librenms.org/Alerting/Templates/ " >< i  class = " fa fa-book fa-1x " ></ i >  Docs </ a ></ h4 > 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            < div  class = " modal-body " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                < div  class = " row " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    < div  class = " col-md-12 " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            < label  for = " name " > Template  name :  </ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            < input  type = " text "  class = " form-control input-sm "  id = " name "  name = " name " > 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                        </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            < label  for = " template " > Template :  </ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            < textarea  class = " form-control "  id = " template "  name = " template "  rows = " 15 " ></ textarea > 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                        </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            < label  for = " title " > Alert  title :  </ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            < input  type = " text "  class = " form-control input-sm "  id = " title "  name = " title "  placeholder = " Alert Title " > 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                        </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        < div  class = " form-group " > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                            < label  for = " title_rec " > Recovery  title :  </ label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            < input  type = " text "  class = " form-control input-sm "  id = " title_rec "  name = " title_rec "  placeholder = " Recovery Title " > 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                        </ div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        < button  type = " button "  class = " btn btn-primary btn-sm "  name = " create-template "  id = " create-template " > Create  template </ button > 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-31 15:54:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        < button  type = " button "  class = " btn btn-default btn-sm "  name = " convert-template "  id = " convert-template "  title = " Convert template to new syntax "  style = " display: none " > Convert  template </ button > 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</ div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< script >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$ ( '#alert-template' ) . on ( 'show.bs.modal' ,  function  ( event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var  button  =  $ ( event . relatedTarget ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-19 01:54:14 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    var  template_id  =  $ ( '#template_id' ) . val (); 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    var  default_template  =  $ ( '#default_template' ) . val (); 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-30 06:03:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-07-19 01:54:14 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if ( template_id  !=  null  &&  template_id  !=  '' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if ( default_template  ==  " 1 " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $ ( '#create-template' ) . after ( '<span class="pull-right"><button class="btn btn-primary btn-sm" id="reset-default">Reset to Default</button></span>' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $ ( '#name' ) . prop ( " disabled " , true ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-30 06:03:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $ ( '#create-template' ) . text ( 'Update template' ); 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        $ . ajax ({ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            type :  " POST " , 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-11 14:54:05 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            url :  " ajax_form.php " , 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            data :  {  type :  " parse-alert-template " ,  template_id :  template_id  }, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            dataType :  " json " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            success :  function ( output )  { 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-06 19:08:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $ ( '#template' ) . val ( output [ 'template' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                $ ( '#name' ) . val ( output [ 'name' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-30 18:05:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $ ( '#title' ) . val ( output [ 'title' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $ ( '#title_rec' ) . val ( output [ 'title_rec' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if ( output [ 'template' ] . indexOf ( " { /if} " ) >= 0 ){ 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-16 21:28:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    toastr . info ( 'The old template syntax is no longer supported. Please see https://docs.librenms.org/Alerting/Old_Templates/' ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-31 15:54:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    $ ( '#convert-template' ) . show (); 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								});  
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-06-13 19:44:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$ ( '#alert-template' ) . on ( 'hide.bs.modal' ,  function ( event )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ ( '#template_id' ) . val ( '' ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-27 23:31:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '#template' ) . val ( '' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ ( '#line' ) . val ( '' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ ( '#value' ) . val ( '' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ ( '#name' ) . val ( '' ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-06-30 06:03:44 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '#create-template' ) . text ( 'Create template' ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '#default-template' ) . val ( '0' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ ( '#reset-default' ) . remove (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ ( '#name' ) . prop ( " disabled " , false ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ ( '#error' ) . val ( '' ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-31 15:54:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ ( '#convert-template' ) . hide (); 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-13 19:44:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								});  
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$ ( '#create-template' ) . click ( '' ,  function ( e )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    e . preventDefault (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var  template  =  $ ( " #template " ) . val (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var  template_id  =  $ ( " #template_id " ) . val (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var  name  =  $ ( " #name " ) . val (); 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-30 17:27:31 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    var  title  =  $ ( " #title " ) . val (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var  title_rec  =  $ ( " #title_rec " ) . val (); 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    alertTemplateAjaxOps ( template ,  name ,  template_id ,  title ,  title_rec ); 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								});  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-31 15:54:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$ ( '#convert-template' ) . click ( '' ,  function ( e )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    e . preventDefault (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    var  template  =  $ ( " #template " ) . val (); 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-19 09:28:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    var  title     =  $ ( " #title " ) . val (); 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-31 15:54:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $ . ajax ({ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        type :  " POST " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        url :  " ajax_form.php " , 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-19 09:28:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        data :  { type :  " convert-template " ,  template :  template ,  title :  title }, 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-31 15:54:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        dataType :  " json " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        success :  function ( output )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if ( output . status  ===  'ok' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                toastr . success ( output . message ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $ ( " #convert-template " ) . hide (); 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-19 09:28:57 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $ ( " #template " ) . val ( output . template ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $ ( " #title " ) . val ( output . title ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-31 15:54:12 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                toastr . error ( output . message ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        error :  function (){ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            toastr . error ( 'An error occurred updating this alert template.' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								});  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function  alertTemplateAjaxOps ( template ,  name ,  template_id ,  title ,  title_rec )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $ . ajax ({ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        type :  " POST " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        url :  " ajax_form.php " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        data :  {  type :  " alert-templates " ,  template :  template ,  name :  name ,  template_id :  template_id ,  title :  title ,  title_rec :  title_rec }, 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-07 15:22:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        dataType :  " json " , 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        success :  function ( output )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            console . log ( output ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-07 15:22:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if ( output . status  ==  'ok' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                toastr . success ( output . message ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                $ ( " #alert-template " ) . modal ( 'hide' ); 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-07 15:22:08 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if ( template_id  !=  null  &&  template_id  !=  '' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $ ( '#templatetable tbody tr' ) . each ( function  ( i ,  row )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        if  ( $ ( row ) . children () . eq ( 0 ) . text ()  ==  template_id )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            $ ( row ) . children () . eq ( 1 ) . text ( name ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            // We found our match so stop looping through the table
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                            return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    }); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    var  newrow  =  [{ id :  output . newid ,  templatename : name }]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $ ( '#templatetable' ) . bootgrid ( " append " ,  newrow ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                toastr . error ( output . message ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }, 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        error :  function (){ 
							 
						 
					
						
							
								
									
										
										
										
											2018-07-14 22:15:43 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            toastr . error ( 'An error occurred updating this alert template.' ); 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-12 22:21:13 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-11-30 17:49:52 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								</ script >