From: Kilian Saffran Date: Wed, 11 Aug 2021 09:01:28 +0000 (+0200) Subject: v20110811 single articlegroup X-Git-Url: http://cloud.dks.lu/git/?a=commitdiff_plain;h=50143408a28f8fea454ae1806791955a889113ba;p=qube.git v20110811 single articlegroup --- diff --git a/api/bin/getapidata.pl b/api/bin/getapidata.pl index fa112a0..749fed4 100644 --- a/api/bin/getapidata.pl +++ b/api/bin/getapidata.pl @@ -455,91 +455,50 @@ if ($onlyget == 0){ #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,/){ diff --git a/public_html/qubeshop/lib/modules/Articles.php b/public_html/qubeshop/lib/modules/Articles.php index b597808..ca18da0 100644 --- a/public_html/qubeshop/lib/modules/Articles.php +++ b/public_html/qubeshop/lib/modules/Articles.php @@ -18,6 +18,12 @@ class 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;"); } + public function getArticleGroup($article,$lang){ + if (!$lang){ $lang=$this->cfg["lang"];} + 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;"); + } + + public function getByFamillyAndGroups($famillycode,$groupcode,$lang){ if (!$lang){ $lang=$this->cfg["lang"];} //all articles returned grouped by article_group; diff --git a/public_html/qubeshop/tmpl/js/shop.js b/public_html/qubeshop/tmpl/js/shop.js index 0690ea6..866f919 100644 --- a/public_html/qubeshop/tmpl/js/shop.js +++ b/public_html/qubeshop/tmpl/js/shop.js @@ -62,23 +62,23 @@ let shop= { let lst = document.getElementById("lst_articlegroups"); lst.innerHTML =""; postData({"cl":"ArticleGroups","fn":"getArticleGroupsByFamille","famille":fart,"lang":"{{lang}}"}).then(data => { - console.log("agdata",data); - for (var d=0;data.data.length;d++){ - console.log("ag dataset",d); - let agshort = '
'+ data.data[d].titre +'
'; + let rowx=0; + for (var d=0;d