| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2017-12-16 13:32:58 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* 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/. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  | require_once __DIR__ . '/../required.php'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | redirectifnotloggedin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $locdata = [ | 
					
						
							|  |  |  |     'locid' => '', | 
					
						
							|  |  |  |     'locname' => '', | 
					
						
							|  |  |  |     'loccode' => '', | 
					
						
							|  |  |  |     'locinfo' => '' | 
					
						
							|  |  |  | ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $editing = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  | if (!empty($VARS['id'])) { | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |     if ($database->has('locations', ['locid' => $VARS['id']])) { | 
					
						
							|  |  |  |         $editing = true; | 
					
						
							|  |  |  |         $locdata = $database->select( | 
					
						
							|  |  |  |                         'locations', [ | 
					
						
							|  |  |  |                     'locid', | 
					
						
							|  |  |  |                     'locname', | 
					
						
							|  |  |  |                     'loccode', | 
					
						
							|  |  |  |                     'locinfo' | 
					
						
							|  |  |  |                         ], [ | 
					
						
							|  |  |  |                     'locid' => $VARS['id'] | 
					
						
							|  |  |  |                 ])[0]; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         // cat id is invalid, redirect to a page that won't cause an error when pressing Save
 | 
					
						
							|  |  |  |         header('Location: app.php?page=editloc'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ?>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <form role="form" action="action.php" method="POST"> | 
					
						
							| 
									
										
										
										
											2018-01-29 00:37:39 -07:00
										 |  |  |     <div class="card border-green"> | 
					
						
							|  |  |  |             <h3 class="card-header text-green"> | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                 <?php | 
					
						
							|  |  |  |                 if ($editing) { | 
					
						
							|  |  |  |                     ?>
 | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |                     <i class="fas fa-edit"></i> <?php $Strings->build("editing location", ['loc' => "<span id=\"name_title\">" . htmlspecialchars($locdata['locname']) . "</span>"]); ?>
 | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                     <?php | 
					
						
							|  |  |  |                 } else { | 
					
						
							|  |  |  |                     ?>
 | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |                     <i class="fas fa-edit"></i> <?php $Strings->get("Adding new location"); ?>
 | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                     <?php | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 ?>
 | 
					
						
							|  |  |  |             </h3> | 
					
						
							| 
									
										
										
										
											2018-01-29 00:37:39 -07:00
										 |  |  |         <div class="card-body"> | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |             <div class="row"> | 
					
						
							| 
									
										
										
										
											2018-01-29 00:37:39 -07:00
										 |  |  |                 <div class="col-12 col-md-6"> | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                     <div class="form-group"> | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |                         <label for="name"><i class="fas fa-map-marker"></i> <?php $Strings->get("name"); ?></label>
 | 
					
						
							|  |  |  |                         <input type="text" class="form-control" id="name" name="name" placeholder="<?php $Strings->get("placeholder location name"); ?>" required="required" value="<?php echo htmlspecialchars($locdata['locname']); ?>" /> | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                     </div> | 
					
						
							|  |  |  |                 </div> | 
					
						
							| 
									
										
										
										
											2018-01-29 00:37:39 -07:00
										 |  |  |                 <div class="col-12 col-md-6"> | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                     <div class="form-group"> | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |                         <label for="code"><i class="fas fa-barcode"></i> <?php $Strings->get("code"); ?></label>
 | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                         <input type="text" class="form-control" id="code" name="code" placeholder="123456789" value="<?php echo htmlspecialchars($locdata['loccode']); ?>" /> | 
					
						
							|  |  |  |                     </div> | 
					
						
							|  |  |  |                 </div> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             <div class="form-group"> | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |                 <label for="info"><i class="fas fa-info"></i> <?php $Strings->get("Description"); ?></label>
 | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                 <textarea class="form-control" id="info" name="info"><?php echo htmlspecialchars($locdata['locinfo']); ?></textarea>
 | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |         <input type="hidden" name="locid" value="<?php echo isset($VARS['id']) ? htmlspecialchars($VARS['id']) : ""; ?>" /> | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |         <input type="hidden" name="action" value="editloc" /> | 
					
						
							|  |  |  |         <input type="hidden" name="source" value="locations" /> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-29 00:37:39 -07:00
										 |  |  |         <div class="card-footer d-flex"> | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |             <button type="submit" class="btn btn-success mr-auto"><i class="fas fa-save"></i> <?php $Strings->get("save"); ?></button>
 | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |             <?php | 
					
						
							|  |  |  |             if ($editing) { | 
					
						
							|  |  |  |                 ?>
 | 
					
						
							| 
									
										
										
										
											2018-09-07 18:29:25 -06:00
										 |  |  |                 <a href="action.php?action=deleteloc&source=locations&locid=<?php echo htmlspecialchars($VARS['id']); ?>" class="btn btn-danger ml-auto"><i class="fas fa-times"></i> <?php $Strings->get('delete'); ?></a>
 | 
					
						
							| 
									
										
										
										
											2017-05-17 23:09:51 -06:00
										 |  |  |                 <?php | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             ?>
 | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  | </form> |