| 
									
										
										
										
											2015-03-21 21:30:55 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | $no_refresh = true; | 
					
						
							| 
									
										
										
										
											2015-03-21 21:30:55 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ?>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  | <div class="row"> | 
					
						
							|  |  |  |     <div class="col-sm-12"> | 
					
						
							|  |  |  |         <span id="message"></span> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | <?php | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | require_once 'includes/modal/alert_template.inc.php'; | 
					
						
							|  |  |  | require_once 'includes/modal/delete_alert_template.inc.php'; | 
					
						
							|  |  |  | require_once 'includes/modal/attach_alert_template.inc.php'; | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  | ?>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <form method="post" action="" id="result_form"> | 
					
						
							|  |  |  | <?php | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if (isset($_POST['results_amount']) && $_POST['results_amount'] > 0) { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     $results = $_POST['results']; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | } | 
					
						
							|  |  |  | else { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     $results = 50; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo '<div class="table-responsive"> | 
					
						
							|  |  |  | <table class="table table-hover table-condensed" width="100%"> | 
					
						
							|  |  |  |   <tr> | 
					
						
							|  |  |  |     <th>Name</th> | 
					
						
							|  |  |  |     <th>Action</th> | 
					
						
							|  |  |  |   </tr> | 
					
						
							|  |  |  |   <tr> | 
					
						
							|  |  |  |     <td>'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-16 23:45:28 +00:00
										 |  |  | if ($_SESSION['userlevel'] >= '10') { | 
					
						
							| 
									
										
										
										
											2015-07-24 10:28:18 +01:00
										 |  |  |     echo '<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#alert-template" data-template_id="">Create new alert template</button>'; | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo '</td> | 
					
						
							|  |  |  | <td><select name="results" id="results" class="form-control input-sm" onChange="updateResults(this);">'; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | $result_options = array( | 
					
						
							|  |  |  |                    '10', | 
					
						
							|  |  |  |                    '50', | 
					
						
							|  |  |  |                    '100', | 
					
						
							|  |  |  |                    '250', | 
					
						
							|  |  |  |                    '500', | 
					
						
							|  |  |  |                    '1000', | 
					
						
							|  |  |  |                    '5000', | 
					
						
							|  |  |  |                   ); | 
					
						
							|  |  |  | foreach ($result_options as $option) { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     echo "<option value='$option'"; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  |     if ($results == $option) { | 
					
						
							|  |  |  |         echo ' selected'; | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     echo ">$option</option>"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | echo '</select></td>'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $count_query = 'SELECT COUNT(id)'; | 
					
						
							|  |  |  | $full_query  = 'SELECT *'; | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | $query = ' FROM `alert_templates`'; | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | $count_query = $count_query.$query; | 
					
						
							|  |  |  | $count       = dbFetchCell($count_query, $param); | 
					
						
							|  |  |  | if (!isset($_POST['page_number']) && $_POST['page_number'] < 1) { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     $page_number = 1; | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | } | 
					
						
							|  |  |  | else { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     $page_number = $_POST['page_number']; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | $start      = (($page_number - 1) * $results); | 
					
						
							|  |  |  | $full_query = $full_query.$query." LIMIT $start,$results"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | foreach (dbFetchRows($full_query, $param) as $template) { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     echo '<tr id="row_'.$template['id'].'">
 | 
					
						
							|  |  |  |             <td>'.$template['name'].'</td> | 
					
						
							|  |  |  |             <td>'; | 
					
						
							| 
									
										
										
										
											2015-02-16 23:45:28 +00:00
										 |  |  |     if ($_SESSION['userlevel'] >= '10') { | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |         echo "<button type='button' class='btn btn-primary btn-sm' data-toggle='modal' data-target='#alert-template' data-template_id='".$template['id']."' data-template_action='edit' name='edit-alert-template'><span class='glyphicon glyphicon-pencil' aria-hidden='true'></span></button> "; | 
					
						
							|  |  |  |         echo "<button type='button' class='btn btn-danger btn-sm' data-toggle='modal' data-target='#confirm-delete-alert-template' data-template_id='".$template['id']."' name='delete-alert-template'><span class='glyphicon glyphicon-trash' aria-hidden='true'></span></button> "; | 
					
						
							|  |  |  |         echo "<button type='button' class='btn btn-warning btn-sm' data-toggle='modal' data-target='#attach-alert-template' data-template_id='".$template['id']."' name='attach-alert-template'><span class='glyphicon glyphicon-th-list' aria-hidden='true'></span></button>"; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  |     echo '    </td> | 
					
						
							|  |  |  |           </tr>'; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-13 20:10:26 +02:00
										 |  |  | if (($count % $results) > 0) { | 
					
						
							|  |  |  |     echo '    <tr> | 
					
						
							|  |  |  |                   <td colspan="2" align="center">'.generate_pagination($count, $results, $page_number).'</td> | 
					
						
							|  |  |  |               </tr>'; | 
					
						
							| 
									
										
										
										
											2014-11-30 17:49:52 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo '</table> | 
					
						
							|  |  |  | <input type="hidden" name="page_number" id="page_number" value="'.$page_number.'"> | 
					
						
							|  |  |  | <input type="hidden" name="results_amount" id="results_amount" value="'.$results.'"> | 
					
						
							|  |  |  | </form> | 
					
						
							|  |  |  | </div>'; |