#group images
$api->writelog("update article_groups images...");
- my $agimg = $db->queryarray("select ag.article,woa.nom_fichier from wiges_ole_article woa join article_groups ag on (woa.article=ag.article) where woa.code_document ='art_image' and woa.nom_fichier is not null;");
- if (scalar(@{$agimg}) > 0){
- my $cmd = 'rsync -av '.$cfg->{datapath}.'/art_image/ '.$cfg->{imgpath}.'article_groups/';
- my $cpr = system($cmd);
- if ($cpr != 0){
+ my $upselsql = "update wiges_ole_article as woa, article_groups as ag
+ set ag.image = case when woa.nom_fichier is null then null else replace(woa.nom_fichier,'art_image','article_groups') end,
+ ag.imgversion = DATE_FORMAT(woa.dateheure_document,'\%Y\%m\%d\%H\%i')
+ where woa.article = ag.article and woa.code_document = 'art_image'; ";
+ if ($cfg->{dryrun} == 1){
+ print $upselsql."\n";
+ } else {
+ my $agimg = $db->exec($upselsql);
+ my $cmd = 'rsync -av '.$cfg->{datapath}.'/art_image/ '.$cfg->{imgpath}.'article_groups/';
+ my $cpr = system($cmd);
+ if ($cpr != 0){
$api->writelog("cmd failed:".$cmd."!");
- }
- }
- foreach my $r (@{$agimg}){
- if (-e $cfg->{datapath}.'/'.$r->{nom_fichier}){
- my $newfname = basename($r->{nom_fichier});
- my $sql = "UPDATE article_groups set image='article_groups/".$newfname."' where article='".$r->{article}."';";
- #system($cmd);
- if ($cfg->{dryrun} == 1){
- print $sql."\n";
- } else {
- $api->writesql('article_groups',$sql);
- $db->exec($sql);
}
- } else {
- #print "File ".dirname($RealBin).'/data/'.$r->{nom_fichier}." does not exist!\n";
- }
}
$api->writelog("update article_groups fichetechnique...");
- #my $sqlcleanft = "UPDATE article_groups set fichetechnique=null;";
- #$db->exec($sqlcleanft);
- my $agfiche = $db->queryarray("select ag.article,woa.nom_fichier from wiges_ole_article woa join article_groups ag on (woa.article=ag.article) where woa.code_document ='art_fiche' and woa.nom_fichier is not null;");
- if (scalar(@{$agfiche}) > 0){
- my $cmd = 'rsync -av '.$cfg->{datapath}.'/art_fiche/ '.$cfg->{mediapath}.'fiche/';
- my $cpr = system($cmd);
- if ($cpr != 0){
+ $upselsql = "update wiges_ole_article as woa, article_groups as ag
+ set ag.fichetechnique = case when woa.nom_fichier is null then null else replace(woa.nom_fichier,'art_fiche','fiche') end,
+ where woa.article = ag.article and woa.code_document = 'art_fiche'; ";
+ if ($cfg->{dryrun} == 1){
+ print $upselsql."\n";
+ } else {
+ my $agfiche = $db->exec($upselsql);
+ my $cmd = 'rsync -av '.$cfg->{datapath}.'/art_fiche/ '.$cfg->{mediapath}.'fiche/';
+ my $cpr = system($cmd);
+ if ($cpr != 0){
$api->writelog("cmd failed:".$cmd."!");
- }
- }
- foreach my $r (@{$agfiche}){
- if (-e $cfg->{datapath}.'/'.$r->{nom_fichier}){
- my $newfname = basename($r->{nom_fichier});
- #$newfname =~ s/\s/_/g;
- # my $cmd = 'cp "'.$cfg->{datapath}.'/'.$r->{nom_fichier}.'" "'.$cfg->{mediapath}.'fiche/'.$newfname.'"';
- # print $cmd."\n";
- # system($cmd);
-
- my $sql = "UPDATE article_groups set fichetechnique='fiche/".$newfname."' where article='".$r->{article}."';";
- #system($cmd);
- if ($cfg->{dryrun} == 1){
- print $sql."\n";
- } else {
- $api->writesql('article_groups',$sql);
- $db->exec($sql);
}
- } else {
- #print "File ".dirname($RealBin).'/data/'.$r->{nom_fichier}." does not exist!\n";
- }
- }
+ }
+
$api->writelog("update article_groups brochure...");
- #my $sqlcleanbro = "UPDATE article_groups set brochure=null;";
- #$db->exec($sqlcleanbro);
- my $agbrochure = $db->queryarray("select ag.article,woa.nom_fichier from wiges_ole_article woa join article_groups ag on (woa.article=ag.article) where woa.code_document ='art_brochure' and woa.nom_fichier is not null;");
- if (scalar(@{$agbrochure}) > 0){
- my $cmd = 'rsync -av '.$cfg->{datapath}.'/art_brochure/ '.$cfg->{mediapath}.'brochure/';
- my $cpr = system($cmd);
- if ($cpr != 0){
+ $upselsql = "update wiges_ole_article as woa, article_groups as ag
+ set ag.fichetechnique = case when woa.nom_fichier is null then null else replace(woa.nom_fichier,'art_brochure','brochure') end,
+ where woa.article = ag.article and woa.code_document = 'art_brochure'; ";
+ if ($cfg->{dryrun} == 1){
+ print $upselsql."\n";
+ } else {
+ my $agfiche = $db->exec($upselsql);
+ my $cmd = 'rsync -av '.$cfg->{datapath}.'/art_brochure/ '.$cfg->{mediapath}.'brochure/';
+ my $cpr = system($cmd);
+ if ($cpr != 0){
$api->writelog("cmd failed:".$cmd."!");
- }
- }
- foreach my $r (@{$agbrochure}){
- if (-e $cfg->{datapath}.'/'.$r->{nom_fichier}){
- my $newfname = basename($r->{nom_fichier});
- #$newfname =~ s/\s/_/g;
- # my $cmd = 'cp "'.$cfg->{datapath}.'/'.$r->{nom_fichier}.'" "'.$cfg->{mediapath}.'brochure/'.$newfname.'"';
- # print $cmd."\n";
- # system($cmd);
-
- my $sql = "UPDATE article_groups set brochure='brochure/".$newfname."' where article='".$r->{article}."';";
- #system($cmd);
- if ($cfg->{dryrun} == 1){
- print $sql."\n";
- } else {
- $api->writesql('article_groups',$sql);
- $db->exec($sql);
}
- } else {
- #print "File ".dirname($RealBin).'/data/'.$r->{nom_fichier}." does not exist!\n";
- }
- }
+ }
+
$api->writelog("End Copy article_groups...");
}
if ($steps =~ /articles,/){
return $this->dbh->queryarray("select id,article,gp_art,famille_art,coalesce(titre_".$lang.",titre_".$this->cfg["lang"].") as titre,coalesce(description_".$lang.",description_".$this->cfg["lang"].") as description,c01_label,c02_label,c03_label,c03_label,c04_label,c05_label,replace(image,' ','%20') as image,fichetechnique,brochure,noticemontage from article_groups where gp_art='".$groupcode."' and famille_art='".$famillycode."' order by titre,article;");\r
}\r
\r
+ public function getArticleGroup($article,$lang){\r
+ if (!$lang){ $lang=$this->cfg["lang"];}\r
+ return $this->dbh->queryarray("select id,article,gp_art,famille_art,coalesce(titre_".$lang.",titre_".$this->cfg["lang"].") as titre,coalesce(description_".$lang.",description_".$this->cfg["lang"].") as description,c01_label,c02_label,c03_label,c03_label,c04_label,c05_label,replace(image,' ','%20') as image,fichetechnique,brochure,noticemontage from article_groups where article='".$article."' order by titre,article;");\r
+ }\r
+\r
+\r
public function getByFamillyAndGroups($famillycode,$groupcode,$lang){\r
if (!$lang){ $lang=$this->cfg["lang"];}\r
//all articles returned grouped by article_group;\r
let lst = document.getElementById("lst_articlegroups");\r
lst.innerHTML ="";\r
postData({"cl":"ArticleGroups","fn":"getArticleGroupsByFamille","famille":fart,"lang":"{{lang}}"}).then(data => {\r
- console.log("agdata",data);\r
- for (var d=0;data.data.length;d++){\r
- console.log("ag dataset",d);\r
- let agshort = '<div class="padding fifth center"><div class="container card-4 center" style="cursor: pointer; padding: 0px!important;" onclick="shop.loadGroupArticle(\''+ data.data[d].article +'\');"><img style="min-height: 150px; height: 150px;" src="img/'+ data.data[d].image +'" alt=""><div class="container center bg-qube text-white bold" style="min-height: 50px; padding-top: 5px;">'+ data.data[d].titre +'</div></div></div>';\r
+ let rowx=0;\r
+ for (var d=0;d<data.data.length;d++){\r
+ //console.log("row " + d);\r
+ if ((d != 0) && (d%5==0)){\r
+ lst.insertAdjacentHTML('beforeend','<div class="row articlegrps" id="artrow_'+ rowx+'" style="display: none;"></div>');\r
+ rowx++;\r
+ }\r
+ let agshort = '<div class="padding fifth center"><div class="container card-4 center" style="cursor: pointer; padding: 0px!important;" onclick="shop.loadGroupArticle(\''+ data.data[d].article +'\',\''+ rowx+'\');"><img style="min-height: 150px; height: 150px;" src="img/'+ data.data[d].image +'" alt=""><div class="container center bg-qube text-white bold" style="min-height: 50px; padding-top: 5px;">'+ data.data[d].titre +'</div></div></div>';\r
lst.insertAdjacentHTML('beforeend',agshort);\r
- } \r
+ \r
+ }\r
+ lst.insertAdjacentHTML('beforeend','<div class="row articlegrps" id="artrow_'+ rowx+'" style="display: none;"></div>');\r
});\r
},\r
getgrouptbldata: function(id){\r
- //let selectedData = shop.tblgroups.getSelectedData();\r
postData({"cl":"ArticleGroups","fn":"getPublishedGroups","lang":"{{lang}}"}).then(data => {\r
- //console.log("GroupData",data);\r
shop.tblgroups.setData(data.data).then(tblres => { });\r
-\r
- // function(){\r
- // if(selectedData[0]){staff.tbl.selectRow(selectedData[0]['id']);}\r
- //\r
}).catch(e => { console.log(e)});\r
},\r
getCounterfield: function(labels,unit){\r
strartgrp += '<th style="width: 46px;">FT</th><th style="width: 46px;">MO</th><th style="width: 46px;">FS</th>'+\r
'</tr></thead>'+\r
'<tbody>';\r
- //console.log("grparticle",grparticle);\r
- //console.log("articledata",articledata);\r
if (articledata[grparticle]){\r
\r
for (var adx in articledata[grparticle]){\r
'</div>';\r
return strartgrp;\r
},\r
- loadGroupArticle: function(){\r
-\r
+ loadGroupArticle: function(article,rowx){\r
+ let mods = document.getElementsByClassName("articlegrps");\r
+ for (let i=0;i<mods.length;i++){\r
+ mods[i].style.display = 'none';\r
+ }\r
+ let lst = document.getElementById("artrow_" + rowx);\r
+ lst.innerHTML='';\r
+ postData({"cl":"Articles","fn":"getArticleGroup","article":article,"lang":"{{lang}}"}).then(agrps => {\r
+ shop.article_groups = agrps.data;\r
+ lst.innerHTML='';\r
+ postData({"cl":"Articles","fn":"getByFamillyAndGroups","famillycode":shop.article_groups[0].famille_art,"groupcode":shop.article_groups[0].gp_art,"lang":"{{lang}}"}).then(arts => {\r
+ shop.articles = arts.data;\r
+ for (var g=0;g< shop.article_groups.length;g++){\r
+ let agrp = shop.setArticleGroup(g,shop.article_groups[g],shop.articles,'shop');\r
+ lst.insertAdjacentHTML('beforeend',agrp);\r
+ }\r
+ lst.style.display = 'block';\r
+ });\r
+ }).catch(e => { console.log(e)});\r
+ \r
},\r
loadProducts: function(){\r
let sel = shop.tblgroups.getSelectedData();\r
shop.setBasket();\r
},\r
articletoaskprice: function(artidx,grpidx){\r
- console.log("grpidx",grpidx);\r
- console.log("artidx",artidx);\r
- let grparticle = shop.article_groups[grpidx].article;\r
+ let grparticle = shop.article_groups[grpidx].article;\r
let article = shop.articles[grparticle][artidx].article;\r
let artid = shop.articles[grparticle][artidx].id;\r
if (!shop.askprice[grparticle]){\r
if (!shop.askprice[grparticle]["articles"][article]){\r
shop.askprice[grparticle]["articles"][article] = shop.articles[grparticle][artidx];\r
}\r
- console.log("price-list",shop.askprice);\r
shop.setAskPrice();\r
},\r
setAskPrice: function(){\r