From: Kilian Saffran Date: Tue, 25 Jun 2019 08:50:40 +0000 (+0200) Subject: tested and updated annuaire and activation X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=8553a5b26b2bb80626140ff1af9074bcd345e762;p=juridig_lu.git tested and updated annuaire and activation --- diff --git a/backoffice/api/lib/dksapp.pm b/backoffice/api/lib/dksapp.pm index b70a61a..6d94cb3 100644 --- a/backoffice/api/lib/dksapp.pm +++ b/backoffice/api/lib/dksapp.pm @@ -7,6 +7,7 @@ use lib ('./lib'); use lib ('./'); use File::Basename; use Getopt::Long; +use Data::Dumper; use dksdb; sub new { @@ -22,31 +23,36 @@ sub activate_app(){ my $iduser = shift; my $duration = shift; my $statusdate = shift; - my $apacc = $self->{db}->dbquery("select ac.id,ac.expiration,ap.app,app.inittables from appaccess ac join apps ap on (ac.id_app=ap.id) where ac.id_user=".$iduser." and id_app=".$idapp.";"); + + + my $apacc = $self->{db}->dbquery("select ac.id,ac.expiration,ap.app,ap.inittables from appaccess ac join apps ap on (ac.id_app=ap.id) where ac.id_user=".$iduser." and id_app=".$idapp.";"); my $res; if ($apacc){ $res = $self->{db}->dbexec("update appaccess set expiration=date(case when expiration >= date('".$statusdate."') then expiration + interval '".$duration." month' else date('".$statusdate."') + interval '".$duration." month' end) where id=".$apacc->{id}); } else { $res = $self->{db}->dbexec("INSERT INTO appaccess (id_user, id_app, publicenabled, expiration) VALUES(".$iduser.", ".$idapp.", null, date('".$statusdate."') + interval '".$duration." month');"); - # if (($apacc->{inittables}) && ($apacc->{inittables} ne "")){ - # my @tbl = split(",",$apacc->{inittables}); - # foreach my $t (@tbl){ - # - # } - # } - if ($idapp eq "2"){ #is annauire + } + if ($idapp eq "2"){ #is annuaire + my $ud = $self->{db}->dbquery("SELECT * from users where id=".$iduser.";"); + if (exists($ud->{id})){ - $self->{db}->dbexec("INSERT INTO lawyercatalog (id_user) VALUES (".$iduser.");"); - my $profile_link = lc(substr($ud->{username},0,index($ud->{username},0,'@'))); - my $profexists = $self->{db}->dbquery("SELECT COUNT(*)+1 as cnt from lawyercatalog where profile_link='".$profile_link."';"); - if ($profexists->{cnt} ne "1"){ - $profile_link .= $profexists->{cnt}; + my $lc = $self->{db}->dbquery("select count(*) as cnt from lawyercatalog where id_user=".$iduser.";"); + + if ($lc->{cnt} eq "0"){ + + $self->{db}->dbexec("INSERT INTO lawyercatalog (id_user) VALUES (".$iduser.");"); + my $profile_link = lc(substr($ud->{username},0,index($ud->{username},'@'))); + my $profexists = $self->{db}->dbquery("SELECT COUNT(*)+1 as cnt from lawyercatalog where profile_link='".$profile_link."';"); + if ($profexists->{cnt} ne "1"){ + $profile_link .= $profexists->{cnt}; + } + + $self->{db}->dbexec("UPDATE lawyercatalog SET profile_link='".$profile_link."' WHERE id_user=".$iduser.";"); } - $self->{db}->dbexec("UPDATE lawyercatalog SET profilelink='".$profile_link."' WHERE id_user=".$iduser.";"); } } - } + return $res; } diff --git a/backoffice/api/lib/dksinvoice.pm b/backoffice/api/lib/dksinvoice.pm index fab7046..1c3331a 100644 --- a/backoffice/api/lib/dksinvoice.pm +++ b/backoffice/api/lib/dksinvoice.pm @@ -6,7 +6,7 @@ use lib ('./lib'); use lib ('./'); use POSIX qw(strftime); use File::Basename; - +use Data::Dumper; use dksdb; use dksreport; use dksapp; @@ -55,7 +55,7 @@ sub newinvoice(){ if (exists($data->{paypal})){ ($inv,$prd) = $self->getpaypaldetails($data); $inv->{invoices_payementmethod} = 'paypal'; - $inv->{invoices_tranactiondata} = JSON::PP::encode_json($data); + $inv->{invoices_transactiondata} = JSON::PP::encode_json($data); } else { $inv->{invoices_email} = $data->{email}; $inv->{invoices_recipient} = $data->{recipient}; @@ -128,7 +128,7 @@ sub getpaypaldetails(){ my $self = shift; my $ppa = shift; my $adrdata->{invoices_email} = $ppa->{payer}->{email_address}; - $adrdata->{invoices_recepient} = $ppa->{payer}->{name}->{givenname}." ".$ppa->{payer}->{name}->{surname}; + $adrdata->{invoices_recipient} = $ppa->{payer}->{name}->{givenname}." ".$ppa->{payer}->{name}->{surname}; $adrdata->{invoices_address} = $ppa->{shipping}->{address}->{address_line_1}; $adrdata->{invoices_zip} = $ppa->{shipping}->{address}->{postal_code}; $adrdata->{invoices_city} = $ppa->{shipping}->{address}->{admin_area_2}; diff --git a/backoffice/api/process.cgi b/backoffice/api/process.cgi index 185c5b0..75fa0bb 100644 --- a/backoffice/api/process.cgi +++ b/backoffice/api/process.cgi @@ -65,24 +65,23 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ my $appinfo = JSON::PP::decode_json($p->{appinfo}); my $invdata = JSON::PP::decode_json($p->{invoice}); my ($invid,$invstatus,$invamount,$invemail) = $inv->newinvoice($appinfo->{id_user},$invdata,$appinfo); + if ($invid){ $html->{result}= $invid; my $pdf = $inv->createpdf($invid,'invoice_dks','fr',dirname($ENV{"SCRIPT_FILENAME"}).'/reports'); + if (-e dirname($ENV{"SCRIPT_FILENAME"}).'/reports/'.$pdf){ if (($invstatus eq "PAYED") && ($invamount > 0)){ my $eml = sendemail->new(); $eml->sendemail('user_invoice',$sess->{id},$invemail,{},dirname($ENV{"SCRIPT_FILENAME"}).'/reports/'.$pdf); } - } else { - # open (LOG,">>tmp/app.log"); - # print LOG "FILE: ".dirname($ENV{"SCRIPT_FILENAME"}).'/reports/'.$pdf." does not exist!\n"; - # close(LOG); - } + } } if (($invstatus ) && ($invstatus eq "PAYED")){ - my $app = dksapp->new(); + $inv->activate_app_byinvoiceid($invid); } + } elsif ($p->{fn} eq "savefield"){ @@ -216,8 +215,8 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ } } if ($invstatus == "PAYED"){ - my $app = dksapp->new(); - $app->activateapp($invid); + #my $app = dksapp->new(); + $inv->activate_app_byinvoiceid($invid); } $html->{result} ="OK"; } @@ -226,12 +225,12 @@ if (($cgi->request_method() eq "GET") || ($cgi->request_method() eq "POST")){ # my $rep = report->new(); # $rep->generatepdf($invid,'invoices','invoicedata','pdfname','invoice_dks','fr',dirname($ENV{"SCRIPT_FILENAME"}).'/reports'); # } - elsif($p->{fn} eq "getevents"){ - my $sql = "select * from geteventsbydisponibility(".$sess->{id}.",date('".$p->{startdate}."'),date('".$p->{enddate}."')) order by startdate,starttime;"; - my $res = $db->dbquerysorted($sql); - $html->{result}->{sql} = $sql; - $html->{result}->{events} = $res; - } + # elsif($p->{fn} eq "getevents"){ + # my $sql = "select * from geteventsbydisponibility(".$sess->{id}.",date('".$p->{startdate}."'),date('".$p->{enddate}."')) order by startdate,starttime;"; + # my $res = $db->dbquerysorted($sql); + # $html->{result}->{sql} = $sql; + # $html->{result}->{events} = $res; + # } } } diff --git a/backoffice/css/module.css b/backoffice/css/module.css index 26ef47a..b463d2e 100644 --- a/backoffice/css/module.css +++ b/backoffice/css/module.css @@ -13,4 +13,35 @@ img.preview { border: 1px solid #ced4da; border-radius: .25rem; padding: .375rem .375rem; -} \ No newline at end of file +} + +[data-type='validator-error'] { + display: none; + font-size: 11px; + position: absolute; + z-index: 10; + margin-top: 2px; + color: #ffffff; + background: rgb(200, 53, 53); + box-shadow: 0 6px 2px -2px rgba(211, 77, 77, 0.47); + padding: 4px 10px; + border-radius: 1px; + pointer-events: none; +} + +[data-type='validator-error']:before { + display: none; + content: ''; + width: 0; + height: 0; + top: -5px; + position: absolute; + left: 6px; + border-left: 5px solid rgba(0, 0, 0, 0); + border-right: 5px solid rgba(0, 0, 0, 0); + border-bottom: 5px solid #c83535; +} + +form input[type='text'].error,input[type='email'].error, form input[type='password'].error, form textarea.error { + border: 1px solid #fa4531; +} diff --git a/backoffice/index.cgi b/backoffice/index.cgi index 06acaaa..2c7d8da 100644 --- a/backoffice/index.cgi +++ b/backoffice/index.cgi @@ -23,7 +23,12 @@ my $vars = $sitecfg; $vars->{filepath} = substr($cgi->url({-absolute=>1}),length($vars->{basepath})+1); $vars->{baseurl} = $cgi->url({-base=>1}).$vars->{basepath}; -$vars->{siteurl} = $cgi->url({-base=>1}).dirname($vars->{basepath}); +if ($vars->{basepath} eq "/"){ + $vars->{siteurl} = $cgi->url({-base=>1}); +}else { + $vars->{siteurl} = $cgi->url({-base=>1}).dirname($vars->{basepath}); +} + if ($vars->{filepath} ne ""){ $vars->{suffix} = substr($vars->{filepath},rindex($vars->{filepath},'.')); $vars->{page} = $vars->{filepath}; diff --git a/backoffice/tmpl/module/annuaire/index.js b/backoffice/tmpl/module/annuaire/index.js index 7bbc9af..532425d 100644 --- a/backoffice/tmpl/module/annuaire/index.js +++ b/backoffice/tmpl/module/annuaire/index.js @@ -16,8 +16,8 @@ tinymce.init({ image_advtab: true, init_instance_callback: function (editor) { editor.on('blur', function (e) { - console.log('Editor was blurred!'); - console.log(e.target.id); + // console.log('Editor was blurred!'); + // console.log(e.target.id); $("#" + e.target.id).html(editor.getContent()); //console.log(editor.getContent()); if (savefield){ @@ -29,29 +29,29 @@ tinymce.init({ } $('select').on('hidden.bs.select', function (event) { - console.log(event); - console.log(savefield); - console.log("ID:" + event.currentTarget.id); + // console.log(event); + // console.log(savefield); + // console.log("ID:" + event.currentTarget.id); savefield(event.currentTarget.id); }); $("input,textarea").on('blur',function(event){ - console.log(event); + // console.log(event); //console.log(event.currentTarget.tagName); //console.log(event.currentTarget.type); if (event.currentTarget.type != "file"){ - console.log('savefield'); + //console.log('savefield'); savefield(event.currentTarget.id); } }); function CropImageDlg(objid){ - console.log("Crop Object ID:"+ objid); + // console.log("Crop Object ID:"+ objid); var obj = document.getElementById("files_" + objid); - console.log(obj.files); + // console.log(obj.files); var file = obj.files[0]; // console.log(file); var fileName = file.name; @@ -90,7 +90,7 @@ $('#cropimg').on('shown.bs.modal', function () { canvasData = cropper.getCanvasData(); var data = cropper.getCroppedCanvas().toDataURL(); var fieldid=$('#cropdata_field_id').val(); - console.log("FieldID:" + fieldid); + //console.log("FieldID:" + fieldid); $("#preview_" + fieldid).prop("src",data); $("#" + fieldid).val(data); savefield(fieldid); @@ -108,7 +108,7 @@ function removephoto(objid,defaultimg){ } function LoadCropper(objid){ - console.log("Preview load cropper!" + objid); + // console.log("Preview load cropper!" + objid); var objf = document.getElementById('files_' + objid); $('#cropdata_field_id').val(objid); @@ -118,3 +118,4 @@ function LoadCropper(objid){ return false; } + diff --git a/backoffice/tmpl/module/annuaire/index.tt b/backoffice/tmpl/module/annuaire/index.tt index fda2005..e71b291 100644 --- a/backoffice/tmpl/module/annuaire/index.tt +++ b/backoffice/tmpl/module/annuaire/index.tt @@ -8,7 +8,7 @@ left join public.lawyercategories lca on (ca.id=lca.id_category and lca.id_catal
-
+
- +
diff --git a/backoffice/tmpl/module/applications/index.js b/backoffice/tmpl/module/applications/index.js index 6e17405..132796b 100644 --- a/backoffice/tmpl/module/applications/index.js +++ b/backoffice/tmpl/module/applications/index.js @@ -17,7 +17,7 @@ var iduser=[% session.id %]; } $("input.fieldsave").on('blur',function(event){ - console.log(event); + //console.log(event); savefield(event.currentTarget.id); }); @@ -75,7 +75,7 @@ var iduser=[% session.id %]; } function voucher_callback(data){ - console.log(data); + //console.log(data); if (data && data.package && data.app){ $("#checkout_package").html("Package: " + data.package + ""); $("#checkout_package").show(); @@ -109,9 +109,13 @@ var iduser=[% session.id %]; } function activate_app(){ - if (!$("#frm_invoicedata").hasClass("was-validated")){ + //console.log(frmvalidate.validate()); + if (frmvalidate.validate() == false){ + // if (!$("#frm_invoicedata").hasClass("was-validated")){ return false; } + $("#checkout").hide(); + $("#loader").show(); var pdata = {fn:"activateapp", appinfo:{},invoice:{}}; //if ($("#frm_invoicedata").hasClass("was-validated")){ $("input[type='hidden']").each(function(){ @@ -124,48 +128,23 @@ var iduser=[% session.id %]; }); pdata['invoice']['description'] = "Souscription juridig.lu - " + appdata[pdata["appinfo"]['id_app']]["name"] + ' - ' + pdata["appinfo"]["package"]; - console.log(pdata); + //console.log(pdata); process_data(pdata,activate_callback); - console.log("Data Process finished!"); + //console.log("Data Process finished!"); return false; - //} - //return false; - // if ($("#frm_invoicedata").hasClass("was-validated")){ - // var pdata = {fn:"activateapp"}; - - // $("#frm_invoicedata input,select").each(function(){ - // console.log($(this).attr("id") = $(this).val()) ; - // pdata[$(this).attr("id")] = $(this).val(); - // }); - - // - // }else { - // console.log("No validation!"); - // } - // return false; + } -// function buy_viainvoice(){ -// if (!$("#frm_invoicedata").hasClass("was-validated")){ -// console.log("Validation NOT OK!RETURN"); -// return false; -// } -// var pdata = {fn:"activateapp"}; -// $("input,select").each(function(){ -// pdata[$(this).attr("id")] = $(this).val(); -// }); -// console.log(pdata); -// process_data(pdata,lauchinvoice_callback); -// } + function activate_callback(data){ - console.log("activated callback"); + //console.log("activated callback"); //console.log(JSON.stringify(data)); parent.location.reload(); } function paypal_callback(data){ - console.log("Paypal callback"); + //console.log("Paypal callback"); //console.log(data); parent.location.reload(); } @@ -200,24 +179,7 @@ var iduser=[% session.id %]; }).render('#paypal-button-container'); - (function() { - 'use strict'; - window.addEventListener('load', function() { - // Fetch all the forms we want to apply custom Bootstrap validation styles to - var forms = document.getElementsByClassName('needs-validation'); - // Loop over them and prevent submission - var validation = Array.prototype.filter.call(forms, function(form) { - form.addEventListener('submit', function(event) { - // console.log("Check Validate"); - if (form.checkValidity() === false) { - event.preventDefault(); - event.stopPropagation(); - } - form.classList.add('was-validated'); - event.preventDefault(); - event.stopPropagation(); - - }, false); - }); - }, false); -})(); \ No newline at end of file +var frmvalidate =new Validator(document.querySelector('#frm_invoicedata'), function (err, res) { + //console.log("Validator: " + res); + return res; +}); diff --git a/backoffice/tmpl/module/applications/index.tt b/backoffice/tmpl/module/applications/index.tt index 905e28c..d079077 100644 --- a/backoffice/tmpl/module/applications/index.tt +++ b/backoffice/tmpl/module/applications/index.tt @@ -114,7 +114,7 @@
- + @@ -123,21 +123,21 @@
- +
- +
- +
- + - +
@@ -154,7 +154,7 @@
- +
@@ -163,6 +163,11 @@
+ +