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
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;
}
[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
+)
<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
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
-<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>