|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Print all available locations |
| 5 | + ************************************************/ |
| 6 | + |
| 7 | +/* functions */ |
| 8 | +require( dirname(__FILE__) . '/../../../functions/functions.php'); |
| 9 | + |
| 10 | +# initialize user object |
| 11 | +$Database = new Database_PDO; |
| 12 | +$User = new User ($Database); |
| 13 | +$Admin = new Admin ($Database); |
| 14 | +$Tools = new Tools ($Database); |
| 15 | +$Result = new Result (); |
| 16 | + |
| 17 | +# verify that user is logged in |
| 18 | +$User->check_user_session(); |
| 19 | + |
| 20 | +# create csrf token |
| 21 | +$csrf = $User->csrf_cookie ("create", "location"); |
| 22 | + |
| 23 | +# get Location object |
| 24 | +if($_POST['action']!="add") { |
| 25 | + $location = $Admin->fetch_object ("locations", "id", $_POST['id']); |
| 26 | + $location!==false ? : $Result->show("danger", _("Invalid ID"), true, true); |
| 27 | +} |
| 28 | + |
| 29 | +# disable edit on delete |
| 30 | +$readonly = $_POST['action']=="delete" ? "readonly" : ""; |
| 31 | +$link = $readonly ? false : true; |
| 32 | + |
| 33 | +?> |
| 34 | + |
| 35 | + |
| 36 | +<!-- header --> |
| 37 | +<div class="pHeader"><?php print ucwords(_("$_POST[action]")); ?> <?php print _('Location'); ?></div> |
| 38 | + |
| 39 | +<!-- content --> |
| 40 | +<div class="pContent"> |
| 41 | + |
| 42 | + <form id="editLocation"> |
| 43 | + <table id="editLocation" class="table table-noborder table-condensed"> |
| 44 | + |
| 45 | + <tbody> |
| 46 | + <!-- name --> |
| 47 | + <tr> |
| 48 | + <th><?php print _('Name'); ?></th> |
| 49 | + <td> |
| 50 | + <input type="text" class="form-control input-sm" name="name" value="<?php print $location->name; ?>" placeholder='<?php print _('Name'); ?>' <?php print $readonly; ?>> |
| 51 | + <input type="hidden" name="csrf_cookie" value="<?php print $csrf; ?>"> |
| 52 | + <input type="hidden" name="id" value="<?php print $location->id; ?>"> |
| 53 | + <input type="hidden" name="action" value="<?php print $_POST['action']; ?>"> |
| 54 | + </td> |
| 55 | + <td> |
| 56 | + <span class="text-muted"><?php print _("Set Location name"); ?></span> |
| 57 | + </td> |
| 58 | + </tr> |
| 59 | + |
| 60 | + <!-- Latitude --> |
| 61 | + <tr> |
| 62 | + <th><?php print _('Latitude'); ?></th> |
| 63 | + <td> |
| 64 | + <input type="text" class="form-control input-sm" name="lat" value="<?php print $location->lat; ?>" placeholder='<?php print _('Latitude'); ?>' <?php print $readonly; ?>> |
| 65 | + </td> |
| 66 | + <td> |
| 67 | + <span class="text-muted"><?php print _("GPS Latitude"); ?></span> |
| 68 | + </td> |
| 69 | + </tr> |
| 70 | + |
| 71 | + <!-- Longitude --> |
| 72 | + <tr> |
| 73 | + <th><?php print _('Longiture'); ?></th> |
| 74 | + <td> |
| 75 | + <input type="text" class="form-control input-sm" name="long" value="<?php print $location->long; ?>" placeholder='<?php print _('Latitude'); ?>' <?php print $readonly; ?>> |
| 76 | + </td> |
| 77 | + <td> |
| 78 | + <span class="text-muted"><?php print _("GPS Longitude"); ?></span> |
| 79 | + </td> |
| 80 | + </tr> |
| 81 | + |
| 82 | + <!-- description --> |
| 83 | + <tr> |
| 84 | + <th><?php print _('Description'); ?></th> |
| 85 | + <td colspan="2"> |
| 86 | + <textarea class="form-control input-sm" name="description" placeholder='<?php print _('Port'); ?>' <?php print $readonly; ?>><?php print $location->description; ?></textarea> |
| 87 | + </td> |
| 88 | + </tr> |
| 89 | + |
| 90 | + </tbody> |
| 91 | + |
| 92 | + </table> |
| 93 | + </form> |
| 94 | +</div> |
| 95 | + |
| 96 | + |
| 97 | +<!-- footer --> |
| 98 | +<div class="pFooter"> |
| 99 | + <div class="btn-group"> |
| 100 | + <button class="btn btn-sm btn-default hidePopupsReload"><?php print _('Cancel'); ?></button> |
| 101 | + <button class="btn btn-sm btn-default <?php if($_POST['action']=="delete") { print "btn-danger"; } else { print "btn-success"; } ?>" id="editLocationSubmit"><i class="fa <?php if($_POST['action']=="add") { print "fa-plus"; } else if ($_POST['action']=="delete") { print "fa-trash-o"; } else { print "fa-check"; } ?>"></i> <?php print ucwords(_($_POST['action'])); ?></button> |
| 102 | + </div> |
| 103 | + <!-- result --> |
| 104 | + <div class="editLocationResult"></div> |
| 105 | +</div> |
0 commit comments