Kaynağa Gözat

changes in labels pdf

chemi ledon 7 yıl önce
ebeveyn
işleme
66d23a014c

+ 1 - 1
app/helpers/application_helper.rb

@@ -8,7 +8,7 @@ module ApplicationHelper
     end
   end
 
-  def wicked_pdf_barcode_image(img, options={})
+  def wicked_pdf_barcode_image(img, options)
     image_tag "file://#{Rails.root.join('public', 'barcodes', img)}", options
   end
 end

+ 4 - 1
app/models/product.rb

@@ -302,6 +302,7 @@ class Product < ActiveRecord::Base
         attributes_json = variant.assign_attributes_to_variant(variant.style_list, id, attributes_json) unless variant.style_list.count.zero?
         variant.attributes_json = attributes_json.to_json
         variant.save(validate: false)
+
       end
     end
   end
@@ -361,6 +362,8 @@ class Product < ActiveRecord::Base
         end
         @products_variant.attributes_json = attributes.to_json
         @products_variant.save(validate: false)
+        @products_variant.generate_barcode
+        @products_variant.save(validate: false)
       end
     end
   end
@@ -439,7 +442,7 @@ class Product < ActiveRecord::Base
       self.barcode = barcode_generated
       save_path = Rails.public_path.join('barcodes', "#{barcode_generated}.png")
       File.open(save_path, 'wb'){ |f|
-        f.write Barby::Code39.new(barcode_generated).to_png(:height => 30, :margin => 5)
+        f.write Barby::Code39.new(barcode_generated).to_png(:height => 50, :margin => 5)
       }
     end
   end

+ 2 - 2
app/views/layouts/labels.html.erb

@@ -10,10 +10,10 @@
         }
       }
       body {
-        width: 58mm;
+        width: 60mm;
         height: auto;
         font-family: 'OpenSansRegular';
-        font-size: 11px;
+        font-size: 12px;
       }
       .text-center {
         text-align: center;

+ 25 - 4
app/views/products/print_labels.pdf.erb

@@ -1,10 +1,31 @@
+<style>
+    .column {
+        float: left;
+    }
+
+    .left {
+        width: 70%;
+        font-size: 10px;
+        min-height:5px;
+    }
+
+    .right {
+        width: 30%;
+        font-size: 12px;
+        font-weight: bold;
+    }
+</style>
 <div class='pdf-body'>
     <% @products.each do |obj| %>
         <% (1..obj['print']).each do |i| %>
-            <span><%= obj['product'].name %></span>
-            <%= wicked_pdf_barcode_image("#{obj['product'].barcode}.png", options = { width: 58, height: 50 }) %>
-            <span><%= obj['product'].display_attributes %></span>
-            <span><%= obj['price'] %></span>
+            <div class="text-center"><%= wicked_pdf_barcode_image("#{obj['product'].barcode}.png", options = { width: 150, height: 50 }) %></div>
+            <p style="margin:0px"><%= obj['product'].name %></p>
+            <div class="row">
+                <div class="column left"><%= obj['product'].display_attributes %></div>
+                <div class="column right"><%= number_to_currency(obj['price'], precision: 2) %></div>
+            </div>
+            <br>
+            <br>
         <% end %>
     <% end %>
 </div>