From a9eb6eb61bcbe4bd38f3ab217d6dd5b869895a8a Mon Sep 17 00:00:00 2001
From: Juliana <juliana@le-filament.com>
Date: Tue, 18 Jan 2022 12:31:02 +0100
Subject: [PATCH] Clear code

---
 static/src/css/style.css   |  4 +-
 static/src/js/container.js | 46 ++------------------
 static/src/xml/pos.xml     | 88 ++------------------------------------
 3 files changed, 8 insertions(+), 130 deletions(-)

diff --git a/static/src/css/style.css b/static/src/css/style.css
index 1e3f6dc..9de6061 100644
--- a/static/src/css/style.css
+++ b/static/src/css/style.css
@@ -125,7 +125,7 @@
 }
 
 .pos .printsqr-screen .bypass-container,
-.pos .balancecontainerqr-screen .add-container,
+.pos .balancecontainerqr-screen .print-qrcode,
 .pos .scale-screen-custo .add-transaction{
     margin: 0 auto;
     text-align: center;
@@ -158,7 +158,7 @@
     width: 300px;
 }
 
-.pos .balancecontainerqr-screen .add-container{
+.pos .balancecontainerqr-screen .print-qrcode{
     width: 250px;
     margin: 40px auto;
 }
diff --git a/static/src/js/container.js b/static/src/js/container.js
index 4bcad53..463ff70 100644
--- a/static/src/js/container.js
+++ b/static/src/js/container.js
@@ -48,13 +48,11 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
                 return self.pos.proxy.scale_read_data_price(priceStr).then(function (scale_answer) {
                     self.set_weight(scale_answer.weight);
                     if ((scale_answer.error === '30' || scale_answer.error === '31') && scale_answer.weight !== 0) {
-//                        self.render_receipt();
-//                        self.handle_auto_print();
-//                        self.renderElement();
                         self.set_weight(0);
                     }
                 });
             }, {duration: 500, repeat: true});
+            
             this._super();
 
             var self = this;
@@ -66,13 +64,6 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
             $("#pos-header-text-peser").removeClass('oe_hidden');
             $("#pos-topheader-scale-cont").removeClass('oe_hidden');
 
-            setTimeout(function(){
-                if (this..weight !== 0) {
-                    self.print();
-                }
-            }, 2000);
-
-            this.render_receipt();
         },
 
         hide: function(){
@@ -108,6 +99,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
             var timestamp = Math.floor((new Date().getTime())/1000);
 
             var weight_str = (this.weight * 1000).toString();
+            var weight_str = (0.2 * 1000).toString();
             weight_str = ("0000" + weight_str).slice(-4);
 
             var ean19 = '';
@@ -118,42 +110,10 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
             var code_base36 = ean20_int.toString(36);
 
             var url_qrcode = url_qr.concat(code_base36);
-            //var logo = this.pos.company_logo_base64;
-            //var url_barcode = window.location.origin + "/report/barcode/?type=EAN13&value=0492525252525&width=300&height=80"
-            
-//          ****************************************
-//          Impression barcode
-            var barcode = new Image();
-            barcode.crossOrigin = "anonymous";
-            var barcode_base64 = window.location.origin + "/report/barcode/?type=EAN13&value=0492525252525&width=300&height=80"
-            //barcode.src = window.location.origin + "/report/barcode/?type=QR&value=" + url_qrcode + "&width=200&height=200"
-            // var img = barcode;
-            // var ratio = 1;
-            // var targetwidth = 200;
-            // var maxheight = 200;
-            // if( img.width !== targetwidth ){
-            //     ratio = targetwidth / img.width;
-            // }
-            // if( img.height * ratio > maxheight ){
-            //     ratio = maxheight / img.height;
-            // }
-            // var width  = Math.floor(img.width * ratio);
-            // var height = Math.floor(img.height * ratio);
-            // var c = document.createElement('canvas');
-            // c.width  = width;
-            // c.height = height;
-            // var ctx = c.getContext('2d');
-            // ctx.drawImage(barcode,0,0, width, height);
-
-            // var barcode_base64 = c.toDataURL('image/png');
-            // Fin impression barcode
-            // **************************************
             
             return {    
                 widget: this,
                 weight: this.weight,
-                url_qrcode: url_qrcode,
-                id_container: code_base36,
                 url_barcode: url_qrcode,
             }
        
@@ -205,7 +165,7 @@ odoo.define('vracoop_pos_container_qrcode.container_print_qr', function (require
             var self = this;
             this._super();
             
-            this.$('.next,.add-container').click(function(){
+            this.$('.next,.print-qrcode').click(function(){
                 self.print();
             });
         },
diff --git a/static/src/xml/pos.xml b/static/src/xml/pos.xml
index 85d803b..cc8926f 100644
--- a/static/src/xml/pos.xml
+++ b/static/src/xml/pos.xml
@@ -5,8 +5,6 @@
         <t t-jquery='.pos-topheader' t-operation='after'>
             <div class="pos-topheader-title">
                 <span class="close-button-bls">close</span>
-                <!-- <span class="placeholder-ShopnameWidget"></span>
-                <span class="placeholder-ShopimageWidget"></span> -->
             </div>
         </t>
     </t>
@@ -32,18 +30,11 @@
         <div class="balancecontainerqr-screen screen">
             <div class="pos-bottom">
                 <div class="pos-confirm" id="validation-bloc-cont">
-                    <h1 class='product-name'>Poser votre contenant sur la balance puis enregistrer</h1>
-                    <div class='add-container'>
+                    <h1 class='product-name'>Poser votre contenant sur la balance pour impression</h1>
+                    <div class='print-qrcode'>
                         Imprimer QR Code
                     </div>
                 </div>
-                <div class="touch-scrollable">
-                    <div class="button print">
-                        <i class='fa fa-print'></i> Imprimer QR Code
-                    </div>
-                    <div class="pos-qr-container">
-                    </div>
-                </div>
 
                 <div class="centered-content-flex">
                     <div class="flex-poids">
@@ -80,61 +71,12 @@
         </div>
     </t>
 
-    <!-- OLD CODE -->
-    <!-- <t t-name="PosQR">
-        <div class="pos-sale-ticket">
-            <div class="pos-center-align">
-                <img t-att-src="widget.pos.company_logo_base64"/><br />
-                <div class='receipt-total'>
-                    <div>
-                        <t t-esc="id_container"/>
-                    </div>
-                    <div class="pos-right-align">
-                        <t t-esc="weight"/>
-                    </div>
-                </div>
-                
-                <div>
-                    <p>l'image se trouve la</p>
-                    <img t-att-src="url_barcode" style="width:100%;height:35%;" />
-                </div>
-
-            </div>
-            <div class="einv-qr">
-                <div t-attf-id="qrcode_container">
-                    <div id="qrcode"></div>
-
-                    <script type="text/javascript">
-                        var qr_data ="<t t-esc="url_qrcode"/>";
-
-                        var qrcode = new QRCode('qrcode' , {
-                        text: qr_data,
-                        width: 160,
-                        height: 160,
-                        colorDark : "#000000",
-                        colorLight : "#ffffff",
-                        correctLevel : QRCode.CorrectLevel.H
-                        });
-                        qrcode.makeCode(qr_data);
-
-                    </script>
-
-                </div>
-            </div>
-            
-        </div>
-    </t> -->
-    <!-- OLD CODE -->
-
     <!-- NEW CODE -->
     <t t-name="PosQR">
         <div class="pos-sale-ticket">
             <div class="pos-center-align">
                 <img t-att-src="widget.pos.company_logo_base64"/><br />
                 <div class='receipt-total'>
-                    <div>
-                        <t t-esc="id_container"/>
-                    </div>
                     <div class="pos-right-align">
                         <t t-esc="weight"/>
                     </div>
@@ -157,34 +99,10 @@
 
         ^FX Third section with bar code.
         ^BY3,2,10
-        ^FO60,10^BQ,2,3,H,7^FDQA,<t t-esc='url_barcode'/>^FS
+        ^FO60,20^BQ,2,4,H,7^FDQA,<t t-esc='url_barcode'/>^FS
 
         ^XZ
     </receipt>
-        <!-- <receipt align='center' width='40' value-thousands-separator='' >
-            <div class="pos-sale-ticket">
-                <div class="pos-center-align">
-                    <img t-att-src="widget.pos.company_logo_base64"/><br />
-                    
-                </div>
-                
-                <div>
-                    <p>l'image se trouve la</p>
-                
-                    <img t-att-src="url_barcode" />
-                </div>
-                <div class='receipt-total'>
-                    <h1>TEST</h1>
-                    <div>
-                        <t t-esc="id_container"/>
-                    </div>
-                    <div class="pos-right-align">
-                        <t t-esc="weight"/>
-                    </div>
-                </div>
-            </div>
-
-        </receipt> -->
     </t>
 
 </templates>
-- 
GitLab