def csv_download
get_search_form
csv_data, filename = Order.csv(@search_list)
- send_data(csv_data, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
+ send_data(csv_data.tosjis, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
end
private
@search_list = []
get_search_form
csv_data, filename = Product.csv(@search_list)
- send_data(csv_data, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
+ send_data(csv_data.tosjis, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
end
def csv_upload
@search_list = []
get_search_form
csv_data, filename = Product.actual_count_list_csv(@search_list)
- send_data(csv_data, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
+ send_data(csv_data.tosjis, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
end
protected
title = %w(商品ID 商品コード 商品名 規格名称 商品型番 返品数 返品日時)
csv_data = CSVUtil.make_csv_string(rows, title)
- send_data(csv_data, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
+ send_data(csv_data.tosjis, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
end
filename = '%s.csv' % name
title = %w(商品コード 商品名 仕入先名 実在庫数 不良在庫数)
csv_data = CSVUtil.make_csv_string(rows, title)
- send_data(csv_data, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
+ send_data(csv_data.tosjis, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
end
private
def csv
totalizer = Object.const_get("#{params[:page]}_totalizer".classify)
csv_data, filename = totalizer.csv(params)
- send_data(csv_data, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
+ send_data(csv_data.tosjis, :type => "application/octet-stream; name=#{filename}; charset=shift_jis; header=present",:disposition => 'attachment', :filename => filename)
end
end
end
end
filename = "order_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv"
- [str.tosjis, filename]
+ [str, filename]
end
private
end
end
filename = "product_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv"
- [str.tosjis, filename]
+ [str, filename]
end
def self.actual_count_list_csv(search_list)
end
end
filename = "actual_count_list_#{Time.now.strftime('%Y%m%d%H%M%S')}.csv"
- [str.tosjis, filename]
+ [str, filename]
end
def master_shop?
end
end
filename = "#{csv_output_setting_name}#{Time.now.strftime('%Y%m%d%H%M%S')}.csv"
- [str.tosjis, filename]
+ [str, filename]
end
private
return pairs
end
- def make_csv_string(rows, title)
- # date = DateTime.now
- # CSV に吐く
- str = CSV.generate("") do |writer|
- writer << title
- rows.each do |row|
- writer << row
- end
+ def make_csv_string(rows, header)
+ CSV.generate do |writer|
+ writer << header
+ rows.each {|row| writer << row }
end
- return str.tosjis
end
-
end
end