summaryrefslogtreecommitdiff
path: root/public/includes/ui-panel.php
blob: 1f408035eb74c632fe265ce85cedecae8c630c62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB" dir="ltr">
  <head>
      <!-- Metas + Title -->
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />

      <title><?=PROJECT?> : Πίνακας Ελέγχου</title>

      <!-- CSS needed -->
      <link href="https://fonts.googleapis.com/css?family=Ubuntu:400,700&display=swap" rel="stylesheet">
      <link rel="stylesheet" href="/css/bootstrap.min.css" /><!-- v4.4.1 -->
      <link rel="stylesheet" href="/css/select2.min.css" /><!-- v4.0.10 -->
      <link rel="stylesheet" href="/css/pi.css" />
  </head>
  <body>

    <div class="pi-container">
      <div class="row">

        <div class="col-md-12">
          <h2><?=PROJECT?></h2>
        </div>

        <!-- menu section -->
        <div class="col-md-4 col-lg-3">
          <h4>Πίνακας Ελέγχου</h4>
          <hr />
              <?php
                  include("includes/menu-contents.php")
              ?>
        </div>
        <!-- / menu section -->

        <div class="col-md-8 col-lg-9 panel-sections">

        <!-- statistics section -->
        <?php if (ROLE > EDITOR) : ?>
          <p>
            <a class="btn btn-warning" data-toggle="collapse" href="#collapse-stats" role="button">Στατιστικά</a>
          </p>
          <div class="collapse show stats" id="collapse-stats">
            <div class="card card-body">
            <table>
                <?php
                    $stats = get_totals();
                    $ccAr = json_decode(CODEJSON);
                    foreach ($ccAr as $key => $val) {
                      if (isset($stats[$val->id])) {
                          echo "<tr>
                                  <td><span>". $val->id ."</span> ". $val->tag . "<a class='btn btn-pi-light' href='/ui-search.php?id=". $val->id ."'>Αναζήτηση</a></td>
                                  <td style='width:45px; text-align:right;'>". $stats[$val->id] ."</td>
                                </tr>
                          ";
                      }
                    }
                ?>
                <tr class="summary"><td>Σύνολο</td><td style='width:45px; text-align:right;'><?=$stats['all']?></td></tr>
            </table>
            </div>
          </div>
        <?php endif; ?>
        <!-- / statistics section -->

        <!-- last items section -->

        <!-- / last items section -->

        <!-- edits history -->
        <!-- / edits history -->

        </div>

      </div>
    </div>





    <!-- scripts and libraries
    load and register one by one, so you don't need to worry about if they are ready -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/1.4.1/jquery-migrate.min.js"></script>
  <script src="/js/bootstrap.min.js"></script>
  <script>

  // functions needed
  // ---------------------------------------------------------------------------

  // pure JS ajax GET request
  // return data as JSON
  // no fancy things like UTF8; if needed use base64 ---------------------------
  function ajax_get(url, callback) {
      var xmlhttp = new XMLHttpRequest();
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

              try {
                  var data = JSON.parse(xmlhttp.responseText);
              } catch(err) {
                  console.log(err.message + " in " + xmlhttp.responseText);
                  return;
              }
              callback(data);
          }
      };

      xmlhttp.open("GET", url, true);
      xmlhttp.send();
  }

  // menu management
  // ---------------------------------------------------------------------------
  $('.dropdown-item').on('click', function(e){
    e.preventDefault();

    // all data-goto have the format: 'method,uri_address'
    // uri_address is the url to call
    // method options:
    // * url : means goto url (redirect)
    // * ajax : means call url via ajax; if 'success = true' then goto '/' after that
    // -------------------------------------------------------------------------
    var opt = $(this).data('goto').split(',');  // split data-goto

    if (opt[0] == 'url') {    // if method = url
      window.location.href = opt[1];
    }
    else {                    // else, method = ajax
      ajax_get(opt[1], function(response) {
        if (response.success) {
          window.location.href = '/';
        }
      });
    }
  });
  </script>

  </body>
</html>