| 
									
										
										
										
											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(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (!empty($_GET["id"])) { | 
					
						
							|  |  |  |     $machineid = $_GET["id"]; | 
					
						
							|  |  |  | } else if (!empty($_GET["arg"])) { | 
					
						
							|  |  |  |     $machineid = $_GET["arg"]; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | if (!Machine::exists($machineid)) { | 
					
						
							| 
									
										
										
										
											2020-06-03 01:06:19 -06:00
										 |  |  |     header("Location: ./app.php?msg=no_such_machine"); | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $machine = new Machine($machineid); | 
					
						
							|  |  |  | ?>
 | 
					
						
							|  |  |  | <div class="card"> | 
					
						
							|  |  |  |     <h3 class="card-header d-flex"> | 
					
						
							|  |  |  |         <div> | 
					
						
							| 
									
										
										
										
											2020-06-26 19:49:57 -06:00
										 |  |  |             <i class="<?php echo $machine->getIcon(); ?>"></i> <?php echo $machine->getTypeLabel(); ?> #<?php echo htmlspecialchars($machine->getID()); ?>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |         </div> | 
					
						
							|  |  |  |         <?php if ($user->hasPermission("MACHINEMANAGER_EDIT")) { ?>
 | 
					
						
							|  |  |  |             <div class="ml-auto"> | 
					
						
							|  |  |  |                 <a href="./app.php?page=editmachine&arg=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-primary btn-sm"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
 | 
					
						
							|  |  |  |                 <a href="./app.php?page=addevent&id=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-success btn-sm"><i class="fas fa-history"></i> <?php $Strings->get("Add Event"); ?></a>
 | 
					
						
							| 
									
										
										
										
											2020-07-15 18:43:57 -06:00
										 |  |  |                 <div class="btn-group"> | 
					
						
							|  |  |  |                     <a href="./app.php?page=editcomponent&machine=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-success btn-sm"><i class="fas fa-memory"></i> <?php $Strings->get("Add Component"); ?></a>
 | 
					
						
							|  |  |  |                     <button type="button" class="btn btn-success btn-sm dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | 
					
						
							|  |  |  |                         <span class="sr-only">Toggle Dropdown</span> | 
					
						
							|  |  |  |                     </button> | 
					
						
							|  |  |  |                     <div class="dropdown-menu"> | 
					
						
							|  |  |  |                         <a class="dropdown-item" href="./app.php?page=components&attachto=<?php echo htmlspecialchars($machine->getID()); ?>"><?php $Strings->get("Attach Existing"); ?></a>
 | 
					
						
							|  |  |  |                     </div> | 
					
						
							|  |  |  |                 </div> | 
					
						
							| 
									
										
										
										
											2020-06-03 01:06:19 -06:00
										 |  |  |                 <a href="./app.php?page=printlabel&id=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-info btn-sm"><i class="fas fa-print"></i> <?php $Strings->get("Print Labels"); ?></a>
 | 
					
						
							|  |  |  |                 <a href="./app.php?page=machines" class="btn btn-danger btn-sm"><i class="fas fa-arrow-left"></i> <?php $Strings->get("Back"); ?></a>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |             </div> | 
					
						
							|  |  |  |         <?php } ?>
 | 
					
						
							|  |  |  |     </h3> | 
					
						
							|  |  |  |     <div class="card-body"> | 
					
						
							|  |  |  |         <div class="row"> | 
					
						
							|  |  |  |             <div class="col-sm-6 mb-3"> | 
					
						
							| 
									
										
										
										
											2020-06-26 19:49:57 -06:00
										 |  |  |                 <h6>Device Info:</h6> | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                 <div class="list-group"> | 
					
						
							| 
									
										
										
										
											2020-06-27 16:23:33 -06:00
										 |  |  |                     <?php | 
					
						
							|  |  |  |                     if (!empty($machine->getClientID())) { | 
					
						
							|  |  |  |                         $client = Clients::getClient($machine->getClientID()); | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                         ?>
 | 
					
						
							| 
									
										
										
										
											2020-06-27 16:23:33 -06:00
										 |  |  |                         <div class="list-group-item"> | 
					
						
							|  |  |  |                             <b><?php $Strings->get("Client"); ?></b>: <?php echo htmlspecialchars($client->getName()); ?>
 | 
					
						
							|  |  |  |                             <br /> | 
					
						
							|  |  |  |                             <div class="ml-3"> | 
					
						
							|  |  |  |                                 <?php if (!empty($client->getPhone())) { ?>
 | 
					
						
							|  |  |  |                                     <b>Phone:</b> <?php echo $client->getPhone(); ?>
 | 
					
						
							|  |  |  |                                     <br /> | 
					
						
							|  |  |  |                                 <?php } ?>
 | 
					
						
							|  |  |  |                                 <?php if (!empty($client->getBillingAddress())) { ?>
 | 
					
						
							|  |  |  |                                     <b>Billing address:</b><br><?php echo str_replace("\n", "\n<br>", htmlspecialchars($client->getBillingAddress())); ?>
 | 
					
						
							|  |  |  |                                     <br /> | 
					
						
							|  |  |  |                                 <?php } ?>
 | 
					
						
							|  |  |  |                                 <?php if (!empty($client->getMailingAddress())) { ?>
 | 
					
						
							|  |  |  |                                     <b>Mailing address:</b><br><?php echo str_replace("\n", "\n<br>", htmlspecialchars($client->getMailingAddress())); ?>
 | 
					
						
							|  |  |  |                                 <?php } ?>
 | 
					
						
							|  |  |  |                                 <br /> | 
					
						
							|  |  |  |                             </div> | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                         <?php | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     ?>
 | 
					
						
							|  |  |  |                     <?php if (!empty($machine->getOS())) { ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							|  |  |  |                             <b><?php $Strings->get("OS/Software"); ?></b>: <?php echo htmlspecialchars($machine->getOS()); ?>
 | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     <?php } ?>
 | 
					
						
							|  |  |  |                     <?php if (!empty($machine->getSerial())) { ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							|  |  |  |                             <b><?php $Strings->get("Serial"); ?></b>: <?php echo htmlspecialchars($machine->getSerial()); ?>
 | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     <?php } ?>
 | 
					
						
							|  |  |  |                     <?php if (!empty($machine->getManufacturer())) { ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							|  |  |  |                             <b><?php $Strings->get("Manufacturer"); ?></b>: <?php echo htmlspecialchars($machine->getManufacturer()); ?>
 | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     <?php } ?>
 | 
					
						
							|  |  |  |                     <?php if (!empty($machine->getModel())) { ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							|  |  |  |                             <b><?php $Strings->get("Model"); ?></b>: <?php echo htmlspecialchars($machine->getModel()); ?>
 | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     <?php } ?>
 | 
					
						
							|  |  |  |                     <?php if (!empty($machine->getCondition())) { ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							|  |  |  |                             <b><?php $Strings->get("Condition"); ?></b>: <?php
 | 
					
						
							|  |  |  |                             $val = $machine->getCondition(); | 
					
						
							|  |  |  |                             $filled = floor($val); | 
					
						
							|  |  |  |                             $empty = 10; | 
					
						
							|  |  |  |                             while ($filled > 0) { | 
					
						
							|  |  |  |                                 $filled--; | 
					
						
							|  |  |  |                                 $empty--; | 
					
						
							|  |  |  |                                 echo "<i class=\"fas fa-star\"></i> "; | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                             if ($val - floor($val) > 0.75) { | 
					
						
							|  |  |  |                                 $empty--; | 
					
						
							|  |  |  |                                 echo "<i class=\"fas fa-star\"></i> "; | 
					
						
							|  |  |  |                             } else if ($val - floor($val) > 0.25) { | 
					
						
							|  |  |  |                                 $empty--; | 
					
						
							|  |  |  |                                 echo "<i class=\"fas fa-star-half-alt\"></i> "; | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                             while ($empty > 0) { | 
					
						
							|  |  |  |                                 $empty--; | 
					
						
							|  |  |  |                                 echo "<i class=\"far fa-star\"></i> "; | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                             echo " ($val/10)"; | 
					
						
							|  |  |  |                             ?>
 | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     <?php } ?>
 | 
					
						
							|  |  |  |                     <?php if (!empty($machine->getPrice())) { ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							|  |  |  |                             <b><?php $Strings->get("Price"); ?></b>: $<?php echo number_format($machine->getPrice(), 2); ?>
 | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     <?php } ?>
 | 
					
						
							| 
									
										
										
										
											2020-06-27 16:04:21 -06:00
										 |  |  |                     <?php | 
					
						
							|  |  |  |                     if (!empty($machine->getPrivateNotes())) { | 
					
						
							|  |  |  |                         ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							| 
									
										
										
										
											2020-06-27 16:12:21 -06:00
										 |  |  |                             <b><?php $Strings->get("Private Notes"); ?></b>:<br><div class="ml-3"><?php echo str_replace("\n", "\n<br>", htmlspecialchars($machine->getPrivateNotes())); ?></div>
 | 
					
						
							| 
									
										
										
										
											2020-06-27 16:04:21 -06:00
										 |  |  |                         </div> | 
					
						
							|  |  |  |                         <?php | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     if (!empty($machine->getPublicNotes())) { | 
					
						
							|  |  |  |                         ?>
 | 
					
						
							|  |  |  |                         <div class="list-group-item"> | 
					
						
							| 
									
										
										
										
											2020-06-27 16:12:21 -06:00
										 |  |  |                             <b><?php $Strings->get("Public Notes"); ?></b>:<br><div class="ml-3"><?php echo str_replace("\n", "\n<br>", htmlspecialchars($machine->getPublicNotes())); ?></div>
 | 
					
						
							| 
									
										
										
										
											2020-06-27 16:04:21 -06:00
										 |  |  |                         </div> | 
					
						
							|  |  |  |                         <?php | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                     ?>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                 </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 <?php | 
					
						
							|  |  |  |                 $history = $machine->getEvents(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if (count($history) > 0) { | 
					
						
							|  |  |  |                     ?>
 | 
					
						
							|  |  |  |                     <div class="mt-4"> | 
					
						
							|  |  |  |                         <h6>Events:</h6> | 
					
						
							|  |  |  |                         <div class="list-group"> | 
					
						
							|  |  |  |                             <?php | 
					
						
							|  |  |  |                             foreach ($history as $h) { | 
					
						
							|  |  |  |                                 echo "<div class=\"list-group-item\">\n"; | 
					
						
							| 
									
										
										
										
											2020-06-07 20:47:02 -06:00
										 |  |  |                                 echo "<b>" . $h->getName() . "</b> on " . date($SETTINGS["datetime_format"], strtotime($h->getDate())) . "<br />\n"; | 
					
						
							| 
									
										
										
										
											2020-06-27 19:06:25 -06:00
										 |  |  |                                 if (!empty($h->getTechUID())) { | 
					
						
							|  |  |  |                                     echo "<b>Technician:</b> " . htmlspecialchars((new User($h->getTechUID()))->getName()) . "<br />\n"; | 
					
						
							|  |  |  |                                 } | 
					
						
							| 
									
										
										
										
											2020-06-07 20:47:02 -06:00
										 |  |  |                                 if (!empty($h->getPublicNotes())) { | 
					
						
							| 
									
										
										
										
											2020-06-27 16:12:21 -06:00
										 |  |  |                                     echo "<div><b>Public Notes:</b><br /><div class=\"ml-3\">" . str_replace("\n", "\n<br>", htmlspecialchars($h->getPublicNotes())) . "</div></div>"; | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                                 } | 
					
						
							| 
									
										
										
										
											2020-06-07 20:47:02 -06:00
										 |  |  |                                 if (!empty($h->getPrivateNotes())) { | 
					
						
							| 
									
										
										
										
											2020-06-27 16:12:21 -06:00
										 |  |  |                                     echo "<div><b>Private Notes:</b><br /><div class=\"ml-3\">" . str_replace("\n", "\n<br>", htmlspecialchars($h->getPrivateNotes())) . "</div></div>"; | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                                 } | 
					
						
							|  |  |  |                                 echo "\n</div>\n"; | 
					
						
							|  |  |  |                             } | 
					
						
							|  |  |  |                             ?>
 | 
					
						
							|  |  |  |                         </div> | 
					
						
							|  |  |  |                     </div> | 
					
						
							|  |  |  |                     <?php | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 ?>
 | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             <?php | 
					
						
							|  |  |  |             $components = $machine->getComponents(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (count($components) > 0) { | 
					
						
							|  |  |  |                 ?>
 | 
					
						
							|  |  |  |                 <div class="col-sm-6 mb-3"> | 
					
						
							|  |  |  |                     <h6>Components:</h6> | 
					
						
							|  |  |  |                     <div class="list-group"> | 
					
						
							|  |  |  |                         <?php | 
					
						
							|  |  |  |                         foreach ($components as $c) { | 
					
						
							|  |  |  |                             ?>
 | 
					
						
							|  |  |  |                             <div class="list-group-item"> | 
					
						
							|  |  |  |                                 <div class="float-right"> | 
					
						
							|  |  |  |                                     <a class="btn btn-primary btn-sm" href="./app.php?page=editcomponent&id=<?php echo $c->getID(); ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
 | 
					
						
							|  |  |  |                                 </div> | 
					
						
							|  |  |  |                                 <b><?php echo $c->getTypeName(); ?></b><br />
 | 
					
						
							|  |  |  |                                 <?php | 
					
						
							|  |  |  |                                 if (!empty($c->getModel())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <b><?php $Strings->get("Model"); ?></b>: <?php echo htmlspecialchars($c->getModel()); ?><br />
 | 
					
						
							|  |  |  |                                     <?php | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                                 if (!empty($c->getCapacity())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <b><?php $Strings->get("Capacity"); ?></b>:  <?php echo htmlspecialchars($c->getCapacity()); ?><br />
 | 
					
						
							|  |  |  |                                     <?php | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                                 if (!empty($c->getSerial())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <b><?php $Strings->get("Serial"); ?></b>:  <?php echo htmlspecialchars($c->getSerial()); ?><br />
 | 
					
						
							|  |  |  |                                     <?php | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-02 23:05:40 -06:00
										 |  |  |                                 if (!empty($c->getManufacturer())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <b><?php $Strings->get("Manufacturer"); ?></b>:  <?php echo htmlspecialchars($c->getManufacturer()); ?><br />
 | 
					
						
							|  |  |  |                                     <?php | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                                 if (!empty($c->getTestedDate())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <b><?php $Strings->get("Tested On"); ?></b>:  <?php echo date($SETTINGS["datetime_format"], strtotime($c->getTestedDate())); ?><br />
 | 
					
						
							|  |  |  |                                     <?php | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                                 if (!empty($c->getPrice())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <b><?php $Strings->get("Price"); ?></b>: $<?php echo number_format($c->getPrice(), 2); ?>
 | 
					
						
							|  |  |  |                                     <?php | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                                 if (!empty($c->getPublicNotes())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <div> | 
					
						
							|  |  |  |                                         <b>Public Notes:</b><br /> | 
					
						
							| 
									
										
										
										
											2020-06-27 16:12:21 -06:00
										 |  |  |                                         <div class="ml-3"><?php echo str_replace("\n", "\n<br>", htmlspecialchars($c->getPublicNotes())); ?></div>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                                     </div> | 
					
						
							|  |  |  |                                     <?php | 
					
						
							|  |  |  |                                 } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                                 if (!empty($c->getPrivateNotes())) { | 
					
						
							|  |  |  |                                     ?>
 | 
					
						
							|  |  |  |                                     <div> | 
					
						
							|  |  |  |                                         <b>Private Notes:</b><br /> | 
					
						
							| 
									
										
										
										
											2020-06-27 16:12:21 -06:00
										 |  |  |                                         <div class="ml-3"><?php echo str_replace("\n", "\n<br>", htmlspecialchars($c->getPrivateNotes())); ?></div>
 | 
					
						
							| 
									
										
										
										
											2019-09-29 22:38:10 -06:00
										 |  |  |                                     </div> | 
					
						
							|  |  |  |                                 <?php } ?>
 | 
					
						
							|  |  |  |                             </div> | 
					
						
							|  |  |  |                             <?php | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                         ?>
 | 
					
						
							|  |  |  |                     </div> | 
					
						
							|  |  |  |                 </div> | 
					
						
							|  |  |  |                 <?php | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             ?>
 | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  | </div> |