mise à jour stickers
This commit is contained in:
parent
318bffc203
commit
1a63ef9f44
@ -286,6 +286,9 @@ GEM
|
||||
mime-types (>= 1.16, < 4.0)
|
||||
netrc (~> 0.8)
|
||||
rmagick (4.0.0)
|
||||
roo (2.8.2)
|
||||
nokogiri (~> 1)
|
||||
rubyzip (>= 1.2.1, < 2.0.0)
|
||||
ruby-vips (2.0.17)
|
||||
ffi (~> 1.9)
|
||||
ruby_dep (1.5.0)
|
||||
@ -409,6 +412,7 @@ DEPENDENCIES
|
||||
rails (= 6.0.3)
|
||||
rails_autolink
|
||||
rmagick
|
||||
roo
|
||||
sass-rails (~> 5)
|
||||
searchkick
|
||||
selenium-webdriver
|
||||
|
@ -670,6 +670,30 @@ class Admin::PCustomersController < ApplicationController
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def update_stickers
|
||||
|
||||
if params[:file]
|
||||
data = Roo::Spreadsheet.open(params[:file].tempfile.path, extension: :xlsx) # open spreadsheet
|
||||
headers = data.row(1) # get header row
|
||||
@data = []
|
||||
data.each_with_index do |row, idx|
|
||||
next if idx == 0 # skip header
|
||||
# create hash from headers and cells
|
||||
user_data = Hash[[headers, row].transpose]
|
||||
@data << user_data
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
34
app/views/admin/p_customers/update_stickers.html.haml
Normal file
34
app/views/admin/p_customers/update_stickers.html.haml
Normal file
@ -0,0 +1,34 @@
|
||||
.qi_row
|
||||
.qi_pannel.qi_plain.padding
|
||||
|
||||
=form_tag "", multipart: true do
|
||||
=file_field_tag :file
|
||||
%br
|
||||
=submit_tag "Mettre à jour les stickers", :class => "btn btn-primary"
|
||||
|
||||
|
||||
-if @data
|
||||
|
||||
%table.table
|
||||
-@data.each do |d|
|
||||
%tr
|
||||
%td
|
||||
=d["Nom"]
|
||||
%td
|
||||
=d["Prénom"]
|
||||
|
||||
-if p_customers = PCustomer.where("cc_particular_name = ? and cc_particular_firstname = ?", d["Nom"],d["Prénom"]) and p_customers.count == 1 and p_customer = p_customers.first
|
||||
%td
|
||||
=p_customer.cc_particular_name
|
||||
%td
|
||||
=p_customer.cc_particular_firstname
|
||||
-p_customer.sticker = true
|
||||
-p_customer.save
|
||||
|
||||
-else
|
||||
%td{:style => "color:red;font-weight:bold;"}
|
||||
=ic(:warning)
|
||||
Utilisateur introuvable
|
||||
|
||||
%td
|
||||
|
@ -871,7 +871,8 @@ Rails.application.routes.draw do
|
||||
get :autocomplete
|
||||
get :import
|
||||
get :import_cat
|
||||
|
||||
get :update_stickers
|
||||
post :update_stickers
|
||||
get :import3
|
||||
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user