54 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /* 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();
 | |
| }
 | |
| 
 | |
| if (!empty($_GET["id"])) {
 | |
|     $machineid = $_GET["id"];
 | |
| } else if (!empty($_GET["arg"])) {
 | |
|     $machineid = $_GET["arg"];
 | |
| }
 | |
| if (!Machine::exists($machineid)) {
 | |
|     header("Location: ./app.php?msg=no_such_machine");
 | |
|     exit();
 | |
| }
 | |
| 
 | |
| $labeltype = array_keys($SETTINGS["labels"]["templates"])[0];
 | |
| 
 | |
| if (!empty($VARS["labeltype"]) && array_key_exists($VARS["labeltype"], $SETTINGS["labels"]["templates"])) {
 | |
|     $labeltype = $VARS["labeltype"];
 | |
| }
 | |
| 
 | |
| $machine = new Machine($machineid);
 | |
| 
 | |
| $pdfurl = "./print/print.php?labeltype=$labeltype&id=$machineid";
 | |
| ?>
 | |
| 
 | |
| <div class="d-flex">
 | |
|     <ul class="nav nav-tabs">
 | |
|         <?php
 | |
|         foreach ($SETTINGS["labels"]["templates"] as $id => $display) {
 | |
|             ?>
 | |
|             <li class="nav-item">
 | |
|                 <a class="nav-link<?php echo ($labeltype == $id ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>&labeltype=<?php echo $id; ?>"><?php echo $display; ?></a>
 | |
|             </li>
 | |
|             <?php
 | |
|         }
 | |
|         ?>
 | |
|     </ul>
 | |
|     <div class="ml-auto">
 | |
|         <a href="./app.php?page=viewmachine&id=<?php echo $machine->getID(); ?>" class="btn btn-info btn-sm"><i class="fas fa-eye"></i> <?php $Strings->get("Go to machine"); ?></a>
 | |
|     </div>
 | |
| </div>
 | |
| 
 | |
| <div>
 | |
|     <iframe src="./print/pdfjs/web/viewer.html?<?php echo "labeltype=$labeltype&id=$machineid"; ?>" width="100%" height="500px"></iframe>
 | |
| </div>
 |