From 03144c9430125e9c81a0b484e5f5d33ccb5e8944 Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Mon, 25 Feb 2019 12:10:05 +0100 Subject: [PATCH] rendezvous events without mailing --- api.php | 50 +++--- index.php | 2 +- lib/processdata.php | 114 ++++++++++++- site.js | 12 +- style.css | 18 +- tmpl/pages/avocats.php | 79 +++++---- tmpl/pages/profile/applications.php | 30 +++- tmpl/pages/profile/profile.php | 13 +- tmpl/pages/profile/rendezvous/clientlist.php | 18 +- .../profile/rendezvous/rendezvouslist.php | 54 +++++- .../profile/rendezvous/rendezvouslistold.php | 77 +++++++++ .../profile/rendezvous/timesheetcalendar.php | 2 +- tmpl/pages/rendezvous.php | 136 ++++++++++----- tmpl/pages/rendezvousevent.php | 161 ++++++++++++++++++ 14 files changed, 627 insertions(+), 139 deletions(-) create mode 100644 tmpl/pages/profile/rendezvous/rendezvouslistold.php create mode 100644 tmpl/pages/rendezvousevent.php diff --git a/api.php b/api.php index 760ae60..ef3fdfd 100644 --- a/api.php +++ b/api.php @@ -6,28 +6,32 @@ header('Content-Type: application/json'); if (isset($_GET)){ if (isset($_GET["action"]) && $_GET["action"] == "rdvday"){ - $sql = "select hour_values,weekdays,option1_name,option1_values,option2_name,option2_values,option3_name,option3_values,option4_name,option4_values from timesheets where id_user=".$_GET["id"]." and startdate <= CURRENT_DATE order by startdate DESC LIMIT 1; - "; - $timesheet = $db->dbquery($sql); - $allweek = array('1','2','3','4','5','6','0'); - $wdays = explode(',',$timesheet["weekdays"]); - $timesheet["hour_values"] = explode(',',$timesheet["hour_values"]); - $timesheet["weekdays"] = array_values(array_diff($allweek,$wdays)); - if ($timesheet["option1_values"] ){ - $timesheet["option1_values"] = explode(',',$timesheet["option1_values"]); - } - if ($timesheet["option2_values"] ){ - $timesheet["option2_values"] = explode(',',$timesheet["option2_values"]); - } - if ($timesheet["option3_values"] ){ - $timesheet["option3_values"] = explode(',',$timesheet["option3_values"]); - } - if ($timesheet["option4_values"] ){ - $timesheet["option4_values"] = explode(',',$timesheet["option4_values"]); - } - $timesheet["startdate"] = date('%Y-%m-%d'); - $timesheet["enddate"] = date('%Y-%m-%d',strtotime("+6 months")); - echo json_encode($timesheet); + $iduser = $db->secvalue($_GET["id"]); + $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;"; + $daydata = $db->dbquery($sql); + $sql ="select dayhours as exception from exceptions where daydate=date('".$_GET['day']."') and id_user=".$iduser.";"; + $exception = $db->dbquery($sql); + if ($daydata["hour_values"] != ""){ + $daydata["hour_values"] = explode(',',$daydata["hour_values"]); + } else { + $daydata["hour_values"] = null; + } + + if (isset($daydata["option1_values"]) && $daydata["option1_values"] != ""){ + $daydata["option1_values"] = explode(',',$daydata["option1_values"]); + } + if (isset($daydata["option2_values"]) && $daydata["option2_values"] != "" ){ + $daydata["option2_values"] = explode(',',$daydata["option2_values"]); + } + if (isset($daydata["option3_values"]) && $daydata["option3_values"] != "" ){ + $daydata["option3_values"] = explode(',',$daydata["option3_values"]); + } + if (isset($daydata["option4_values"]) && $daydata["option4_values"] != "" ){ + $daydata["option4_values"] = explode(',',$daydata["option4_values"]); + } + echo json_encode($daydata); } else if (isset($_GET["action"]) && ($_GET["action"] == "timesheetday") && isset($_GET["day"]) && isset($_GET["id_user"])){ if (preg_match('/^\d\d\d\d-\d\d-\d\d$/',$_GET['day']) == 1) { @@ -83,7 +87,7 @@ $db->dbexec($updsql); } } - echo json_encode (array)); + echo json_encode (array()); } else { echo json_encode (array()); diff --git a/index.php b/index.php index b54ab5a..d955a33 100644 --- a/index.php +++ b/index.php @@ -32,7 +32,7 @@ } // process actions - if (isset($_GET["action"])){ + if (isset($_GET)){ process_getdata($_GET); } diff --git a/lib/processdata.php b/lib/processdata.php index 8860137..2bd1123 100644 --- a/lib/processdata.php +++ b/lib/processdata.php @@ -2,7 +2,7 @@ function process_postdata($pdt){ global $user; $submittype=""; - //print_r($pdt); + print_r($pdt); foreach ( $pdt as $k => $value){ //echo "$k
"; if (substr($k, 0, 7) === 'submit_' ){ @@ -18,6 +18,9 @@ case 'submit_exception': save_data('exceptions',$pdt); break; + case 'submit_rendezvous': + save_rendezvous($pdt); + break; case 'submit_profile': save_data('users',$pdt); break; @@ -33,10 +36,9 @@ switch ($submittype){ case 'submit_login': $user = checklogin($pdt["username"],$pdt["password"]); - break; case 'submit_rendezvous': - save_data('events',$pdt); + save_rendezvous($pdt); break; case 'submit_register': register_user($pdt); @@ -47,6 +49,8 @@ case 'submit_activation': activate_user($pdt["useremail"],$pdt["activationkey"]); break; + case 'submit_resendevent': + break; } } return; @@ -54,7 +58,9 @@ function process_getdata($gdt){ global $baseurl,$p,$db,$user; - if (isset($gdt["action"])){ + // print_r($gdt); + if ($user != null){ + if (isset($gdt["action"])){ switch ($gdt['action']){ case 'logout': $db->dbexec("delete from usersession where sessionid='".$user["sessionid"]."';"); @@ -67,8 +73,8 @@ case 'delete': break; } - } - if (isset($gdt["activate"])){ + } + if (isset($gdt["activate"])){ switch ($gdt['activate']){ case 'rendezvous': $expiredate = date('Y-m-d',strtotime('+21 days')); @@ -79,10 +85,82 @@ 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; + } + } + } } + function save_rendezvous($rdv){ + global $db,$msg; + + $sqlsenderuser = "select id,userblocked from users where useremail='".$db->secvalue($rdv["useremail"])."';"; + $clientuser = $db->dbquery($sqlsenderuser); + if (!isset($clientuser)){ + //save new client user + $usersql = "INSERT INTO users (usersurname, userprename, useremail, usergroup,userphone) VALUES ('".$rdv["usersurname"]."','".$rdv["userprename"]."','".$rdv["useremail"]."','client','".$rdv["userphone"]."');"; + $db->dbexec($sql2); + $usersql = "select id,userblocked as email from users where useremail='".$rdv["useremail"]."';"; + $clientuser = $db->dbquery($usersql); + } + + if ($clientuser["userblocked"] == "1"){ + $msg = '
L\'utilisateur avec l\'email '.$rdv["useremail"].' a été blocké par le système!
'; + return; + }else { + if (preg_match('/^\d\d.\d\d.\d\d\d\d$/',$rdv["rendezvousdatepicker"]) == 1){ + $rdv["eventdate"] = str_replace('/', '-', $rdv["rendezvousdatepicker"]); + $rdv["eventdate"] = date('Y-m-d', strtotime($val)); + } + $options=""; + if (isset($rdv["option1"]) || isset($rdv["option2"]) || isset($rdv["option3"]) || isset($rdv["option4"])){ + $sqlopt = "select option1_name,option2_name,option3_name,option4_name from timesheets where startdate <= date('".$rdv["eventdate"]."') order by startdate desc LIMIT 1"; + $optionnames = $db->dbquery($sqlopt); + if (isset($rdv["option1"]) && $rdv["option1"] != ""){ + $options .= $optionnames["option1_name"].': '.$rdv["option1"]."
"; + } + if (isset($rdv["option2"]) && $rdv["option2"] != ""){ + $options .= $optionnames["option2_name"].': '.$rdv["option2"]."
"; + } + if (isset($rdv["option3"]) && $rdv["option3"] != ""){ + $options .= $optionnames["option3_name"].': '.$rdv["option3"]."
"; + } + if (isset($rdv["option4"]) && $rdv["option4"] != ""){ + $options .= $optionnames["option4_name"].': '.$rdv["option4"]."
"; + } + } + $to_user = $db->dbquery("select prename,surname from users where id=".$db->secvalue($rdv["id_user"])); + $rdvuuid = gen_uuid(); + $sqlevent = "INSERT INTO events (id_user, id_client, eventdate, eventoptions, eventuuid, eventhour, user_status, client_status) + VALUES(".$db->secvalue($rdv["id_user"]).", ".$db->secvalue($clientuser["id"]).", date('".$db->secvalue($rdv["eventdate"])."'), ".(($options != "")?"'".$options."'":'null').", '".$rdvuuid."', '".$db->secvalue($rdv["eventhour"])."', 'unconfirmed', 'unconfirmed');"; + $db->dbexec($sqlevent); + $mdata= array("email" => $rdv["useremail"],"prename" => $rdv["userprename"],"surname" =>$rdv["userprename"], "eventdate" => $rdv["rendezvousdatepicker"], "eventhour" => $rdv["eventhour"], "event_ident" => $rdvuuid, "event_options" => $options); + $send = 0;// sendemail('client_rendezvous_confirmation',$mdata); + if ($send == 0){ + $msg= '
Votre demande à été enregistrer!
+ Nous vous avons envoyé un email avec un lien de confirmation.
Après confirmation votre demande sera tranféré au avocat! +
'; + } else { + $msg= '
Erreur! quelque chose n\'a pas bien fonctionnée!
'; + } + } + + } + function register_user($pdt){ global $db,$msg,$p; //do we have already an account for this user? @@ -227,6 +305,28 @@ return $password; } + function gen_uuid() { + return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + // 32 bits for "time_low" + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), + + // 16 bits for "time_mid" + mt_rand( 0, 0xffff ), + + // 16 bits for "time_hi_and_version", + // four most significant bits holds version number 4 + mt_rand( 0, 0x0fff ) | 0x4000, + + // 16 bits, 8 bits for "clk_seq_hi_res", + // 8 bits for "clk_seq_low", + // two most significant bits holds zero and one for variant DCE1.1 + mt_rand( 0, 0x3fff ) | 0x8000, + + // 48 bits for "node" + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) + ); + } + function save_data($dbtable,$data){ global $db,$msg; diff --git a/site.js b/site.js index 974d33a..f0ec513 100644 --- a/site.js +++ b/site.js @@ -84,12 +84,12 @@ function initstandard(){ todayHighlight: true, daysOfWeekDisabled: [0,6] }); - $('.datepicker').on('changeDate', function() { - //console.log($('#rendezvousdatepicker').datepicker('getFormattedDate')); - $('#dateselected').val( - $('#rendezvousdatepicker').datepicker('getFormattedDate') - ); - }); + // $('.datepicker').on('changeDate', function() { + // //console.log($('#rendezvousdatepicker').datepicker('getFormattedDate')); + // $('#dateselected').val( + // $('#rendezvousdatepicker').datepicker('getFormattedDate') + // ); + // }); //$(".btn-group-toggle").twbsToggleButtons(); //console.log("init now tinymce!"); tinymce.init({ diff --git a/style.css b/style.css index 12c66f5..23c8dbf 100644 --- a/style.css +++ b/style.css @@ -1,5 +1,9 @@ html,body { - background: #343a40 !important; + background: #000 !important; +} + +.bg-dark { + background-color: #000!important; } main { @@ -11,7 +15,7 @@ main { } .sidebar { - background: #343a40 !important; + background: #000 !important; /* min-height: 80vh; */ } @@ -56,4 +60,14 @@ header.masterhead > h1 { #weekpicker .datepicker table tr:hover td.day { background: #8A8A8F; color: #fff; +} + +#rdo_hour_values .btn-outline-secondary { + color: #000; + +} + +#rdo_hour_values .btn-outline-secondary:not(:disabled):not(.disabled).active, #rdo_hour_values .btn-outline-secondary:not(:disabled):not(.disabled):active, #rdo_hour_values .show>.btn-outline-secondary.dropdown-toggle { + background-color: #28a745!important; + border: 1px solid #28a745!important; } \ No newline at end of file diff --git a/tmpl/pages/avocats.php b/tmpl/pages/avocats.php index 88d3727..b51a14f 100644 --- a/tmpl/pages/avocats.php +++ b/tmpl/pages/avocats.php @@ -1,5 +1,5 @@ = 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') group by usr.id;"; $avocats = $db->dbqueryall($sql); if ($avocats){ ?> @@ -8,62 +8,83 @@
-
+
-
'.$avo['usersurname'].' '.$avo['userprename'].' '.(($avo['usercompany'] != "")?'('.$avo['usercompany'].')':'').'
-
-
-
- picture -
-
-

Addresse

- '.(($avo['useraddress'] != "")?$avo['useraddress']:'').'
- L-'.(($avo['userzip'] != "")?$avo['userzip']:'').' '.(($avo['usercity'] != "")?$avo['usercity']:'').'
- : '.(($avo['userphone'] != "")?$avo['userphone']:'').'
- : '.(($avo['useremail'] != "")?$avo['useremail']:'').' -
-
-

Heures de consultation

'.(($avo['consultmon'] != "")?''.$avo['consultmon'].'
':'') + echo '
+
+ +
+
'; + echo '
+
'.$avo['usersurname'].' '.$avo['userprename'].' '.(($avo['usercompany'] != "")?'('.$avo['usercompany'].')':''),'
'; + + if ($avo["userphoto"] != ''){ + echo 'picture'; + } + if ($avo["rendezvous_active"] == "1"){ + echo 'prendre rendez-vous'; + } + echo '
'; + if (($avo['useraddress'] != '') || ($avo['userzip'] != '') || ($avo['usercity'] != '') || ($avo['useremail'] != '') || ($avo['userphone'] != '')){ + echo '
Contact
'; + if ($avo['useraddress'] != '') { echo $avo['useraddress'].'
';} + if ($avo['userzip'] != '' || $avo['usercity'] != ''){ + echo '
'.(($avo['userzip'] != "")?$avo['userzip']:'').' '.(($avo['usercity'] != "")?$avo['usercity']:'').'
'; + } + if ($avo['userphone'] != ''){ + echo ''; + } + if ($avo['useremail']){ + echo ': '.$avo['useremail'].''; + } + echo '
'; + } + if ($avo['consultmon'] != '' || $avo['consulttue'] != '' || $avo['consultwed'] != '' || $avo['consultthu'] != '' || $avo['consultfri'] != '' || $avo['consultsat'] != '' || $avo['consultsun'] != ''){ + echo '
+
Heures de consultation
'.(($avo['consultmon'] != "")?''.$avo['consultmon'].'
':'') .(($avo['consulttue'] != "")?''.$avo['consulttue'].'
':'') .(($avo['consultwed'] != "")?''.$avo['consultwed'].'
':'') .(($avo['consultthu'] != "")?''.$avo['consultthu'].'
':'') .(($avo['consultfri'] != "")?''.$avo['consultfri'].'
':'') .(($avo['consultsat'] != "")?''.$avo['consultsat'].'
':'') .(($avo['consultsun'] != "")?''.$avo['consultsun'].'
':''). - '
-
'; - + '
'; + } if ($avo['userspecialisations'] != ""){ + echo '
'; $spa = explode(',',$avo['userspecialisations']); - echo '

Specialisation

+ echo '
Specialisation
  • '.join('
  • ',$spa).'
'; + echo '
'; } + + + + echo '
-

'.(($avo['userdescription'] != "")?$avo['userdescription']:'').'

'; - if (strpos($avo['services'],'rendezvous') >= -1 ){ - echo ''; -} + echo '
'; } } ?> + diff --git a/tmpl/pages/profile/applications.php b/tmpl/pages/profile/applications.php index f02307b..40e1450 100644 --- a/tmpl/pages/profile/applications.php +++ b/tmpl/pages/profile/applications.php @@ -1,8 +1,9 @@ dbqueryall($sql); - $today = date('Y-m-d'); - $torenewstart = date('Y-m-d',strtotime("-14 days")) + $today = date('Y-m-d'); + $torenewstart = date('Y-m-d',strtotime("-14 days")); + ?>
@@ -11,6 +12,7 @@ foreach($userapps as $app => $appdata){ if (($appdata["activated"] == 1) || ($user["usergroup"] == "administrator")){ + ?>
@@ -24,12 +26,12 @@ - +

Periode d'essaie: semaines à partir de l'activation

= $today) { - echo ''; - echo '

Expire le:  '.date("d.m.Y", strtotime($appdata['expiration'])).'

'; + echo ''; + echo '

'.(($appdata['autorenew']== 1)?'Renouvellation automatique':'Expire ').' le:  '.date("d.m.Y", strtotime($appdata['expiration'])).'

'; } else { ?> @@ -42,6 +44,15 @@
Prix: € HTVA / mois
(payable par année)

+ Payer Maintenant'; + } else if ($appdata['expiration'] > $torenewstart){ + echo ''; + } + } + ?>
@@ -51,4 +62,9 @@ } // end foreach ?>
-
\ No newline at end of file +
+ \ No newline at end of file diff --git a/tmpl/pages/profile/profile.php b/tmpl/pages/profile/profile.php index d9ea507..dbb4ff7 100644 --- a/tmpl/pages/profile/profile.php +++ b/tmpl/pages/profile/profile.php @@ -6,13 +6,9 @@ $subpath = ""; } } - // $activatedapps = array(); - // if (($user['usergroup'] != 'client') && ($user['service'] != "")){ - // $activatedapps = explode(',',$user['services']); - // } ?>
-'; + } + +?> + \ No newline at end of file -- 2.39.5