favorites bug fix
authorKilian Saffran <ksaffran@dks.lu>
Tue, 31 Aug 2021 15:04:25 +0000 (17:04 +0200)
committerKilian Saffran <ksaffran@dks.lu>
Tue, 31 Aug 2021 15:04:25 +0000 (17:04 +0200)
public_html/qubeshop/lib/modules/Articles.php
public_html/qubeshop/lib/modules/User.php
public_html/qubeshop/log/logintest.log
public_html/qubeshop/tmpl/elements/shoptoolbar.html
public_html/qubeshop/tmpl/js/shop.js
public_html/qubeshop/tmpl/panels/pnl_favorites.html

index 21bceee..2a7bef5 100644 (file)
@@ -40,7 +40,9 @@ class Articles{
   public function getFavoriteArticles($iduser,$lang){\r
     if (!$lang){ $lang=$this->cfg["lang"];}\r
     //all articles returned grouped by article_group;\r
-    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;");\r
+    $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)\r
+    where ar.article in ( select article from userfavorites where id_user = '".$iduser."') order by ar.article_group,ar.article;";\r
+    return $this->dbh->querybykey('article_group',$sql);\r
   }\r
 \r
   public function getNewArticleGroups($lang){\r
index 2f1b0fd..f6c4c36 100644 (file)
@@ -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;
   }
index 224727d..83ddf95 100644 (file)
@@ -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
+)
index 35147eb..d8f97a2 100644 (file)
@@ -7,5 +7,5 @@
   <button class="bar-item toolbarbtn right" onclick="myapp.viewpanel('profile');"><span class="icon icon-user"></span>Mon Compte</button>\r
   <button class="bar-item toolbarbtn right" onclick="myapp.viewpanel('shop');"><span class="icon icon-box"></span>Produits</button>\r
   <button class="bar-item toolbarbtn right" onclick="contratcadre.view(); return false;"><span class="icon icon-contrat-cadre"></span>Contrat Cadre</button>\r
-  <button class="bar-item toolbarbtn right orange" onclick="myapp.viewpanel('favorites');"><span class="icon icon-star"></span>Favorites</button>\r
+  <button class="bar-item toolbarbtn right orange" onclick="shop.loadFavorites();"><span class="icon icon-star"></span>Favorites</button>\r
 </div>
\ No newline at end of file
index bc79f33..002ae4c 100644 (file)
@@ -359,19 +359,22 @@ let shop= {
   articletofavorites: function(artidx,grpidx){\r
     let grparticle = shop.article_groups[grpidx].article;\r
     postData({"cl":"User","fn":"setUserFaviorite","iduser":"{{session.id_user}}","article":shop.articles[grparticle][artidx].article}).then(agrps => {\r
+      \r
       console.log("Favorite saved!");\r
     });\r
   },\r
   loadFavorites: function(){\r
     let lst = document.getElementById("lst_favorites");\r
-    document.getElementById("articlehead").innerHTML="{{lbl.favorites}}}";\r
+    lst.innerHTML='';\r
+    //document.getElementById("articlehead").innerHTML="{{lbl.favorites}}}";\r
       postData({"cl":"Articles","fn":"getFavoriteArticleGroups","iduser":"{{session.id_user}}","lang":"{{lang}}"}).then(agrps => {\r
+        console.log("gr favs",agrps);\r
         shop.favgroups = agrps.data;\r
-        lst.innerHTML='';\r
+        \r
         postData({"cl":"Articles","fn":"getFavoriteArticles","iduser":"{{session.id_user}}","lang":"{{lang}}"}).then(arts => {\r
           shop.favarticles = arts.data;\r
-          for (var g=0;g< shop.favorite_groups.length;g++){\r
-            let agrp = shop.setArticleGroup(g,shop.favorite_groups[g],shop.favarticles,'fav');\r
+          for (var g=0;g< shop.favgroups.length;g++){\r
+            let agrp = shop.setArticleGroup(g,shop.favgroups[g],shop.favarticles,'fav');\r
             lst.insertAdjacentHTML('beforeend',agrp);\r
           }\r
           myapp.viewpanel("favorites");\r
index 8771d8b..a2f8e40 100644 (file)
@@ -1,8 +1,8 @@
-<div class="container" style="width: 1200px;margin: auto;">
+<div class="container"  style="width: 1500px; margin: auto;">
   <div class="bar border">
     <div class="bar-item"><h2 class="color-qube">Favorites</h2></div>   
   </div>
-  <div  class="lst_favorites" style="height: calc(100vh - 218px); overflow-y: auto;">
+  <div id="lst_favorites" style="height: calc(100vh - 218px); overflow-y: auto;">
     
   </div>