auto commit on 2019-07-05 18:23
authorKilian Saffran <ksaffran@dks.lu>
Fri, 5 Jul 2019 16:23:41 +0000 (18:23 +0200)
committerKilian Saffran <ksaffran@dks.lu>
Fri, 5 Jul 2019 16:23:41 +0000 (18:23 +0200)
backoffice/index.cgi
backoffice/tmpl/block/sidebar.tt
backoffice/tmpl/module/profile/index.tt
backoffice/tmpl/module/users/form_users.js [new file with mode: 0644]
backoffice/tmpl/module/users/form_users.tt [new file with mode: 0644]
backoffice/tmpl/module/users/index.js
backoffice/tmpl/module/users/index.tt
backoffice/tmpl/module/users/javascript.tt

index 6f3e75b..4ac06b0 100644 (file)
@@ -107,7 +107,7 @@ if ($p->{sid} ne ""){
 }
 
 
-$vars->{beforex} = $vars->{page};
+#$vars->{beforex} = $vars->{page};
 if (!exists($sess->{id}) || (!exists($p->{sid})) || $p->{sid} eq ""){
   $skl = "skeleton/login.tt";
 }
@@ -159,6 +159,7 @@ if ($skl ne "skeleton/login.tt" && $vars->{page} =~ /^module/){
   if ($vars->{page} !~ /\.tt$/) {
     $skl = "skeleton/module_file.tt";
   }
+  $vars->{params}= $p;
 }
 
 #END - iFrame - Modules
@@ -172,9 +173,9 @@ $template->process($skl,$vars) || die "Template process failed: ", $template->er
 # }
 
 #  print Dumper($vars);
-# print "/*";
+ print "/*";
 # # print Dumper($p);
-print Dumper($vars);
+print Dumper($vars);
 # # print Dumper($sess);
-print "*/";
+print "*/";
 
index 8cfaf81..677040c 100644 (file)
@@ -1,5 +1,6 @@
 
 [% viewapps = dksdb.prepare("select ap.id,ap.app,ap.description,ap.name,acc.publicenabled,acc.expiration, to_char(expiration,'dd.mm.yyyy') as dspexpiration from apps ap left join appaccess acc on (ap.id=acc.id_app) where acc.id_user=? and acc.expiration >= CURRENT_DATE and ap.activated=true;")%]
+
 <nav class="sidebar sidebar-offcanvas" id="sidebar">
         <ul class="nav">
           <!-- <li class="nav-item">
           [% END %]
           [% END %]
         </ul>
-        
-      </nav>
+              
+[% admcnt = dksdb.prepare("select count(*) as cnt from useringroups where id_user=?;") %]
+[% isadmin = admcnt.execute(session.id) %]
+[% IF isadmin > 0 %]
+<!-- ADMIN APPS -->
+
+  <h2>Admin</h2>
+    <ul class="nav">
+      [% adminapps = dksdb.prepare("select ap.id,ap.app,ap.name,ug.usergroup from apps ap 
+join useringroups uigr on (ap.id_usergroup=uigr.id_group)
+join usergroups ug on (uigr.id_group=ug.id) where ug.usergroup='admin' and uigr.id_user=? order by name;") %]
+        [% FOREACH adm = adminapps.execute(session.id) %]
+        [% IF adm.id %]
+          <li class="nav-item">
+            <a class="nav-link" href="javascript:backoffice.loadpage('module/[% adm.app %]/index.html','[% adm.name %]');">
+              [% IF adm.icon %]
+                <i class="mdi mdi-application menu-icon"></i>
+              [% ELSE %]
+                <i class="mdi mdi-application menu-icon"></i>
+              [% END %]
+              
+              <span class="menu-title">[% adm.name %]</span>
+            </a>
+          </li>
+          [% END %]
+        [% END %]
+    </ul>
+[% END %]
+</nav>
index 3af8cd7..2674001 100644 (file)
@@ -5,7 +5,7 @@
 <div class="col-sm-12">
   <div class="card">
     <div class="card-body">
-     <form id="frm_annuaire" name="frm_annuaire" data-ident_users_id=[% session.id %]>     
+     <form id="frm_profile" name="frm_profile" data-ident_users_id="[% session.id %]">     
           
           <div class="form-group">
               <label for="usersurname">Nom</label>
diff --git a/backoffice/tmpl/module/users/form_users.js b/backoffice/tmpl/module/users/form_users.js
new file mode 100644 (file)
index 0000000..12e871f
--- /dev/null
@@ -0,0 +1,3 @@
+function initpage(){
+  
+}
\ No newline at end of file
diff --git a/backoffice/tmpl/module/users/form_users.tt b/backoffice/tmpl/module/users/form_users.tt
new file mode 100644 (file)
index 0000000..d2a7a5d
--- /dev/null
@@ -0,0 +1,91 @@
+[% userdata = dksdb.prepare("select us.id,us.username,us.prename,us.surname,us.blocked,ug.usergroup as defaultgroup,string_agg(distinct(uign.usergroup),',') as othergroups 
+from users us 
+join usergroups ug on (us.id_usergroup=ug.id)
+left join useringroups uig on (us.id=uig.id_user)
+left join usergroups uign on (uig.id_group=uign.id) where us.id=? group by us.id,ug.id LIMIT 1;") %]
+[% FOREACH usr = userdata.execute(params.id) %]
+<form id="frm_user" data-ident_users_id="[% usr.id %]">
+<div class="form-group">
+  <label for="usersurname">Nom</label>
+              <input type="text" class="form-control fieldsave" id="surname" name="users_surname"  required value="[% usr.surname %]">
+          </div>
+          <div class="form-group">
+            <label for="userprename">Prénom</label>
+            <input type="text" class="form-control fieldsave" id="prename" name="users_prename"  required  value="[% usr.prename %]">
+          </div>
+          <div class="form-group">
+            <label for="username">username (email)</label>
+            <input type="email" class="form-control fieldsave" id="username" name="users_username" pattern="/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/"   required  value="[% usr.username %]">
+          </div>
+          <div class="form-group">
+              <label for="council">Default Group</label>
+              <select class="form-control" title="rien selectionné"  id="id_usergroup" name="users_id_usergroup" >
+                  
+                  [% FOREACH cc=dksdb.query("select id,usergroup from usergroups order by id;") %]
+                  [% IF usr.defaultgroup == cc.usergroup %]
+                  <option value="[cc.id]" selected>[% cc.usergroup %]</option>
+                  [% ELSE %]
+                  <option value="[cc.id]">[% cc.usergroup %]</option>
+                  [% END %]
+                
+                [% END %]
+              </select>
+            </div>
+</form>
+[% END %]
+<h2>Applications</h2>
+[% appdata = dksdb.prepare("select ap.name,ac.id_user,ac.id_app,ac.publicenabled,ac.expiration from appaccess ac join apps ap on (ac.id_app=ap.id) where ac.id_user=?;") %]
+<table class="table table-bordered table-hover table-striped" style="width: 100%; margin: 0px;"  id="tbl_applications">
+                  <thead class="thead-dark"> 
+                    <tr>
+                        <th>Application</th>
+                        <th>Public Enabled</th>
+                        <th>Expiration</th>
+                  </tr>
+                    </thead>
+               
+        <tbody>
+        [% FOREACH uap = appdata.execute(params.id) %]
+        <tr>
+          <td>[% uap.name %]</td>
+          <td>[% uap.publicenabled %]</td>
+          <td>[% uap.expiration %]</td>
+        </tr>
+    [% END %]
+        </tbody>
+    </table>
+<h2>Invoices</h2>
+[% invdata = dksdb.prepare("select iv.id,iv.id_user,iv.reference,iv.invoicedate,iv.email,iv.status,iv.statusdate,iv.voucher,iv.payementmethod,iv.sumgrossamount,iv.payedamount,iv.pdfname from invoices iv left join apps ap on (iv.id_app=ap.id) where id_user=? order by iv.invoicedate DESC;") %]
+<table class="table table-bordered table-hover table-striped" style="width: 100%; margin: 0px;"  id="tbl_invoices">
+                  <thead class="thead-dark"> 
+                    <tr>
+                        <th>Reference</th>
+                        <th>Invoice Date</th>
+                        <th>Status</th>
+                        <th>Status Date</th>
+                        <th>Voucher</th>
+                        <th>Method</th>
+                        <th>Amount</th>
+                        <th>Payed Amount</th>
+                        <th>E-Mail</th>
+                        <th>PDF</th>
+                  </tr>
+                    </thead>
+               
+        <tbody>
+        [% FOREACH ivd = invdata.execute(params.id) %]
+        <tr>
+          <td>[% ivd.reference %]</td>
+          <td>[% ivd.invoicedate %]</td>
+          <td>[% ivd.status %]</td>
+          <td>[% ivd.statusdate %]</td>
+          <td>[% ivd.voucher %]</td>
+          <td>[% ivd.method %]</td>
+          <td>[% ivd.sumgrossamount %]</td>
+          <td>[% ivd.payedamount %]</td>
+          <td>[% ivd.email %]</td>
+          <td>[% IF ivd.pdfname %] <button class="btn btn-info"><i class="mdi mdi-pdf-box"></i></button> [% END %]</td>
+        </tr>
+    [% END %]
+        </tbody>
+    </table>
\ No newline at end of file
index e69de29..12e871f 100644 (file)
@@ -0,0 +1,3 @@
+function initpage(){
+  
+}
\ No newline at end of file
index e69de29..70b211c 100644 (file)
@@ -0,0 +1,47 @@
+
+
+<h1>Utilisateurs</h1>
+
+                <table class="table table-bordered table-hover table-striped" style="width: 100%; margin: 0px;"  id="tbl_users">
+                  <thead class="thead-dark"> 
+                    <tr>
+                        <th>Username</th>
+                        <th>Prename</th>
+                        <th>Surname</th>
+                        <th>Is Blocked</th>
+                        <th>Default Group</th>
+                        <th>Applications</th>
+                        <th>Other Groups</th>
+                        <th>&nbsp;</th>
+                  </tr>
+                    </thead>
+               
+        <tbody>
+        [% FOREACH aus = dksdb.query("select us.id,us.username,us.prename,us.surname,us.blocked,ug.usergroup as defaultgroup,string_agg(ax.name,',') as apps,string_agg(distinct(uign.usergroup),',') as othergroups 
+from users us 
+join usergroups ug on (us.id_usergroup=ug.id)
+left join useringroups uig on (us.id=uig.id_user)
+left join usergroups uign on (uig.id_group=uign.id)
+left join (
+select ap.name,ac.id_user,ac.id_app,ac.publicenabled,ac.expiration,row_number() over (partition by ac.id_user) from appaccess ac join apps ap on (ac.id_app=ap.id) 
+) ax
+on (us.id=ax.id_user and ax.id_app is not null)
+group by us.id,ug.id") %]
+        <tr>
+          <td>[% aus.username %]</td>
+          <td>[% aus.prename %]</td>
+          <td>[% aus.surname %]</td>
+          <td>[% aus.blocked %]</td>
+          <td>[% aus.defaultgroup %]</td>
+          <td>[% aus.apps %]</td>
+          <td>[% aus.othergroups %]</td>
+          <td>
+            <button class="btn btn-info" onclick="parent.backoffice.loadpage('module/users/form_users.html?id=[% aus.id %]','App User');"><i class="mdi mdi-pencil"></i></button>
+            [% IF aus.id != session.id %]
+            <button class="btn btn-danger" onclick="delete_user('[% aus.id %]');"><i class="mdi mdi-trash-can"></i></button>
+            [% END %]
+          </td>
+        </tr>
+    [% END %]
+        </tbody>
+    </table>
index e69de29..ef812af 100644 (file)
@@ -0,0 +1,4 @@
+<script src="[% abspath %]vendors/js-form-validator/js-form-validator.js"></script>
+<script src="[% abspath %]vendors/bootstrap-select/js/bootstrap-select.min.js"></script>
+<script src="[% abspath %]js/fieldsave.js"></script>
+<script src="[% pagename %].js"></script>