From ce0f77a2a7679c79f8a3b1389a295af459b6ea8d Mon Sep 17 00:00:00 2001 From: Kilian Saffran Date: Tue, 31 Aug 2021 17:04:25 +0200 Subject: [PATCH] favorites bug fix --- public_html/qubeshop/lib/modules/Articles.php | 4 +- public_html/qubeshop/lib/modules/User.php | 2 +- public_html/qubeshop/log/logintest.log | 45 +++++++++++++++++++ .../qubeshop/tmpl/elements/shoptoolbar.html | 2 +- public_html/qubeshop/tmpl/js/shop.js | 11 +++-- .../qubeshop/tmpl/panels/pnl_favorites.html | 4 +- 6 files changed, 59 insertions(+), 9 deletions(-) diff --git a/public_html/qubeshop/lib/modules/Articles.php b/public_html/qubeshop/lib/modules/Articles.php index 21bceee..2a7bef5 100644 --- a/public_html/qubeshop/lib/modules/Articles.php +++ b/public_html/qubeshop/lib/modules/Articles.php @@ -40,7 +40,9 @@ class Articles{ public function getFavoriteArticles($iduser,$lang){ if (!$lang){ $lang=$this->cfg["lang"];} //all articles returned grouped by article_group; - return $this->dbh->querybykey('article_group',"select ar.id,UPPER(ar.article_group) as article_group,UPPER(ar.article) as article,ar.gp_art,ar.famille_art,ar.c01,ar.c02,ar.c03,ar.c04,ar.c05,ap.prix_net,ar.unite_quantite,qte_stock,qte_commandee,ar.doc_ft,ar.doc_mo,ar.doc_fs,case when ar.creationdate + INTERVAL 1 month > CURRENT_DATE then 1 else null end as isnew,ar.videolink from articles ar left join article_prices ap on (ar.article=ap.article) where article_group in (select article_group from articles where is active=1 and article in (select article from userfavorites where id_user='".$iduser."') group by article_group) order by article_group,article;"); + $sql ="select ar.id, UPPER(ar.article_group) as article_group, UPPER(ar.article) as article, ar.gp_art, ar.famille_art, ar.c01, ar.c02, ar.c03, ar.c04, ar.c05, ap.prix_net, ar.unite_quantite, qte_stock, qte_commandee, ar.doc_ft, ar.doc_mo, ar.doc_fs, case when ar.creationdate + INTERVAL 1 month > CURRENT_DATE then 1 else null end as isnew, ar.videolink from articles ar left join article_prices ap on (ar.article = ap.article) + where ar.article in ( select article from userfavorites where id_user = '".$iduser."') order by ar.article_group,ar.article;"; + return $this->dbh->querybykey('article_group',$sql); } public function getNewArticleGroups($lang){ diff --git a/public_html/qubeshop/lib/modules/User.php b/public_html/qubeshop/lib/modules/User.php index 2f1b0fd..f6c4c36 100644 --- a/public_html/qubeshop/lib/modules/User.php +++ b/public_html/qubeshop/lib/modules/User.php @@ -14,7 +14,7 @@ class User{ public function setUserFaviorite($iduser,$article){ $newid = $this->dbh->newuuid(); - $sql ="INSERT INTO userfavorites (id,id_user,article) VALUES ('".$newid."');"; + $sql ="INSERT INTO userfavorites (id,id_user,article) VALUES ('".$newid."','".$iduser."','".$article."');"; $ret = $this->dbh->exec($sql); return $ret; } diff --git a/public_html/qubeshop/log/logintest.log b/public_html/qubeshop/log/logintest.log index 224727d..83ddf95 100644 --- a/public_html/qubeshop/log/logintest.log +++ b/public_html/qubeshop/log/logintest.log @@ -23,3 +23,48 @@ USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.l [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c [usertype] => admin ) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) +USER: select id,usertype from users where lower(useremail)=lower('ksaffran@dks.lu') and userpassword = '0ecf731e2426a8a469f06e9f4a3bcbed6f8071d9d3e3ef7ef5fd9165021e27ec' and userpassword is not null and userpassword != '' and isenabled='1'; - Array +( + [id] => ef3b63ab-24a5-4972-86fb-8c3a4f36e75c + [usertype] => admin +) diff --git a/public_html/qubeshop/tmpl/elements/shoptoolbar.html b/public_html/qubeshop/tmpl/elements/shoptoolbar.html index 35147eb..d8f97a2 100644 --- a/public_html/qubeshop/tmpl/elements/shoptoolbar.html +++ b/public_html/qubeshop/tmpl/elements/shoptoolbar.html @@ -7,5 +7,5 @@ - + \ No newline at end of file diff --git a/public_html/qubeshop/tmpl/js/shop.js b/public_html/qubeshop/tmpl/js/shop.js index bc79f33..002ae4c 100644 --- a/public_html/qubeshop/tmpl/js/shop.js +++ b/public_html/qubeshop/tmpl/js/shop.js @@ -359,19 +359,22 @@ let shop= { articletofavorites: function(artidx,grpidx){ let grparticle = shop.article_groups[grpidx].article; postData({"cl":"User","fn":"setUserFaviorite","iduser":"{{session.id_user}}","article":shop.articles[grparticle][artidx].article}).then(agrps => { + console.log("Favorite saved!"); }); }, loadFavorites: function(){ let lst = document.getElementById("lst_favorites"); - document.getElementById("articlehead").innerHTML="{{lbl.favorites}}}"; + lst.innerHTML=''; + //document.getElementById("articlehead").innerHTML="{{lbl.favorites}}}"; postData({"cl":"Articles","fn":"getFavoriteArticleGroups","iduser":"{{session.id_user}}","lang":"{{lang}}"}).then(agrps => { + console.log("gr favs",agrps); shop.favgroups = agrps.data; - lst.innerHTML=''; + postData({"cl":"Articles","fn":"getFavoriteArticles","iduser":"{{session.id_user}}","lang":"{{lang}}"}).then(arts => { shop.favarticles = arts.data; - for (var g=0;g< shop.favorite_groups.length;g++){ - let agrp = shop.setArticleGroup(g,shop.favorite_groups[g],shop.favarticles,'fav'); + for (var g=0;g< shop.favgroups.length;g++){ + let agrp = shop.setArticleGroup(g,shop.favgroups[g],shop.favarticles,'fav'); lst.insertAdjacentHTML('beforeend',agrp); } myapp.viewpanel("favorites"); diff --git a/public_html/qubeshop/tmpl/panels/pnl_favorites.html b/public_html/qubeshop/tmpl/panels/pnl_favorites.html index 8771d8b..a2f8e40 100644 --- a/public_html/qubeshop/tmpl/panels/pnl_favorites.html +++ b/public_html/qubeshop/tmpl/panels/pnl_favorites.html @@ -1,8 +1,8 @@ -
+

Favorites

-
+
-- 2.39.5