From: Kilian Saffran Date: Tue, 19 Mar 2019 11:11:58 +0000 (+0100) Subject: rendezvous bugfixes X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=87a948d6720072b38bdcedc199504fdaacca1d66;p=juridig.git rendezvous bugfixes --- diff --git a/api.php b/api.php index ef3fdfd..83691a3 100644 --- a/api.php +++ b/api.php @@ -10,15 +10,44 @@ $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 as exception from exceptions where daydate=date('".$_GET['day']."') and id_user=".$iduser.";"; + $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 { $daydata["hour_values"] = null; } - + if ($daydata["hour_values"] != null){ + $dhnew = array(); + if ($exception != null){ + $exp = explode(',',$exception["dayhours"]); + foreach ($daydata["hour_values"] as $val){ + if (!in_array($val,$exp)){ + array_push($dhnew,$val); + } + } + $daydata["hour_values"] = $dhnew; + } + } + //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){ + $tev = explode(',',$takenevents["eventhour"]); + foreach ($daydata["hour_values"] as $val){ + if (!in_array($val,$tev)){ + array_push($dhnew,$val); + } + } + $daydata["hour_values"] = $dhnew; + } + } if (isset($daydata["option1_values"]) && $daydata["option1_values"] != ""){ $daydata["option1_values"] = explode(',',$daydata["option1_values"]); } diff --git a/lib/process_email.php b/lib/process_email.php index 8ca340c..cf7dcac 100644 --- a/lib/process_email.php +++ b/lib/process_email.php @@ -14,9 +14,6 @@ } $maildata = $db->dbquery($datasql); - - error_log($datasql."\n"); - error_log($maildata."\n"); $body = $tmpl['emailtext']; $subject = $tmpl['mailsubject']; foreach ($data as $key => $value){ @@ -62,7 +59,9 @@ //$retdata =shell_exec($cmd); system($cmd,$status); - + if ($status==0){ + error_log("Mail sended to ".$data["email"].' with template:'.$template); + } return $status; } diff --git a/lib/process_rdv.php b/lib/process_rdv.php index e0a0bd3..7c6f8b7 100644 --- a/lib/process_rdv.php +++ b/lib/process_rdv.php @@ -63,10 +63,11 @@ function rdv_changestatus($rdv){ $sql = "select DATE_FORMAT(ev.eventdate,'%d/%m/%Y') as eventdate,ev.eventoptions,ev.eventhour,ev.user_status,ev.client_status,ev.eventuuid, CONCAT(usr.userprename,' ',usr.usersurname) as username, CONCAT(cl.userprename,' ',cl.usersurname) as clientname, - ev.clientuuid,ev.useruuid,cl.userphone as clientphone,cl.useremail as clientemail,usr.useremail, + ev.clientuuid,ev.useruuid,cl.userphone as clientphone,cl.useremail as clientemail,usr.useremail 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
"; $event = $db->dbquery($sql); $sql = ""; $newrdv = 0; @@ -88,6 +89,7 @@ function rdv_changestatus($rdv){ $sql = "UPDATE events SET user_status='canceled' where useruuid='".$rdv["uuid"]."'"; } } + // $msg .= "SQL 2: $sql
"; if ($sql != ""){ $res = $db->dbexec($sql); if ($res !== false){ @@ -97,15 +99,41 @@ function rdv_changestatus($rdv){ if ($newrdv == 1){ $mailtmpl = 'user_rendezvous'; } - $send = sendemail('user_rendezvous_status_change',$mdata); + $send = sendemail($mailtmpl,$mdata); } else if ($rdv["uuid"] == $event["useruuid"]){ $mdata= array("email" => $event["clientemail"], "eventuuid" => $event["eventuuid"], "siteurl" => $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["HTTP_HOST"].$baseurl); $send = sendemail('client_rendezvous_status_change',$mdata); } } else { - $msg = = '
Erreur! quelque chose n\'a pas bien fonctionnée!
'; + $msg = '
Erreur! quelque chose n\'a pas bien fonctionnée!
'; } } } } + +function resendevent($rdv){ + global $db,$msg,$baseurl; + $sql = "select DATE_FORMAT(ev.eventdate,'%d/%m/%Y') as eventdate,ev.eventoptions,ev.eventhour,ev.user_status,ev.client_status,ev.eventuuid, + CONCAT(usr.userprename,' ',usr.usersurname) as username, + CONCAT(cl.userprename,' ',cl.usersurname) as clientname, + ev.clientuuid,ev.useruuid,cl.userphone as clientphone,cl.useremail as clientemail,usr.useremail + 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"])."'"; + $event = $db->dbquery($sql); + if (($event != null) && ($event["clientemail"] == $rdv["useremail"])){ + $mdata= array("email" => $rdv["useremail"], "eventuuid" => $event["eventuuid"], "siteurl" => $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["HTTP_HOST"].$baseurl); + $send = sendemail('client_rendezvous_confirmation',$mdata); + if ($send == 0){ + $msg = '
Votre demande à été enregistrée!
+ Nous vous avons envoyés un email avec un lien de confirmation.
Après confirmation votre demande sera tranférée au avocat! +
'; + } else { + $msg = '
Erreur! quelque chose n\'a pas bien fonctionnée!
'; + } + } else { + $msg = '
l\'addresse e-mail n\'est pas correcte où cette demande de rendez-vous n\'existe pas!
'; + } + +} ?> \ No newline at end of file diff --git a/lib/processdata.php b/lib/processdata.php index ca387d6..f46944d 100644 --- a/lib/processdata.php +++ b/lib/processdata.php @@ -66,6 +66,7 @@ function process_postdata($pdt){ activate_user($pdt["useremail"],$pdt["activationkey"]); break; case 'submit_resendevent': + resend_rdv($pdt); break; } } @@ -95,8 +96,8 @@ function process_getdata($gdt){ break; } } - if (isset($gdt("uuid")) && isset($gdt("setstatus"))){ - rdv_changestatus(); + if (isset($gdt["uuid"]) && isset($gdt["setstatus"])){ + rdv_changestatus($gdt); } if (isset($gdt["enable"])){ enable_app($gdt); diff --git a/tmpl/pages/profile/checkout.php b/tmpl/pages/profile/checkout.php index 4b206f2..3886274 100644 --- a/tmpl/pages/profile/checkout.php +++ b/tmpl/pages/profile/checkout.php @@ -3,7 +3,7 @@ $sql = "select *,(select LPAD(count(*) + 1,4,0) from invoicedata where id_user=".$user["id"].") as invoicenum from invoicedata where id_user=".$user["id"]." order by invoicedate desc LIMIT 1;"; $lastinv = $db->dbquery($sql); if (!$lastinv){ - $sql = "SELECT CONCAT(COALESCE(userprename,''),' ',COALESCE(usersurname,'')) as recipient, useremail as email, useraddress as address, userzip as zip, usercity as city, '0001' as invoicenum, CONCAT('JD',YEAR(CURDATE()),LPAD(".$user["id"].",4,0)) as clientnumber FROM users where id=".$user["id"]; + $sql = "SELECT CONCAT(COALESCE(usr.userprename,''),' ',COALESCE(usr.usersurname,'')) as recipient, usr.useremail as email, cat.address, cat.zip as zip, cat.city as city, '0001' as invoicenum, CONCAT('JD',YEAR(CURDATE()),LPAD(".$user["id"].",4,0)) as clientnumber FROM users usr left join catalog cat on (usr.id=cat.id_user) where usr.id=".$user["id"]; $lastinv = $db->dbquery($sql); } $sql = "select apps.id,apr.id,apps.name,apr.monthlyprice, apps.evaluationdays,apr.minmonth,apr.package diff --git a/tmpl/pages/rendezvous.php b/tmpl/pages/rendezvous.php index e016924..a1524d2 100644 --- a/tmpl/pages/rendezvous.php +++ b/tmpl/pages/rendezvous.php @@ -98,12 +98,12 @@ var rdvdata = {"id_user":"", "useremail":null, "userphone":null }; - +var tomorrow = new Date(); +tomorrow.setDate(tomorrow.getDate() + 1); function initdata(){ moment.locale('fr'); - //console.log("INIT RDV DATA!"); moment.locale('fr'); getuserdata(); $('.datepicker').datepicker({ @@ -121,12 +121,11 @@ function initdata(){ return d.format("DD/MM/YYYY"); } }, - startDate: new Date(), - //container: '#weekpicker', // Inject to placeholder to apply css + startDate: tomorrow, autoclose: true, - todayHighlight: true, - //calendarWeeks: true, - weekStart: 1 // Week starts on Sat + // todayHighlight: true, + calendarWeeks: true, + weekStart: 1 }); $('.datepicker').on('show', function() { $('.datepicker table tr').each(function() { @@ -146,43 +145,24 @@ function initdata(){ } }); }); - //getdaydata(); - // $('.datepicker').on('changeDate', function() { - // rdvdata.eventstartdate = $('#rendezvousdatepicker').datepicker('getFormattedDate'); - // console.log("change daydata!"); - // getdaydata(); - // }); } function getuserdata(){ - console.log("Get User Data!"); $("#tr_id_user > td").html($("#avoname").val()); rdvdata.id_user = $("#id_user").val(); getdaydata(rdvdata.eventstartdate); } -// function(){ - -// } - function getdaydata(daydate){ - console.log("LOAD Day: " + daydate); - //console.log('/api.php?action=rdvday&day='+ daydate+'&id='+ rdvdata.id_user); $.ajax({ encoding:"UTF-8", url:'/api.php?action=rdvday&day='+ daydate+'&id='+ rdvdata.id_user, success: function (data){ - console.log(data); - //$("#tr_id_user > td").html($("#id_user :selected").text()); - // $("#tr_eventstartdate > td").html(rdvdata.eventstartdate); - // $("#rendezvousdatepicker").val(rdvdata.eventstartdate); $("#tr_options > td").html(""); $("#tr_eventhour> td").html(""); - //$('.datepicker').html(""); $("#options").html(""); - // $('#rendezvousdatepicker').datepicker('destroy'); $('#rdo_hour_values').html(""); if (!data.hour_values){ $("#submit_rendezvous").attr("disabled", true); @@ -192,7 +172,6 @@ function getdaydata(daydate){ for (var i in data.hour_values){ $('#rdo_hour_values').append('
'); - // $('#rdo_hour_values').append(' '+ data.hour_values[i] +''); } if (data.option1_name){ var opt1v = ""; diff --git a/tmpl/pages/rendezvousevent.php b/tmpl/pages/rendezvousevent.php index 217ad4f..c201769 100644 --- a/tmpl/pages/rendezvousevent.php +++ b/tmpl/pages/rendezvousevent.php @@ -5,7 +5,7 @@ $sql = "select DATE_FORMAT(ev.eventdate,'%d/%m/%Y') as eventdate,ev.eventoptions,ev.eventhour,ev.user_status,ev.client_status, CONCAT(usr.userprename,' ',usr.usersurname) as username, CONCAT(cl.userprename,' ',cl.usersurname) as clientname, - ev.clientuuid,ev.useruuid,cl.userphone as clientphone,cl.useremail as clientemail + ev.clientuuid,ev.useruuid,cl.userphone as clientphone,cl.useremail as clientemail,usr.useremail 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($_GET["uuid"])."' or ev.useruuid='".$db->secvalue($_GET["uuid"])."'"; @@ -15,13 +15,13 @@ if ($_GET["uuid"] == $event["clientuuid"]){ if ($event["client_status"] == 'unconfirmed'){ ?> - echo '
+

Merci pour votre demande de rendez-vous,
Nous vous avons envoyé un email avec un liens pout confirmer votre demande de rendezvous!
-

- "/> + + "/>
@@ -90,7 +90,7 @@
'; } ?> @@ -147,12 +147,11 @@
Le Rendez-Vous demnadé est introuvable dans le système!
'; } - +} ?>