v20220506 1.6.19 master
authorKilian Saffran <ksaffran@dks.lu>
Fri, 6 May 2022 12:15:00 +0000 (14:15 +0200)
committerKilian Saffran <ksaffran@dks.lu>
Fri, 6 May 2022 12:15:00 +0000 (14:15 +0200)
public_html/api/bin/getapidata.pl
public_html/index.php
public_html/js/askprice.js
public_html/js/shop.js
public_html/lib/modules/Orders.php
public_html/lib/modules/Site.php
public_html/lib/version.php
public_html/pages/product.php

index 38504a4..de66bce 100644 (file)
@@ -755,7 +755,7 @@ if ($onlyget == 0){
     when code_document in ('art_soumis') then 'soumission'
     when code_document in ('art_brochure') then 'securite'
     else null end as tblcolumn, 
-    case when commentaire is not null 
+    case when commentaire like 'http%'
     then commentaire else
     concat(case when code_document in ('art_bro_pdf') then 'brochure' 
     when code_document in ('art_fiche') then 'fiche' 
@@ -771,17 +771,28 @@ if ($onlyget == 0){
     code_document,commentaire,nom_fichier from wiges_ole_article where code_document!='art_image' and article LIKE '&%';";
     my $filedata = $db->queryarray($sqlfiles);
     foreach my $f (@{$filedata}){
-      if (($f->{tblcolumn} ne "") && ($f->{tblvalue} !~ /^http/) && (-e $cfg->{mediapath}.'/'.$f->{nom_fichier})){
-        if (! -d dirname($cfg->{path}.'/'.$f->{tblvalue})){
-          mkdir dirname($cfg->{mediapath}.'/'.$f->{tblvalue});
-        }
-        #print 'cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.''.$f->{tblvalue}.'"'."\n";
-        system('cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.''.$f->{tblvalue}.'"');
-        #print "UPDATE article_groups SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';"."\n";
-        $db->exec("UPDATE article_groups SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';");
-      } elsif (($f->{tblcolumn} ne "") && ($f->{tblvalue} =~ /^http/)){
-        #print "UPDATE article_groups SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';"."\n";
+      # if (-e $cfg->{mediapath}.'/'.$f->{nom_fichier}) && (){
+      #   $stat = stat($cfg->{mediapath}.'/'.$f->{nom_fichier});
+      #   if ($stat[7] ne "0"){
+      #     $db->exec("UPDATE article_groups SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';");
+      #   }
+      # }
+      if ($f->{tblvalue} =~ /^http/){
         $db->exec("UPDATE article_groups SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';");
+      } elsif (-e $cfg->{mediapath}.'/'.$f->{nom_fichier}){
+        my @stat = stat($cfg->{mediapath}.'/'.$f->{nom_fichier});
+        if ($stat[7] ne "0"){
+          $db->exec("UPDATE article_groups SET ".$f->{tblcolumn}."='".$f->{nom_fichier}."' where article='".$f->{article}."';");
+          if (-e $cfg->{mediapath}.'/'.$f->{tblvalue}){
+            my @stat2 = stat($cfg->{mediapath}.'/'.$f->{tblvalue});
+            if ($stat2[7] ne $stat[7]){
+              system('cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.'/'.$f->{tblvalue}.'"');
+            }
+          } else {
+              system('cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.'/'.$f->{tblvalue}.'"'); 
+          }
+          
+        } 
       }
     }
 
@@ -889,21 +900,38 @@ if ($onlyget == 0){
     code_document,commentaire,nom_fichier from wiges_ole_article where code_document!='art_image' and article NOT LIKE '&%';";
     my $filedata = $db->queryarray($sqlfiles);
     foreach my $f (@{$filedata}){
-      if (($f->{tblcolumn} ne "") && ($f->{tblvalue} !~ /^http/)){
-        if (! -d dirname($cfg->{mediapath}.''.$f->{tblvalue})){
-          mkdir dirname($cfg->{mediapath}.''.$f->{tblvalue});
-        }
-        #print 'cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.''.$f->{tblvalue}.'"'."\n";
-        system('cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.''.$f->{tblvalue}.'"');
-        #print "UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';"."\n";
-        $db->exec("UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';");
-      } elsif (($f->{tblcolumn} ne "") && ($f->{tblvalue} =~ /^http/)){
-        #print "UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';"."\n";
+      if ($f->{tblvalue} =~ /^http/){
         $db->exec("UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';");
+      } elsif (-e $cfg->{mediapath}.'/'.$f->{nom_fichier}){
+        my @stat = stat($cfg->{mediapath}.'/'.$f->{nom_fichier});
+        if ($stat[7] ne "0"){
+          $db->exec("UPDATE articles SET ".$f->{tblcolumn}."='".$f->{nom_fichier}."' where article='".$f->{article}."';");
+          if (-e $cfg->{mediapath}.'/'.$f->{tblvalue}){
+            my @stat2 = stat($cfg->{mediapath}.'/'.$f->{tblvalue});
+            if ($stat2[7] ne $stat[7]){
+              system('cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.'/'.$f->{tblvalue}.'"');
+            }
+          } else {
+             system('cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.'/'.$f->{tblvalue}.'"'); 
+           }
+          
+        } 
       }
+      # if (($f->{tblcolumn} ne "") && ($f->{tblvalue} !~ /^http/)){
+      #   if (! -d dirname($cfg->{mediapath}.''.$f->{tblvalue})){
+      #     mkdir dirname($cfg->{mediapath}.''.$f->{tblvalue});
+      #   }
+      #   #print 'cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.''.$f->{tblvalue}.'"'."\n";
+      #   system('cp "'.$cfg->{mediapath}.'/'.$f->{nom_fichier}.'" "'.$cfg->{mediapath}.''.$f->{tblvalue}.'"');
+      #   #print "UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';"."\n";
+      #   $db->exec("UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';");
+      # } elsif (($f->{tblcolumn} ne "") && ($f->{tblvalue} =~ /^http/)){
+      #   #print "UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';"."\n";
+      #   $db->exec("UPDATE articles SET ".$f->{tblcolumn}."='".$f->{tblvalue}."' where article='".$f->{article}."';");
+      # }
     }
 
-    $api->writelog("end copy articles files...");
+    $api->writelog("end copy articles files..."); 
   }
   if (($steps =~ /prices,/)  || ($steps =~ /articles,/)){
     $api->writelog("copy article prices...");
index d1f2620..fd68f15 100644 (file)
@@ -157,7 +157,7 @@ $site = new Site($db,$cfg);
 <meta name="geo.placename" content="Luxembourg" />
 <meta name="geo.position" content="49.651203;6.083003" />
 <meta name="ICBM" content="49.651203, 6.083003" />
-<link rel="alternate" type="text/html" hreflang="fr" href="<?php echo $cfg["siteurl"]; ?>home/home/matieres-premieres/fr/" />
+<link rel="alternate" type="text/html" hreflang="fr" href="<?php echo $cfg["siteurl"]; ?>/home/1/fr/" />
 <link rel="canonical" href="<?php echo $cfg["siteurl"]; ?>" />
 <!--CSS-->
 
@@ -176,8 +176,8 @@ $site = new Site($db,$cfg);
 <script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>vendor/bootstrap/js/bootstrap.bundle.min.js?v=<?php echo $cfg["version"];?>" ></script>
 
 
-<script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>vendor/tabulator/js/tabulator.min.js?v={{ version }}"></script>
-<script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>vendor/moment/moment-with-locales.min.js?v={{ version }}"></script>
+<script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>vendor/tabulator/js/tabulator.min.js?v=<?php echo $cfg["version"];?>"></script>
+<script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>vendor/moment/moment-with-locales.min.js?v=<?php echo $cfg["version"];?>"></script>
 <script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>vendor/mustache/mustache.min.js?v=<?php echo $cfg["version"];?>" ></script> 
 <script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>js/publicrequest.js?v=<?php echo $cfg["version"];?>"></script>
 <script type="text/javascript" src="<?php echo $cfg["basepath"]; ?>js/askprice.js?v=<?php echo $cfg["version"];?>"></script>
index ea9025e..f77ca48 100644 (file)
@@ -5,11 +5,12 @@ let publicaskprice = {
   },
   loadTable: function(){
     postData({"ac":"getOrderItems","id_user":mysite.iduser,"type":"askprice","lang":preferences.lang}).then(ogrps => {
+      
       this.setTable(ogrps.data);
     });
   },
   setTable: function(odata){
-    //console.log("odata",odata);
+    //console.log("order table to fill!",odata);
     let bs = document.getElementById("lst_order_askprice");
     if (!bs){
       return false;
@@ -73,8 +74,8 @@ let publicaskprice = {
       cval = cval.replace(/,/,'.');
       cval = parseFloat(cval);
     }
-    console.log("RecalcValue",cval);
-    console.log("Send",{"ac":"setUserItem","article":obj.dataset.article,"quantity":cval,"id_user":mysite.iduser,"type":'askprice'});
+    //console.log("RecalcValue",cval);
+    //console.log("Send",{"ac":"setUserItem","article":obj.dataset.article,"quantity":cval,"id_user":mysite.iduser,"type":'askprice'});
     postData({"ac":"setUserItem","article":obj.dataset.article,"quantity":cval,"id_user":mysite.iduser,"type":'askprice'}).then(data => {
       //console.log("AC quRecalc returned",data);
     });
@@ -88,7 +89,7 @@ let publicaskprice = {
   },
   
   getItemCount: function(){
-    console.log("mysite",mysite);
+    //console.log("mysite",mysite);
     postData({"ac":"getOrderItemCount","id_user":mysite.iduser,"type":'askprice'}).then(data => {
       publicaskprice.itemscount = data.data.cnt;
       //console.log("Items",data.data);
index 8dccaf9..2ccbd25 100644 (file)
@@ -10,7 +10,7 @@ let shop = {
   },
   getCounterfield: function(labels,unit){
     labels.unshift('');
-    let stf = null;
+    let stf = null; 
 
     for (var l=1;l<=labels.length;l++){
       if (/^Carton/.test(labels[l])){ stf="c0"+l};
@@ -296,10 +296,11 @@ let shop = {
     });
   },
   initEvents(){
+    //console.log("init events now!");
     if (document.getElementById("searchtopnav")){
       //console.log("Shop SET search event!");
       document.getElementById("searchtopnav").addEventListener("keypress", function(event) {
-        console.log("Enter Search",event.keyCode)
+        //console.log("Enter Search",event.keyCode)
         //console.log("Keypress ",event.keyCode);
         if (event.keyCode === 13) {
           //console.log("Keypress ",event.keyCode);
index ffd03a1..051dba9 100644 (file)
@@ -61,10 +61,10 @@ class Orders {
       $ng[$grps[$g]["article_group"]] = $grps[$g];
       $ng[$grps[$g]["article_group"]]["articles"] = array();  
     }
-    $arsql ="select ar.id, UPPER(ar.article_group) as article_group, UPPER(ar.article) as article,oa.quantity, 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 , oa.comment
-    from articles ar left join article_prices ap on (ar.article = ap.article)
+    $arsql ="select ar.id, UPPER(ar.article_group) as article_group, UPPER(ar.article) as article,oa.quantity, ar.gp_art, ar.famille_art, ar.c01, ar.c02, ar.c03, ar.c04, ar.c05, 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 , oa.comment
+    from articles ar 
     join order_articles oa on (ar.article = oa.article and id_user='".$id_user."' and id_order is null and code_document='".$type."')
-    where ar.isactive=1 group by ar.article,ar.id,oa.quantity,oa.comment,ap.prix_net order by ar.article_group,ar.article;";
+    where ar.isactive=1 group by ar.article,ar.id,oa.quantity,oa.comment order by ar.article_group,ar.article;";
     $arts = $this->dbh->queryarray($arsql);
     for ($a=0;$a < count($arts);$a++){
       if (isset($ng[$arts[$a]["article_group"]])){
index 5eaf9ac..78c0726 100644 (file)
@@ -75,9 +75,9 @@ class Site{
       </div>
     </div>
     <div class="col d-md-none" style="margin-left: 10px;">
-      <div class="row bg-qube" style="width: 180px;">
+      <div class="row bg-qube" style="width: 176px;">
         <div class="col-12" style="margin: 0 auto; background-color: #fff;text-align: center;">
-        <img src="<?php  echo $imgfile ?>"  style="width: 170px;height: 170px;" alt="<?php echo $agr['article'];?>">
+        <img src="<?php  echo $imgfile ?>"  style="width: 166px;height: 166px;" alt="<?php echo $agr['article'];?>">
       </div>
       <div  class="col-12" style="min-height: 50px; padding:5px; text-align: center; font-size: 10pt;">
           <span class="text-white"><?php echo $agr["titre"]; ?></span>
index c7b6116..3a8df56 100644 (file)
@@ -1,5 +1,5 @@
 <?php 
-  $cfg["version"] = "1.6.12";
+  $cfg["version"] = "1.6.19";
   if ($cfg["debug"] == 1){
     $cfg["version"] = date('Ymdhis');
   }
index 87c236e..4797b54 100644 (file)
@@ -19,7 +19,7 @@ if (strlen($prod) > 1){
 }\r
 \r
 ?>\r
-  <nav class="navbar navbar-expand-lg bg-qube">\r
+<nav class="navbar navbar-expand-lg bg-qube">\r
   <div class="container-fluid">\r
   <a class="navbar-brand text-white" ><?php echo $lbl["products"]; ?></a> \r
   <div class="d-flex d-none d-sm-block text-white" id="articleresulthead"><?php if ($selfamille != null) {echo $selfamille." | ".$famname; }?> <?php if ($pgrp != null) {echo " - ".$pgrp." | ".$grpname; }?></div>\r
@@ -63,6 +63,7 @@ if (strlen($prod) > 1){
               $cla = "odd";\r
               $agrp = $ag->getPublishedGroups($lang);\r
               foreach ($agrp as $ax){\r
+                //file_put_contents("log/products.log",print_r($ax,true)."\n",FILE_APPEND);\r
                 if ($cla == "odd"){ $cla = "even";} else { $cla="odd"; }\r
                 if ($fam != $ax['famille_art']){\r
                   ?>\r
@@ -74,6 +75,7 @@ if (strlen($prod) > 1){
                   <?php\r
                   $fam = $ax['famille_art'];\r
                 }\r
+                //file_put_contents("log/products.log",$ax['famille_art'].'=='.$selfamille."\n",FILE_APPEND);\r
                 if (($ax['famille_art'] == $selfamille) && ($selfamille != null)) {\r
                   // onclick="mysite.reload('<?php echo $cfg["basepath"]."product/".$ax["famille_art"].'/'.$ax["gp_art"].'/'.$cfg["lang"]; ?  >/');"\r
                 ?>\r
@@ -181,6 +183,18 @@ if (strlen($prod) > 1){
       if ($pgrp == null){\r
         $agroups = $ag->getArticleGroupsByFamille($selfamille,$lang);\r
         $count=1;\r
+        ?>\r
+        <script>\r
+          let loadp = true;\r
+          function initpage(){\r
+            console.log("init events!");\r
+            shop.initEvents();\r
+            publicaskprice.init();\r
+            publicaskprice.getItemCount();\r
+            \r
+          }\r
+          </script>\r
+        <?php\r
       foreach($agroups as $agr) {\r
         $imgfile = $cfg["basepath"].'shop/img/qubenoimg.jpg';\r
         if (file_exists('shop/img/'.$agr['image'])) {\r
@@ -221,27 +235,23 @@ if (strlen($prod) > 1){
           $count++;\r
         }\r
         ?>\r
-        <script>\r
-          let loadp = true;\r
-          function initpage(){\r
-            publicaskprice.init();\r
-            publicaskprice.getItemCount();\r
-            shop.initEvents();\r
-          }\r
-          </script> <?php\r
+         <?php\r
       } else {\r
         \r
         $agroups = $ag->getArticleGroupsByFamilleAndGroup($selfamille,$pgrp,$lang);\r
         $dtype = 'askprice';\r
         if (isset($sess["id_user"])){\r
           $dtype = 'shop';\r
-        }\r
+        } \r
         \r
         ?>\r
         \r
         <script>\r
           let loadp = true;\r
+          \r
           function initpage(){\r
+            \r
+            shop.initEvents();\r
             let lst = document.getElementById("productdata");\r
             let col=1;\r
             postData({"ac":"getArticleGroups","groupcode":"<?php echo $pgrp; ?>","famillycode":"<?php echo $selfamille; ?>","lang":"<?php echo $lang; ?>"}).then(agrps => {\r