near to version 1
authorKilian Saffran <ksaffran@dks.lu>
Tue, 19 Mar 2019 14:45:04 +0000 (15:45 +0100)
committerKilian Saffran <ksaffran@dks.lu>
Tue, 19 Mar 2019 14:45:04 +0000 (15:45 +0100)
15 files changed:
api.php
lib/process_payment.php
lib/process_profile.php
lib/process_rdv.php
lib/processdata.php
phpinfo.php [deleted file]
site.js
tmpl/blocks/avocatsearch.php
tmpl/javascript.php
tmpl/pages/profile/rendezvous/clientlist.php
tmpl/pages/profile/rendezvous/rendezvouslistold.php
tmpl/pages/profile/rendezvous/timesheetcalendar.php
tmpl/pages/profile/rendezvous/timesheetlist.php
tmpl/pages/rendezvous.php
tmpl/pages/rendezvousevent.php

diff --git a/api.php b/api.php
index 83691a3..eb49a6e 100644 (file)
--- a/api.php
+++ b/api.php
           $num_wd = date('w',strtotime($_GET['day']));
           $str_wd = strtolower(date('D',strtotime($_GET['day'])));
           $sql ="select ".$str_wd."_values as hour_values,option1_name,option1_values,option2_name,option2_values,option3_name,option3_values,option4_name,option4_values from timesheets where startdate <= date('".$_GET['day']."') and weekdays LIKE '%".$num_wd."%' and id_user=".$iduser." order by startdate desc LIMIT 1;";
-          error_log("GET RDVDAY:".$sql);
+          
           $daydata = $db->dbquery($sql);
           $sql ="select dayhours from exceptions where daydate=date('".$_GET['day']."') and id_user=".$iduser.";";
           $exception = $db->dbquery($sql);
-          // $daydata["exception"] = explode(',',$exception["dayhours"]);
+          
           if ($daydata["hour_values"] != ""){
             $daydata["hour_values"] = explode(',',$daydata["hour_values"]);
           } else {
@@ -35,7 +35,7 @@
           //exclude taken rdv times
           $sql = "select eventhour from events where eventdate=date('".$_GET['day']."') and id_user='".$iduser."' and (user_status != 'canceled' or client_status != 'canceled')";
           $takenevents = $db->dbquery($sql);
-          // $daydata["taken"] = explode(',',$takenevents["eventhour"]);
+          
           if ($daydata["hour_values"] != null){
             $dhnew = array();
             if ($takenevents != null){
index c79247c..b5f1dc6 100644 (file)
@@ -15,7 +15,7 @@ function send_invoice(){
   REPLACE(FORMAT(payedamount, 2),'.',',') as payedamount  from invoicedata where id_user=".$user["id"]." order by invoicedate DESC,id DESC LIMIT 1;";
   $pdfdata = $db->dbquery($sql);
   $pdffile = create_pdfinvoice($pdfdata);
-  $msg .= '<br/>'.$pdffile;
+  //$msg .= '<br/>'.$pdffile;
   if ($pdffile != ""){
      $send = sendemail('user_invoice',array("email" => $user["useremail"],"id" => $user["id"]),array($pdffile));
      if ($send == 0){
@@ -107,11 +107,11 @@ function activate_evaluation($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"].";";
@@ -119,7 +119,6 @@ function activate_evaluation($gdt){
       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);
       }
     }
index 0661618..4478eb5 100644 (file)
@@ -75,7 +75,7 @@ function checklogin($username,$passwd){
   $luser = $db->dbquery($sql);
   $sid = null;
   $retuser=null; 
-  //echo "<pre>$sql<br/>".$luser["cnt"]."</pre>";
+
   if ($luser["cnt"] == 1){
       $sid = generateRandomString();
       $sql = "INSERT INTO usersession (sessionid, id_user, lastlogin, useragent, remoteaddr) 
@@ -83,12 +83,11 @@ function checklogin($username,$passwd){
       $db->dbexec($sql);
       setcookie("juridig",$sid);
       $retuser = getsessiondata($sid);
-      
-      //$p='profile';
+
   }else {
       setcookie("juridig","");
       $msg='<div class="alert alert-danger">Utilisateur et/ou mot de passe non connu!</div>';
-      //$p='/home';
+
   }
   return $retuser;
 }
index 7c6f8b7..2f75d04 100644 (file)
       // $msg .= $senddata;
       // $send = 0;
       if ($send == 0){
-        $msg .=  '<div class="alert alert-info">Votre demande à été enregistrée!<br/>
+        $msg =  '<div class="alert alert-info">Votre demande à été enregistrée!<br/>
     Nous vous avons envoyés un email avec un lien de confirmation.<br/>Après confirmation votre demande sera tranférée au avocat!
     </div>';
       } else {
-        $msg .= '<div class="alert alert-danger">Erreur! quelque chose n\'a pas bien fonctionnée!</div>';
+        $msg = '<div class="alert alert-danger">Erreur! quelque chose n\'a pas bien fonctionnée!</div>';
       }
     } 
 
@@ -67,7 +67,7 @@ function rdv_changestatus($rdv){
   from events ev 
   left join users usr on (ev.id_user=usr.id) 
   left join users cl on (ev.id_client=cl.id) where ev.clientuuid='".$db->secvalue($rdv["uuid"])."' or ev.useruuid='".$db->secvalue($rdv["uuid"])."'";
-  // $msg .= "SQL 1: $sql<br/>";
+
   $event = $db->dbquery($sql);
   $sql = "";
   $newrdv = 0;
@@ -89,7 +89,7 @@ function rdv_changestatus($rdv){
         $sql = "UPDATE events SET user_status='canceled' where useruuid='".$rdv["uuid"]."'";
       }
     }
-    // $msg .= "SQL 2: $sql<br/>";
+
     if ($sql != ""){
       $res = $db->dbexec($sql);
       if ($res !== false){
index f46944d..d9db952 100644 (file)
@@ -74,18 +74,29 @@ function process_postdata($pdt){
     }
 
 function process_getdata($gdt){
-        global $baseurl,$p,$db,$user;
+        global $baseurl,$p,$db,$user,$sp;
         // print_r($gdt);
         if ($user != null){
           if (isset($gdt["action"])){
             switch ($gdt['action']){
                 case 'logout':
-                    $db->dbexec("delete from usersession where sessionid='".$user["sessionid"]."';");
+                    $db->dbexec("delete from usersession where sessionid='".$user["sessionid"]."' and id_user=".$user["id"].";");
                     $user=array();
                     setcookie("juridig","");
                     $p='home';
                     break;
-                
+                case 'deleterdv':
+                    $db->dbexec("delete from events where id='".$gdt["id"]."' and id_user='".$user["id"]."';");
+                    break;
+                case 'deletetimesheet':
+                    $db->dbexec("delete from timesheets where id='".$gdt["id"]."' and id_user='".$user["id"]."';");
+                    break;
+                case 'block':
+                    $db->dbexec("insert into userclients (id_client,id_user,clientblocked) VALUES ('".$gdt["clientid"]."','".$user["id"]."','1')");
+                    break;
+                case 'unblock':
+                    $db->dbexec("delete from userclients  WHERE id_client='".$gdt["clientid"]."' and id_user='".$user["id"]."'");
+                    break;
                 
             }
           }
diff --git a/phpinfo.php b/phpinfo.php
deleted file mode 100644 (file)
index c9f5eeb..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<?php phpinfo(); ?>
\ No newline at end of file
diff --git a/site.js b/site.js
index ab3862d..a7ddfc2 100644 (file)
--- a/site.js
+++ b/site.js
@@ -23,31 +23,21 @@ $( document ).ready(function() {
 
 
 function handleFileSelect(evt) {
-  var files = evt.target.files; // FileList object
+  var files = evt.target.files;
   var utype = "";
   if ($("form").attr('id') == "dksrdv_catalog"){
     $("form").prepend('<input type="hidden"  id="photo" name="photo" value=""/>');
-
-  // Loop through the FileList and render image files as thumbnails.
   for (var i = 0, f; f = files[i]; i++) {
-
-    // Only process image files.
     if (!f.type.match('image.*')) {
       continue;
     }
-    
       var reader = new FileReader();
-
-    // Closure to capture the file information.
     reader.onload = (function(theFile) {
       return function(e) {
         $("#preview").attr("src",e.target.result);
         $("#"+utype+"photo").val(e.target.result);
-        //console.log($("#userphoto"));
       };
     })(f);
-
-    // Read in the image file as a data URL.
     reader.readAsDataURL(f);
   }
 }
@@ -60,8 +50,6 @@ function removephoto(utype){
   }
 }
 
-
-
 function initstandard(){
   var forms = document.querySelectorAll('form.dks');
   if (forms.length > 0){
@@ -75,7 +63,6 @@ function initstandard(){
 
   tinymce.init({
     selector: '.richeditarea',
-    //height: 300,
     branding: false,
     menubar:false,
     statusbar: false,
@@ -88,7 +75,6 @@ function initstandard(){
 
 function  imsg(data){
   var tmp = h1(data);
-  console.log(tmp);
   window.location.href=tmp;
 }
 
index 4405eef..223e6ae 100644 (file)
@@ -6,7 +6,7 @@
     left join `catalog` cat on (usr.id=cat.id_user)
     where usr.usergroup in ('avocat')  and usr.userblocked is null and usr.activationkey is null group by usr.id order by cat.company,cat.surname,cat.prename;";
   $avocats = $db->dbqueryall($sql);
-  // echo "$sql";
+
   ?>
   
   <div class="row justify-content-center">
index d5d840d..43a6671 100644 (file)
@@ -8,4 +8,4 @@
 <script src="<?php echo $baseurl; ?>/vendor/bootstrap4-tagsinput/tagsinput.js"></script> 
 <script src="<?php echo $baseurl; ?>/vendor/twbs-toggle-buttons/jquery.twbs-toggle-buttons.min.js"></script> 
 <script src="<?php echo $baseurl; ?>/vendor/tinymce/js/tinymce/tinymce.min.js"></script> 
-<script src="<?php echo $baseurl; ?>/site.js?v=4"></script>
\ No newline at end of file
+<script src="<?php echo $baseurl; ?>/site.js?v=5"></script>
\ No newline at end of file
index 72c914f..feabcb4 100644 (file)
@@ -2,7 +2,7 @@
     $sql = "select cl.id as id_client,ev.id_user,cl.usersurname,cl.userprename,cl.userphone,cl.useremail,case when uc.clientblocked=1 then 1 else 0 end as clientblocked,cl.userblocked as globalblocked from events ev 
     left join users cl on (cl.id=ev.id_client)
     left join userclients uc on (uc.id_client=cl.id and uc.id_user=".$user['id'].") group by cl.id;";
-    //echo $sql;
+
     $tablelist = $db->dbqueryall($sql);
 ?>
 
@@ -29,9 +29,9 @@
                     if ($row["globalblocked"] == "1"){
                       echo '<span class="text-danger">blocké par juridig.lu</span>';
                     } else if ($row["clientblocked"] == "1"){
-                      echo '<button class="btn btn-danger" onclick="location.href='.$baseurl.'/profile/rendezvous/clientlist?action=unblock&clientid='.$row['id_client'].';"><i class="fas fa-lock"></i></button>';
+                      echo '<button class="btn btn-danger" onclick="location.href=\''.$baseurl.'/profile/rendezvous/clientlist?action=unblock&clientid='.$row['id_client'].'\';"><i class="fas fa-lock"></i></button>';
                     } else {
-                      echo '<button class="btn btn-success" onclick="location.href='.$baseurl.'/profile/rendezvous/clientlist?action=block&clientid='.$row['id_client'].';"><i class="fas fa-lock-open"></i></button>';
+                      echo '<button class="btn btn-success" onclick="location.href=\''.$baseurl.'/profile/rendezvous/clientlist?action=block&clientid='.$row['id_client'].'\';"><i class="fas fa-lock-open"></i></button>';
                     }
                   ?>
                 
@@ -42,4 +42,8 @@
             ?>
             <tr></tr>
         </tbody>
-</table>
\ No newline at end of file
+</table>
+<script>
+function initdata(){
+}
+</script>
\ No newline at end of file
index fcc6bcf..6a152df 100644 (file)
@@ -64,7 +64,7 @@ $tablelist = $db->dbqueryall($sql);
                       echo '<span class="text-warning">INCONNUE</span>';
                     }; ?></td>
                 <?php } ?>
-                <td><button class="btn btn-danger" onclick="location.href='<?php echo $baseurl.'/rendezvouslistold?action=deletetimesheet&id='.$row['id']; ?>';"><i class="fas fa-trash"></i></button></td>
+                <td><button class="btn btn-danger" onclick="location.href='<?php echo $baseurl.'/profile/rendezvous/rendezvouslistold?action=deleterdv&id='.$row['id']; ?>';"><i class="fas fa-trash"></i></button></td>
         </tr>
         <?php    
                 }
index d41104a..2dd220a 100644 (file)
@@ -1,8 +1,3 @@
-<?php
-    
-    
-?>
-
 <form id="dksrdv_exception" id="dksrdv_exception" class="needs-validation" novalidate>
     <input type="hidden" id="id_user" name="id_user" value="<?php echo $user['id']; ?>" />
   <div class="row">
           </div>
 </form>
 <script type="text/javascript">
+
 var wds={"mon":null,"tue":null,"wed": null,"thu":null, "fri": null, "sat": null, "sun": null};
-function initdata(){
-  moment.locale('fr');
-  $('.datepicker').datepicker({
-    language: 'fr',
-    format: {
-      toDisplay: function(date) {
-        var d = moment(date); // In my case, week begin on Sat. +1 day to make sure Sat moved to next week (Default start from Sun)
+
+function getweek(date){
+  var d = moment(date); 
         wds.mon = moment(date).startOf('week').add(1,'d');
         $("#datemon").html(wds.mon.format("D. MMM"));
         wds.tue = moment(date).startOf('week').add(2,'d');
@@ -85,8 +77,16 @@ function initdata(){
         $("#datesat").html(wds.sat.format("D. MMM"));
         wds.sun = moment(date).startOf('week').add(7, 'd'); 
         $("#datesun").html(wds.sun.format("D. MMM"));
-        console.log(wds);
         return d.format("[CW]WW")+ " - ( " + wds.mon.format("DD/MM/YYYY") + " - " + wds.sun.format("DD/MM/YYYY") + " )";
+}
+
+function initdata(){
+  moment.locale('fr');
+  $('.datepicker').datepicker({
+    language: 'fr',
+    format: {
+      toDisplay: function(date) {
+        return getweek(date); 
       },
       toValue: function(date) {
         var year = Number(date.split("-W")[0]);
@@ -95,10 +95,10 @@ function initdata(){
         return d.toDate();
       }
     },
-    container: '#weekpicker', // Inject to placeholder to apply css
+    container: '#weekpicker', 
     autoclose: true,
     calendarWeeks: true,
-    weekStart: 1 // Week starts on Sat
+    weekStart: 1 
   });
   $('.datepicker').on('show', function() {
     $('#weekpicker').find('.datepicker table tr').each(function() {
@@ -118,6 +118,8 @@ function initdata(){
       }
     });
   });
+  $("#calendarweek").val(getweek(new Date()));
+  getdaytimesheets();
 }
   
 function getdaytimesheets() {
@@ -127,7 +129,7 @@ function getdaytimesheets() {
                  encoding:"UTF-8",
                  url:'<?php echo $baseurl; ?>/api.php?action=timesheetday&day='+wds[d].format('YYYY-MM-DD')+'&id_user='+ $("#id_user").val(),
                  success: function (data){
-        console.log(data);
+      
         if (data.daydata){
            var dd = data.daydata.split(',');
            for (var i in dd){
@@ -148,7 +150,7 @@ function getdaytimesheets() {
 }
 
 function setstatus(objid){
-  console.log("id for status:" + objid + $("#" + objid).hasClass("btn"));
+
   status=null;
   if ($("#" + objid).hasClass("btn-success")){
     status="set";
@@ -159,13 +161,11 @@ function setstatus(objid){
     $("#" + objid).removeClass("btn-danger");
     $("#" + objid).addClass("btn-success");
   }
-  console.log('/api.php?action=setexception&type='+ status+'&day='+$("#" + objid).attr("data-date")+'&value='+$("#" + objid).html()+'&id_user='+ $("#id_user").val());
-  $.ajax({
+ $.ajax({
                  encoding:"UTF-8",
                  url:'<?php echo $baseurl; ?>/api.php?action=setexception&type='+ status+'&day='+$("#" + objid).attr("data-date")+'&value='+$("#" + objid).html()+'&id_user='+ $("#id_user").val(),
                  success: function (data){
-        console.log(data);
-        
+      
       },
                  error: function(data){
 
index 82e25c3..1fabbc1 100644 (file)
@@ -3,7 +3,7 @@
  replace(replace(replace(replace(replace(replace(replace(ts.weekdays,'1','Lu'),'2','Ma'),'3','Me'),'4','Je'),'5','Ve'),'6','Sa'),'0','Di') as weekdays, 
  CONCAT(COALESCE(option1_name,''),',',COALESCE(option2_name,''),COALESCE(option3_name,''),COALESCE(option4_name,'')) as options
  FROM timesheets ts where ts.id_user=".$user['id'].";";
- //echo "$sql";
+
  $tablelist = $db->dbqueryall($sql);
 ?>
 <h5>Mes Horaires</h5>
                 <td><?php echo $row['options']; ?></td>
                 <td>
                     <button class="btn btn-info" onclick="location.href='<?php echo $baseurl; ?>/profile/rendezvous/timesheet?id=<?php echo $row['id']; ?>';"><i class="fas fa-edit"></i></button>
-                    <button class="btn btn-danger" onclick="location.href='<?php echo $baseurl; ?>/profile/rendezvous/timesheetlist?action=deletetimesheet&id=<?php echo $row['id']; ?>"><i class="fas fa-trash"></i></button>
+                    <button class="btn btn-danger" onclick="location.href='<?php echo $baseurl; ?>/profile/rendezvous/timesheetlist?action=deletetimesheet&id=<?php echo $row['id']; ?>';"><i class="fas fa-trash"></i></button>
                 </td>
             </tr>
             <?php    
                 }
             ?>
         </tbody>
-</table>
\ No newline at end of file
+</table>
+<script>
+function initdata(){
+}
+</script>
\ No newline at end of file
index a1524d2..ffe80b2 100644 (file)
@@ -5,7 +5,7 @@ $selid = null;
 if (isset($_GET["id"]) && ($_GET['id'] != "")){
 $selid = $_GET['id'];
 $sql = "SELECT usr.id,usr.userprename,usr.usersurname from users usr left join userservices srv on (usr.id=srv.id_user) where srv.service='rendezvous' and srv.expiration >= CURRENT_DATE and usr.id='".$_GET["id"]."';";
-// echo $sql;
+
 $avosel = $db->dbquery($sql);
 }
 ?>
index e9f4245..f5403f1 100644 (file)
@@ -39,7 +39,7 @@
           <div class="row justify-content-center">
             <div class="col-md-4">
               <div class="card" style="">
-                <div class="card-header"><h6>Votre Rendez-Vous</h6></div>
+                <div class="card-header"><h5>Votre Rendez-Vous</h5></div>
                 <div class="card-body">
                   <table>
                   <tr><th>Votre Nom</th><td><?php echo $event["clientname"];?></td></tr>
@@ -96,7 +96,7 @@
               ?>
               
               <div class="card" style="">
-                <div class="card-header"><h6>Votre Rendez-Vous</h6></div>
+                <div class="card-header"><h5>Votre Rendez-Vous</h5></div>
                 <div class="card-body">
                   <table>
                   <tr><th  style="width: 150px;">Votre Nom</th><td><?php echo $event["username"];?></td></tr>
                       echo '<span class="text-warning">INCONNUE</span>';
                     }; ?></td></tr>
                     <?php
-                    if (($user) && ($user["usergroup"] == 'avocat'){
+                    if (($user) && ($user["usergroup"] == 'avocat')){
                       ?>
                       <tr><th>Tél. Client</th><td><a href="tel:<?php echo $event["clientphone"];?>"><?php echo $event["clientphone"];?></a></td></tr>
                       <tr><th>E-mail Client</th><td><a href="mailto:<?php echo $event["clientemail"];?>"><?php echo $event["clientemail"];?></a></td></tr>