1<h4><?php print _('List of all locations'); ?></h4> 2<hr> 3 4<?php 5if($User->get_module_permissions ("locations")>1) { 6include('menu.php'); 7} 8?> 9 10 11<?php 12 13/** 14 * Script to print locations 15 ***************************/ 16 17# verify that user is logged in 18$User->check_user_session(); 19 20# perm check 21if ($User->get_module_permissions ("locations")<1) { 22 $Result->show("danger", _("You do not have permissions to access this module"), false); 23} 24# check that location support isenabled 25elseif ($User->settings->enableLocations!="1") { 26 $Result->show("danger", _("Locations module disabled."), false); 27} 28else { 29 # fetch all locations 30 $all_locations = $Tools->fetch_all_objects("locations", "name"); 31 32 $colspan = 4; 33 34 // table 35 print "<table class='table sorted table-striped table-top table-td-top' data-cookie-id-table='all_locations'>"; 36 // headers 37 print "<thead>"; 38 print "<tr>"; 39 print " <th>"._('Name')."</th>"; 40 print " <th>"._('Objects')."</th>"; 41 print " <th>"._('Description')."</th>"; 42 print " <th>"._('Address')."</th>"; 43 print " <th>"._('Coordinates')."</th>"; 44 if(sizeof($custom) > 0) { 45 foreach($custom as $field) { 46 if(!in_array($field['name'], $hidden_custom_fields)) { 47 print "<th class='hidden-xs hidden-sm hidden-md'>".$Tools->print_custom_field_name ($field['name'])."</th>"; 48 $colspan++; 49 } 50 } 51 } 52 if($User->get_module_permissions ("locations")>1) 53 print " <th style='width:80px'></th>"; 54 print "</tr>"; 55 print "</thead>"; 56 57 print "<tbody>"; 58 59 # if none than print 60 if($all_locations===false) { 61 print "<tr>"; 62 print " <td colspan='$colspan'>".$Result->show("info","No Locations configured", false, false, true)."</td>"; 63 print "</tr>"; 64 } 65 else { 66 foreach ($all_locations as $l) { 67 68 // count 69 $cnt = $Tools->fetch_location_objects ($l->id, true); 70 $cnt = $cnt[0]->cnt; 71 72 // print 73 print "<tr>"; 74 print " <td><a class='btn btn-xs btn-default' href='".create_link("tools", "locations", $l->id)."'><i class='fa fa-map prefix'></i> $l->name</a></td>"; 75 print " <td><span class='badge badge1 badge5'>$cnt "._('objects')."</span></td>"; 76 // description 77 $l->description = strlen($l->description)==0 ? "/" : $l->description; 78 print " <td><span class='text-muted'>$l->description</span></td>"; 79 // address 80 $l->address = strlen($l->address)==0 ? "/" : $l->address; 81 print "<td>$l->address</td>"; 82 // coordinates 83 if(strlen($l->lat)>0 || strlen($l->long)==0) { print "<td><span class='text-muted'>$l->lat / $l->long</span></td>"; } 84 else { print "<td>".$Result->show("warning", _("Location not set"), false, false, true)."</td>"; } 85 //custom 86 if(sizeof($custom) > 0) { 87 foreach($custom as $field) { 88 if(!in_array($field['name'], $hidden_custom_fields)) { 89 print "<td class='hidden-xs hidden-sm hidden-md'>"; 90 $Tools->print_custom_field ($field['type'], $l->{$field['name']}); 91 print "</td>"; 92 } 93 } 94 } 95 // actions 96 if($User->get_module_permissions ("locations")>1) { 97 print "<td class='actions'>"; 98 $links = []; 99 $links[] = ["type"=>"header", "text"=>"Show"]; 100 $links[] = ["type"=>"link", "text"=>"Show location", "href"=>create_link($_GET['page'], "locations", $l->id), "icon"=>"eye", "visible"=>"dropdown"]; 101 $links[] = ["type"=>"divider"]; 102 103 $links[] = ["type"=>"header", "text"=>"Manage"]; 104 $links[] = ["type"=>"link", "text"=>"Edit location", "href"=>"", "class"=>"open_popup", "dataparams"=>"data-script='app/admin/locations/edit.php' data-action='edit' data-id='$l->id'", "icon"=>"pencil"]; 105 106 if($User->get_module_permissions ("locations")>2) { 107 $links[] = ["type"=>"link", "text"=>"Delete location", "href"=>"", "class"=>"open_popup", "dataparams"=>"data-script='app/admin/locations/edit.php' data-action='delete' data-id='$l->id'", "icon"=>"times"]; 108 $links[] = ["type"=>"divider"]; 109 } 110 // print links 111 print $User->print_actions($User->user->compress_actions, $links); 112 print "</td>"; 113 114 } 115 116 print "</tr>"; 117 } 118 } 119 print "</tbody>"; 120 print "</table>"; 121}