]> _ Git - fluidbook-html5.git/commitdiff
wait #1966 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 1 Mar 2018 15:41:27 +0000 (16:41 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 1 Mar 2018 15:41:27 +0000 (16:41 +0100)
js/libs/fluidbook/special/wescosales.js
style/special/wescosales.less

index 8037af5f1fac7710a5fe7b987f3203cd53cfd6da..2c6b7f9f178f36d844fcaecac84d136c58df277b 100644 (file)
@@ -17,7 +17,7 @@ function initWescoNav() {
         'left': $("header nav").outerWidth() + 20,
         position: "absolute"
     }).append(select);
-    $("#wescosalesselect").on('change', function () {
+    $(document).on('change', "#wescosalesselect", function () {
         $(".wescosaleswindow").each(function () {
             setWescoSalesPanel($(this).data('ref'), null, true);
         });
@@ -59,27 +59,50 @@ function setWescoSalesPanel(ref, e, updateOnly) {
     var w = '';
     w += '<a href="#" class="close"></a>';
     w += '<h2>' + r.title + '</h2>';
-    w += '<h3>' + rref.substr(0, 3) + ' ' + rref.substr(3, 3) + ' ' + rref.substr(6) + '</h3>';
+    if (rref.length == 9) {
+        w += '<h3>' + rref.substr(0, 3) + ' ' + rref.substr(3, 3) + ' ' + rref.substr(6) + '</h3>';
+    } else if (rref.length == 5) {
+        w += '<h3>' + rref.substr(0, 2) + ' ' + rref.substr(2) + '</h3>';
+    }
     w += '<hr />';
     if (!updateOnly) {
         $('body').append('<div id="' + id + '" class="wescosaleswindow" data-ref="' + ref + '"></div>');
     }
+
+    var seenNotFigure = false;
+
     w += '<table>';
+    w += '<tr><th></th><th>Qté</th><th>CA</th></tr>';
     for (var i in r.countries[activeCountry]) {
         var d = r.countries[activeCountry][i];
         if (d[1] === null) {
             continue;
         }
-        w += '<tr>';
-        w += '<td class="d">' + d[0] + '</td>';
-        w += '<td class="v">' + d[1] + '</td>';
+
+        if (d[2] == null) {
+            var cl = '';
+            if (!seenNotFigure) {
+                w += '<tr class="hr"><td colspan="3"><hr /></td></tr>';
+                seenNotFigure = true;
+            }
+            w += '<tr>';
+            w += '<td class="d">' + d[0] + '</td>';
+            w += '<td class="v" colspan="2">' + d[1] + '</td>';
+        } else {
+            w += '<tr>';
+            w += '<td class="d">' + d[0] + '</td>';
+            w += '<td class="v">' + d[1] + '</td>';
+            w += '<td class="c">' + d[2] + '</td>';
+        }
         w + '</tr>';
     }
     w += '<table>';
     $('#' + id).html(w);
-    var x = e.pageX - 150;
-    var y = e.pageY - $("#" + id).outerHeight() / 2;
-    $("#" + id).css({left: x, top: y}).data({x: x, y: y});
+    if (e != null) {
+        var x = e.pageX - 150;
+        var y = e.pageY - $("#" + id).outerHeight() / 2;
+        $("#" + id).css({left: x, top: y}).data({x: x, y: y});
+    }
 
     setInteractPanel(ref, updateOnly);
 }
@@ -157,11 +180,10 @@ function wescoLinksReady() {
 }
 
 function getWescoRef(ref) {
-    ref = ref.toString().substr(4);
+    ref = ref.toString().substr(ref.toString().length - 5);
     if (wsref[ref] === undefined) {
         var res = {countries: {}, del: ''};
         for (var country in DATAS.basketReferences) {
-
             var sheet = DATAS.basketReferences[country];
             var line0 = sheet[0];
             var l = line0.length;
@@ -179,13 +201,23 @@ function getWescoRef(ref) {
                         continue;
                     }
 
-                    d.push([line0[i], line[i]]);
+                    var ca = null;
+                    var hasCA = false;
+                    if (line0[i + 1] != undefined && line0[i + 1].toString().indexOf('CA ' + line0[i]) != -1) {
+                        ca = Math.round(parseFloat(line[i + 1])).toString();
+                        hasCA = true;
+                    }
+                    d.push([line0[i], line[i], ca]);
+
                     if (String(line0[i]).toLocaleLowerCase().indexOf('supp') >= 0 && line[i] !== null && String(line[i]) != '') {
                         res.del = line[i];
                     }
                     if (String(line0[i]).toLocaleLowerCase().indexOf('export') >= 0 && line[i] !== null && String(line[i]) != '') {
                         res.export = line[i];
                     }
+                    if (hasCA) {
+                        i++;
+                    }
                 }
                 res.countries[country] = d;
                 res.title = line[1];
index 40771a9755bf8084b597ca342f8b8aab7db6e573..43075b25a0b9490b8270b7de12fe899139f8a00c 100644 (file)
        table {
                width: 100%;
                font-size: 13px;
+               border-collapse: collapse;
+               tr.hr td {
+                       height: 15px;
+                       hr{
+                               bottom: 0;
+                               height: 1px;
+                               background: #fff;
+                               width: 100%;
+                       }
+               }
                td {
-                       margin: 2px 0;
+                       margin: 0px 0;
+               }
+               th {
+                       text-align: right;
+                       padding: 0 15px;
                }
                .v {
                        text-align: right;
                        white-space: nowrap;
                        width: 1px;
+                       padding: 0 15px;
+               }
+               .c {
+                       text-align: right;
+                       white-space: nowrap;
+                       width: 1px;
+                       border-left: 1px solid #fff;
+                       padding: 0 15px;
                }
        }
 }