| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  | <?php | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |  * Copyright 2019 Netsyms Technologies. | 
					
						
							|  |  |  |  * This Source Code Form is subject to the terms of the Mozilla Public | 
					
						
							|  |  |  |  * License, v. 2.0. If a copy of the MPL was not distributed with this | 
					
						
							|  |  |  |  * file, You can obtain one at http://mozilla.org/MPL/2.0/. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | redirectIfNotLoggedIn(); | 
					
						
							|  |  |  | $user = new User($_SESSION['uid']); | 
					
						
							|  |  |  | if (!$user->hasPermission("MACHINEMANAGER_VIEW")) { | 
					
						
							|  |  |  |     header("Location: ./app.php?msg=no_permission"); | 
					
						
							|  |  |  |     die(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $writeaccess = $user->hasPermission("MACHINEMANAGER_EDIT"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 21:29:37 -06:00
										 |  |  | $machines = $database->query("SELECT machines.machineid, machines.clientid, machines.model, machines.os, machines.serial, events.date AS eventdate, events.eventname
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  | FROM   machines | 
					
						
							|  |  |  | LEFT OUTER JOIN events ON events.machineid = machines.machineid | 
					
						
							| 
									
										
										
										
											2020-06-27 19:06:25 -06:00
										 |  |  | WHERE (date=(SELECT MAX(s2.date) | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                 FROM events s2 | 
					
						
							|  |  |  |                 WHERE machines.machineid = s2.machineid | 
					
						
							|  |  |  |             ) | 
					
						
							| 
									
										
										
										
											2020-06-27 19:06:25 -06:00
										 |  |  | OR NOT EXISTS (SELECT * FROM events WHERE events.machineid = machines.machineid)) AND deleted = 0")->fetchAll();
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:25:04 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | $clients = Clients::getAll(); | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  | ?>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <div class="btn-group"> | 
					
						
							|  |  |  |     <?php if ($writeaccess) { ?>
 | 
					
						
							|  |  |  |         <a href="app.php?page=editmachine" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Add Machine"); ?></a>
 | 
					
						
							|  |  |  |     <?php } ?>
 | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | <table id="machinetable" class="table table-bordered table-hover table-sm"> | 
					
						
							|  |  |  |     <thead> | 
					
						
							|  |  |  |         <tr> | 
					
						
							|  |  |  |             <th data-priority="0"></th> | 
					
						
							|  |  |  |             <th data-priority="1"><?php $Strings->get('Actions'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:19:28 -06:00
										 |  |  |             <th data-priority="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('ID'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:25:04 -06:00
										 |  |  |             <th data-priority="2"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('Client'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:19:28 -06:00
										 |  |  |             <th data-priority="4"><i class="fas fa-hdd hidden-sm"></i> <?php $Strings->get('OS/Software'); ?></th>
 | 
					
						
							|  |  |  |             <th data-priority="2"><i class="fas fa-hashtag hidden-sm"></i> <?php $Strings->get('Model'); ?></th>
 | 
					
						
							|  |  |  |             <th data-priority="1"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Last Event'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:25:04 -06:00
										 |  |  |             <th data-priority="3"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Serial'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |         </tr> | 
					
						
							|  |  |  |     </thead> | 
					
						
							|  |  |  |     <tbody> | 
					
						
							|  |  |  |         <?php | 
					
						
							|  |  |  |         foreach ($machines as $m) { | 
					
						
							|  |  |  |             ?>
 | 
					
						
							|  |  |  |             <tr> | 
					
						
							|  |  |  |                 <td></td> | 
					
						
							|  |  |  |                 <td> | 
					
						
							|  |  |  |                     <?php | 
					
						
							|  |  |  |                     if ($writeaccess) { | 
					
						
							|  |  |  |                         ?>
 | 
					
						
							|  |  |  |                         <a class="btn btn-primary btn-sm" href="app.php?page=editmachine&arg=<?php echo $m['machineid']; ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
 | 
					
						
							|  |  |  |                         <a class="btn btn-success btn-sm" href="app.php?page=addevent&id=<?php echo $m['machineid']; ?>" ><i class="fas fa-history"></i> <?php $Strings->get("Add Event"); ?></a>
 | 
					
						
							|  |  |  |                         <?php | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     ?>
 | 
					
						
							| 
									
										
										
										
											2020-06-03 01:06:19 -06:00
										 |  |  |                     <a class="btn btn-info btn-sm" href="app.php?page=printlabel&id=<?php echo $m['machineid']; ?>"><i class="fas fa-print"></i> <?php $Strings->get("Print"); ?></a>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                 </td> | 
					
						
							|  |  |  |                 <td><a href="./app.php?page=viewmachine&id=<?php echo $m['machineid']; ?>"><?php echo $m['machineid']; ?></a></td>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:25:04 -06:00
										 |  |  |                 <td><?php | 
					
						
							|  |  |  |                 foreach ($clients as $c) { | 
					
						
							|  |  |  |                     if ($c->getID() == $m['clientid']) { | 
					
						
							|  |  |  |                         echo $c->getName(); | 
					
						
							|  |  |  |                         break; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 ?></td>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                 <td><?php echo $m['os']; ?></td>
 | 
					
						
							|  |  |  |                 <td><?php echo $m['model']; ?></td>
 | 
					
						
							|  |  |  |                 <td><span class="d-none"><?php echo $m['eventdate']; ?></span><?php echo empty($m['eventdate']) ? "-" : $m["eventname"] . " " . date($SETTINGS["datetime_format"], strtotime($m['eventdate'])); ?></td>
 | 
					
						
							|  |  |  |                 <td><?php echo $m['serial']; ?></td>
 | 
					
						
							|  |  |  |             </tr> | 
					
						
							|  |  |  |             <?php | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         ?>
 | 
					
						
							|  |  |  |     </tbody> | 
					
						
							|  |  |  |     <tfoot> | 
					
						
							|  |  |  |         <tr> | 
					
						
							|  |  |  |             <th data-priority="0"></th> | 
					
						
							|  |  |  |             <th data-priority="1"><?php $Strings->get('Actions'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:19:28 -06:00
										 |  |  |             <th data-priority="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('ID'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:25:04 -06:00
										 |  |  |             <th data-priority="2"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('Client'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:19:28 -06:00
										 |  |  |             <th data-priority="4"><i class="fas fa-hdd hidden-sm"></i> <?php $Strings->get('OS/Software'); ?></th>
 | 
					
						
							|  |  |  |             <th data-priority="2"><i class="fas fa-hashtag hidden-sm"></i> <?php $Strings->get('Model'); ?></th>
 | 
					
						
							|  |  |  |             <th data-priority="1"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Last Event'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2020-05-16 15:25:04 -06:00
										 |  |  |             <th data-priority="3"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Serial'); ?></th>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |         </tr> | 
					
						
							|  |  |  |     </tfoot> | 
					
						
							|  |  |  | </table> |