summaryrefslogtreecommitdiff
path: root/public/ui-profile.php
blob: db0db63ca14b16275ffe0f859d509320a974b1a3 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
include("config/parametres.php");
include("includes/sessions.php");
include("includes/functions.php");

// if visitor then go to '/'
if (!ROLE) {
  header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
  header("Cache-Control: post-check=0, pre-check=0", false);
  header("Pragma: no-cache");
  header("Location: /");
  die();
}

$birth = date("D j M Y, h:i:sa", $_SESSION['birth']);

?><!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>
  <?php // Menu ----------------------------------------------------------------
        include("includes/menu.php");
  ?>

    <div class="profile-container">
      <div class="row">
        <div class="col-md-12">
          <h2>Προφίλ</h2>
          <h4>Στοιχεία Χρήστη</h4>

          <hr />

          <div class="user-profile">
            <div><span>Ονοματεπώνυμο χρήστη :</span> <strong><?=$_SESSION['name']?></strong></div>
            <div><span>Ρόλος :</span> <strong><?=USER_ROLES[$_SESSION['role']]?></strong></div>
            <div><span>Ημερομηνία δημιουργίας :</span> <?=local_dt($_SESSION['birth'])?> </div>
            <div><span>Email σύνδεσης :</span> <strong><?=$_SESSION['email']?></strong></div>
          </div>

          <hr />

          <div class="some-form">
            <p>
              <a class="btn btn-pi-light" data-toggle="collapse" href="#collapse-pass" role="button">Αλλαγή Κωδικού Πρόσβασης</a>
            </p>
            <div class="collapse" id="collapse-pass">
              <div class="card card-body">
                <form id="change-pass" method="post">

                  <div class="form-group">
                    <label for="pass">Νέος κωδικός πρόσβασης</label>
                    <input class="form-control" type="password" name="pass" required>
                  </div>
                  <div class="form-group">
                    <label for="confirm">Επιβεβαίωση κωδικού</label>
                    <input class="form-control" type="password" name="confirm" required>
                  </div>
                  <br />

                  <input class="btn btn-primary" type="submit" value="Αποθήκευση νέου κωδικού">

                </form>
              </div>
            </div>
          </div>

        </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>

  var waitingResponse = false;    // flag for an ajax request that was sent and still waiting response

  // 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 = '/';
        }
      });
    }
  });
*/


  // 01. MENU MANAGEMENT
  // ---------------------------------------------------------------------------
  //////////////////////////////////////////////////////////////////////////////

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

    if (!waitingResponse) {
      waitingResponse = true;

      // var r = confirm("Δεν έχετε αποθηκεύσει το τρέχον αντικείμενο!\nΕίστε σίγουροι ότι θέλετε να εγκαταλείψετε τη σελίδα;");
      r = true;     // no need for confirmation
      if (r == true) {

        // 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 = '/';
            }
          });
        }

      }
      else {
        // user did not confirmed the selection; do nothing
      }

      waitingResponse = false;
    }

  });


  // 02. CHANGE PASSWORD
  // ---------------------------------------------------------------------------
  //////////////////////////////////////////////////////////////////////////////

  $('#change-pass').on('submit', function(e){
    e.preventDefault();

    // check passwords are not-empty and match
    // if ok submit request
    // if submited echo everythig is ok
    // then close password section
    alert('submit form');
  });


  </script>

  </body>
</html>