status 2019-03-13
authorKilian Saffran <ksaffran@dks.lu>
Wed, 13 Mar 2019 14:55:47 +0000 (15:55 +0100)
committerKilian Saffran <ksaffran@dks.lu>
Wed, 13 Mar 2019 14:55:47 +0000 (15:55 +0100)
index.php
lib/processdata.php
tmpl/blocks/avocatsearch.php
tmpl/pages/profile/applications.php
tmpl/pages/profile/package.php
tmpl/pages/profile/profile.php
tmpl/pages/rendezvous.php

index abf9de8..8252e39 100644 (file)
--- a/index.php
+++ b/index.php
     $sp = explode("/",$_GET["p"]);
     $p = $sp[0];
   }
+  if ($p == "rendezvous") && (count($sp) == 2){
+    //TODO: get id by ident name
+    // $userident = $db->dbquery("select id from users where ident=");
+    // if ($userident){
+    //   $_GET["id"] = 
+    // }else {
+    //   $_GET["id"] = -1;
+    // }
+     
+  }
   // process form data
   if (isset($_POST) && count($_POST) > 0){
     
@@ -53,8 +63,6 @@
 </head>
 <body>
 <?php include("tmpl/navs/profile.php"); ?>
-
-<?php include("tmpl/navs/navigation.php"); ?>
 <main role="main">
   <div class="container-fluid">
       <?php 
index ffef6ac..a0efd96 100644 (file)
           }
           if (isset($gdt["activate"])){
             switch ($gdt['activate']){
-                case 'rendezvous':
-                    $expiredate = date('Y-m-d',strtotime('+21 days'));
-                    if (!(strpos($user['service_valid'],'rendezvous') > 0) && !(strpos($user['service_expired'],'rendezvous') > 0)){
-                        $db->dbexec("INSERT INTO userservices (id_user,service,expiration) VALUES (".$user['id'].",'rendezvous',date('".$expiredate."'))");
-                        $user = getsessiondata($user['sessionid']);
-                    }
-                    
+                case 'evaluation':
+                    activate_evaluation($gdt);
                     break;
             }
           }
-          if (isset($gdt["app"])){
-            if (isset($gdt["autorenew"])){
-              $db->dbexec("UPDATE userservices set autorenew=".$db->secvalue($gdt["autorenew"])." WHERE service='".$db->secvalue($gdt["app"])."' and id_user=".$user['id'].";)");
-            }
-            switch ($gdt['activate']){
-                case 'rendezvous':
-                    $expiredate = date('Y-m-d',strtotime('+21 days'));
-                    if (!(strpos($user['service_valid'],'rendezvous') > 0) && !(strpos($user['service_expired'],'rendezvous') > 0)){
-                        $db->dbexec("INSERT INTO userservices (id_user,service,expiration) VALUES (".$user['id'].",'rendezvous',date('".$expiredate."'))");
-                        $user = getsessiondata($user['sessionid']);
-                    }
-                    
-                    break;
-            }
+          if (isset($gdt["enable"])){
+            enable_app($gdt);
           }
-      }
-        
+        } 
     }
 
     function save_rendezvous($rdv){
         return $rows;
     }
 
-    // function send_company_invitation($pdt){
 
-    // }
-
-    // function delete_profile_company($pdt){
-
-    // }
-
-    function delete_profile_user($pdt){
+    function delete_profile_user(){
+      //must save email in separate table to 
+      //first save user to evaluationtable
+      $db->dbexec("delete FROM users WHERE id=".$user["id"])." cascade;";
+    }
 
+    function activate_evaluation($gdt){
+      global $db,$user,$msg;
+      $sql = "select us.service,us.expiration,us.payeddate,us.isevaluation,apps.name from userservices us join apps on (us.id_app=apps.id) where us.id_app='".$gdt["id"]."' and us.id_user=".$user["id"].";";
+      $eval = $db->dbquery($sql);
+      if ($eval){
+        $msg = '<div class=\"alert alert-danger">Vous avez déjà testé le service '.$eval["name"].'</div>';
+      } else {
+        $sql = "select id,app,name,evaluationdays from apps where id=".$gdt["id"];
+        
+        $eapp = $db->dbquery($sql);
+        if ($eapp["evaluationdays"] == null){
+          $msg = '<div class=\"alert alert-danger">Cette Application n\'a pas une periode d\'évaluation</div>';
+        }else {
+          $evaldate = date('Y-m-d',strtotime("+".$eapp["evaluationdays"]." days"));
+          $evaldateshow = date('d.m.Y',strtotime("+".$eapp["evaluationdays"]." days"));
+          $sql = "INSERT INTO userservices (id_user,service,expiration,isevaluation,id_app) VALUES (".$user["id"].",".$eapp["app"].",date('".$evaldate."'),1,".$gdt["id"].")";
+          $db->dbexec($sql);
+          $msg = '<div class=\"alert alert-success">Periode d\'évaluation a été activé jusqu\'au '.$evaldateshow.'</div>';
+        }
+        
+        
+      }
     }
+      function enable_app($gdt){
+        global $db,$user,$msg;
+        $sql = "select id,service,expiration,payeddate,isevaluation from userservices where id_app='".$gdt["id"]."' and id_user=".$user["id"].";";
+        $eval = $db->dbquery($sql);
+        // $msg = $sql;
+        if ($eval){
+          if ($gdt["enable"] == "0"){ $gdt["enable"] = 'null';}
+          $sql = "UPDATE userservices set enabled=".$gdt["enable"]." WHERE id=".$eval["id"].";";
+          // $msg .= '<br/>'.$sql;
+          $db->dbexec($sql);
+        } else {
+          $sql = "select id,evaluationdays,app from apps where id=".$gdt["id"].";";
+          $eapp = $db->dbquery($sql);
+          if (($eapp) && ($eapp["evaluationdays"] == null)){
+            
+            $sql = "INSERT INTO userservices (id_user,service,id_app,enabled) VALUES (".$user["id"].",'".$eapp["app"]."',".$gdt["id"].",".$gdt["enable"].")";
+            // $msg .= '<br/>'.$sql;
+            $db->dbexec($sql);
+          }
+        }
+      }
 ?>
\ No newline at end of file
index 1ef7927..f56bb8c 100644 (file)
@@ -1,11 +1,18 @@
 <?php
-  $sql = "SELECT case when srv.service = 'rendezvous' and srv.expiration >= CURRENT_DATE then 1 else null end as rendezvous_active,usr.* from users usr left join userservices srv on (usr.id=srv.id_user) where usr.usergroup in ('administrator','avocat')  and usr.userblocked is null and usr.activationkey is null group by usr.id;";
+  $sql = "SELECT case when srv.service = 'rendezvous' and srv.enabled='1' and srv.expiration >= CURRENT_DATE then 1 else null end as rendezvous_active,usr.* from users usr 
+  join userservices annu on (usr.id=annu.id_user and annu.service='annuaire' and annu.enabled=1)
+  join userservices srv on (usr.id=srv.id_user)
+  where usr.usergroup in ('avocat')  and usr.userblocked is null and usr.activationkey is null group by usr.id;";
   $avocats = $db->dbqueryall($sql);
+  ?>
+  
+  <div class="row justify-content-center">
+  <h1>Annuaire des avocats au Luxembourg</h1>
+  </div>
+  <?php
   if ($avocats){
 ?>
-<div class="row justify-content-center">
-<h1>Annuaire des avocats au Luxembourg</h1>
-</div>
+
 <div class="row justify-content-center">
 <?php
 // echo '<!--<div class="col-sm-6" style="width: 100%;">
index b2a2d69..823cb2f 100644 (file)
@@ -1,7 +1,7 @@
 <?php
-    $sql = "select apps.id,apps.name,apps.description,userv.expiration,userv.payeddate,userv.isevaluation,userv.enabled, GROUP_CONCAT(apr.package) as packages, GROUP_CONCAT(apr.monthlyprice) as prices, apps.evaluationdays
+    $sql = "select apps.id,apps.name,apps.description,apps.activated,userv.expiration,userv.payeddate,userv.isevaluation,userv.enabled, GROUP_CONCAT(apr.package) as packages, GROUP_CONCAT(apr.monthlyprice) as prices, apps.evaluationdays
     from apps 
-    left join userservices userv on (apps.id=userv.id_app and userv.id_user='".$user[id]."')
+    left join userservices userv on (apps.id=userv.id_app and userv.id_user='".$user["id"]."')
     left join appprices apr on (apps.id=apr.id_app)
     where apps.activated=1 group by apps.id;";
     $userapps = $db->dbqueryall($sql);
               '<td>'.$appdata["name"].'</td>'.
               '<td>'.$appdata["description"].'</td>'.
               '<td>';
-              if (($appdata["prices"] == "0") || ($appdata["expiration"] >= today )){  
-                if ($userapps["enabled"] == 1){
-                  echo '<button class="btn btn-success">Désactiver</button>';
+              if (($appdata["prices"] == "0") || ($appdata["expiration"] >= $today )){  
+                if ($appdata["enabled"] == "1"){
+                  echo '<button class="btn btn-outline-success btn-block" onclick="location.href=\''.$baseurl.'/profile/applications?id='.$appdata["id"].'&enable=0\';"><i class="far fa-check-square"></i> Désactiver</button>';
                 } else if (($appdata["prices"] == "0") || ($userapps["enabled"] == 0)) {
-                  echo '<button class="btn btn-danger">Activer</button>';
+                  echo '<button class="btn btn-outline-danger btn-block" onclick="location.href=\''.$baseurl.'/profile/applications?id='.$appdata["id"].'&enable=1\';" style="padding: 2px;"><i class="far fa-square"></i> Activer</button>';
                 }
               } else if ($appdata["payeddate"] != null) {
                 echo '<span class="text-danger">désactivé</span>';
               }
               echo '</td>'.
-              '<td>'.$appdata["expiration"].'</td>'.
+              '<td>'.(($appdata["expiration"] != null)?date('d.m.Y',strtotime($appdata["expiration"])):'').'</td>'.
               '<td>';
               if ($appdata["prices"] == "0"){
                   echo '<span class="text-success">activé</span>';
               } else if ($appdata["payeddate"] == null){
-                  echo '<a class="btn btn-primary" onclick="location.href=\''.$baseurl.'/profile/package?id='.$appdata["id"].'\';">Souscrire</a>';
+                  echo '<button class="btn btn-primary" onclick="location.href=\''.$baseurl.'/profile/package?id='.$appdata["id"].'\';">Souscrire</button>';
               } else if ($appdata["expiration"] >= torenewstart) {
-                  echo '<a class="btn btn-primary" onclick="location.href=\''.$baseurl.'/profile/package?id='.$appdata["id"].'\';">Prolonger</a>';
+                  echo '<button class="btn btn-primary" onclick="location.href=\''.$baseurl.'/profile/package?id='.$appdata["id"].'\';">Prolonger</button>';
               }
               echo '</td>'.
               '</tr>';
index 28855fd..37e3086 100644 (file)
@@ -27,7 +27,7 @@
             <h5 class="card-title text-muted text-uppercase text-center">Evaluation</h5>
             <h6 class="card-price text-center"><?php echo $userapps["0"]["evaluationdays"]; ?> jours gratuit</span></h6>
             <hr>
-            <a href="#" class="btn btn-block btn-primary text-uppercase">Activer</a>
+            <a href="<?php echo $baseurl.'/profile/application?app='.$_GET["id"]."&activate=evaluation" ?>" class="btn btn-block btn-primary text-uppercase">Activer</a>
           </div>
         </div>
       </div>
index 5f9936a..edbedb7 100644 (file)
                 //        echo ' <a class="dropdown-item" href="'.$baseurl.'/profile/invoices">Factures</a>';
                     
                 // }
+               
                 ?> 
                 <div class="dropdown-divider"></div>
                 <?php 
-                    if (strpos($user["service_valid"],'rendezvous') >= 0 ){ ?>
+                
+                    if (strpos($user["service_valid"],'rendezvous') !== false ){ 
+                      //echo "srvvaid:".strpos($user["service_valid"],'rendezvous')."";
+                ?>
+                    
                         <h6 class="dropdown-header">Rendez-Vous</h6>
                 <a class="dropdown-item" href="<?php echo $baseurl; ?>/profile/rendezvous/clientlist">Mes Clients</a>
                 <a class="dropdown-item" href="<?php echo $baseurl; ?>/profile/rendezvous/rendezvouslist">Mes Rendez-Vous</a>
                       <label class="custom-file-label" for="files">Selection fichier</label>
                     </div>
                   </div>
-        <!-- <input type="file" id="photo" class="btn btn-info" /> -->
-      <!-- <button type="button" class="btn btn-info" >Ajouter/Remplayer Photo</button> -->
       <a class="btn btn-danger" onclick="javascript:removephoto('user');"><i class="fas fa-trash"></i>&nbsp;supprimer la photo</a>
     </div>
   </div>
                     <input type="text" class="form-control" id="userspecialisations" name="userspecialisations" data-role="tagsinput"    value="<?php echo $userprofile['userspecialisations']; ?>">
                   </div>
                   <div class="row">
-                      <div class="col-sm-6">
-                      <div class="form-group">
-                        <label for="uservisibility">Visualiser profile dans l'annuaire</label>
-                        <input type="checkbox" class="form-control" value="1" id="uservisibility" name="uservisibility" <?php echo (($userprofile['uservisibility'] == 1)? "checked":"") ?> />
-                      </div>
-                      </div>
+                      
                       <div class="col-sm-6">
                       <div class="form-group">
                         <label for="userprice">Prix mandataire (à partir de)</label>
index 93d0cd3..6d731f5 100644 (file)
@@ -17,8 +17,8 @@ $avolist = $db->dbqueryall($sql);
             <div class="col-sm-8">
             <div class="col-sm-12">
             <div class="form-group">
-                        <label for="id_user">Sélectionner l'avocat</label>
-                        <select id="id_user" name="id_user" class="form-control" onchange="getuserdata();">
+                        <label for="id_user">l'avocat selectionné</label>
+                        <select id="id_user" name="id_user" class="form-control" onchange="getuserdata();" disabled>
 <?php
                         foreach ($avolist as $avosel){
                             echo '<option value="'.$avosel['id'].'" '.(($avosel['id'] == $selid)?'selected':'').'>'.$avosel['usersurname'].' '.$avosel['userprename'].' '.(($avosel['usercompany'] != '')?' ('.$avosel['usercompany'].')':'').'</option>';