suite
This commit is contained in:
parent
011d04ed5c
commit
bfd2801043
15
Gemfile
15
Gemfile
@ -1,9 +1,8 @@
|
||||
source 'http://rubygems.org'
|
||||
|
||||
|
||||
gem 'rails', '4.2.6'
|
||||
|
||||
gem "mysql2"
|
||||
gem "mysql2", '~> 0.3.18'
|
||||
|
||||
gem 'sass-rails', '5.0.3'
|
||||
|
||||
@ -63,7 +62,7 @@ gem 'gravatar_image_tag'
|
||||
|
||||
#gem 'country_select'
|
||||
|
||||
gem 'roo', '~> 2.1.0'
|
||||
gem 'roo', '~> 2.8.2'
|
||||
gem 'roo-xls'
|
||||
|
||||
gem 'curb'
|
||||
@ -84,11 +83,17 @@ gem "nokogiri"
|
||||
gem 'elasticsearch-model'
|
||||
gem 'elasticsearch-rails'
|
||||
|
||||
gem 'twitter-text'
|
||||
#gem 'twitter-text'
|
||||
|
||||
gem 'pygments.rb'
|
||||
gem 'redcarpet'
|
||||
|
||||
gem 'omniauth-facebook'
|
||||
|
||||
gem 'truncate_html'
|
||||
gem 'truncate_html'
|
||||
|
||||
gem 'axlsx', '3.0.0.pre'
|
||||
gem 'axlsx_rails'
|
||||
|
||||
|
||||
gem 'zip-zip'
|
333
Gemfile.lock
333
Gemfile.lock
@ -37,153 +37,173 @@ GEM
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
acts_as_commentable (4.0.2)
|
||||
acts_as_tree (2.1.0)
|
||||
acts_as_tree (2.9.0)
|
||||
activerecord (>= 3.0.0)
|
||||
addressable (2.4.0)
|
||||
arel (6.0.3)
|
||||
bcrypt (3.1.10)
|
||||
binding_of_caller (0.7.2)
|
||||
arel (6.0.4)
|
||||
axlsx (3.0.0.pre)
|
||||
htmlentities (~> 4.3, >= 4.3.4)
|
||||
mimemagic (~> 0.3)
|
||||
nokogiri (~> 1.8, >= 1.8.2)
|
||||
rubyzip (~> 1.2, >= 1.2.1)
|
||||
axlsx_rails (0.5.2)
|
||||
actionpack (>= 3.1)
|
||||
axlsx (>= 2.0.1)
|
||||
bcrypt (3.1.13)
|
||||
binding_of_caller (0.8.0)
|
||||
debug_inspector (>= 0.0.1)
|
||||
builder (3.2.2)
|
||||
byebug (3.5.1)
|
||||
columnize (~> 0.8)
|
||||
debugger-linecache (~> 1.2)
|
||||
slop (~> 3.6)
|
||||
builder (3.2.3)
|
||||
byebug (11.0.1)
|
||||
capistrano (2.15.9)
|
||||
highline
|
||||
net-scp (>= 1.0.0)
|
||||
net-sftp (>= 2.0.0)
|
||||
net-ssh (>= 2.0.14)
|
||||
net-ssh-gateway (>= 1.1.0)
|
||||
carrierwave (0.10.0)
|
||||
activemodel (>= 3.2.0)
|
||||
activesupport (>= 3.2.0)
|
||||
json (>= 1.7)
|
||||
carrierwave (1.3.1)
|
||||
activemodel (>= 4.0.0)
|
||||
activesupport (>= 4.0.0)
|
||||
mime-types (>= 1.16)
|
||||
coffee-rails (4.1.0)
|
||||
coffee-rails (4.1.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
coffee-script (2.3.0)
|
||||
railties (>= 4.0.0, < 5.1.x)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.9.1)
|
||||
columnize (0.9.0)
|
||||
concurrent-ruby (1.0.2)
|
||||
countries (1.2.2)
|
||||
currencies (~> 0.4.2)
|
||||
i18n_data (~> 0.7.0)
|
||||
country_select (2.5.1)
|
||||
countries (~> 1.2.0)
|
||||
coffee-script-source (1.12.2)
|
||||
commonjs (0.2.7)
|
||||
concurrent-ruby (1.1.5)
|
||||
countries (3.0.0)
|
||||
i18n_data (~> 0.8.0)
|
||||
sixarm_ruby_unaccent (~> 1.1)
|
||||
unicode_utils (~> 1.4)
|
||||
country_select (4.0.0)
|
||||
countries (~> 3.0)
|
||||
sort_alphabetical (~> 1.0)
|
||||
curb (0.8.8)
|
||||
currencies (0.4.2)
|
||||
debug_inspector (0.0.2)
|
||||
debugger-linecache (1.2.0)
|
||||
elasticsearch (1.0.15)
|
||||
elasticsearch-api (= 1.0.15)
|
||||
elasticsearch-transport (= 1.0.15)
|
||||
elasticsearch-api (1.0.15)
|
||||
crass (1.0.4)
|
||||
curb (0.9.10)
|
||||
debug_inspector (0.0.3)
|
||||
elasticsearch (7.1.0)
|
||||
elasticsearch-api (= 7.1.0)
|
||||
elasticsearch-transport (= 7.1.0)
|
||||
elasticsearch-api (7.1.0)
|
||||
multi_json
|
||||
elasticsearch-model (0.1.8)
|
||||
elasticsearch-model (6.0.0)
|
||||
activesupport (> 3)
|
||||
elasticsearch (> 0.4)
|
||||
elasticsearch (> 1)
|
||||
hashie
|
||||
elasticsearch-rails (0.1.8)
|
||||
elasticsearch-transport (1.0.15)
|
||||
elasticsearch-rails (6.0.0)
|
||||
elasticsearch-transport (7.1.0)
|
||||
faraday
|
||||
multi_json
|
||||
erubis (2.7.0)
|
||||
execjs (2.3.0)
|
||||
faraday (0.12.1)
|
||||
execjs (2.7.0)
|
||||
faraday (0.15.4)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
fastimage (1.8.1)
|
||||
addressable (~> 2.3, >= 2.3.5)
|
||||
fastimage (2.1.5)
|
||||
ffi (1.11.1)
|
||||
formtastic (2.3.0)
|
||||
actionpack (>= 3.0)
|
||||
formtastic-bootstrap (3.0.0)
|
||||
formtastic (>= 2.2)
|
||||
geocoder (1.2.9)
|
||||
globalid (0.3.6)
|
||||
activesupport (>= 4.1.0)
|
||||
geocoder (1.5.1)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
gravatar_image_tag (1.2.0)
|
||||
haml (4.0.6)
|
||||
haml (5.1.1)
|
||||
temple (>= 0.8.0)
|
||||
tilt
|
||||
haml-rails (0.8.2)
|
||||
haml-rails (1.0.0)
|
||||
actionpack (>= 4.0.1)
|
||||
activesupport (>= 4.0.1)
|
||||
haml (>= 3.1, < 5.0)
|
||||
haml (>= 4.0.6, < 6.0)
|
||||
html2haml (>= 1.0.1)
|
||||
railties (>= 4.0.1)
|
||||
hashie (3.5.5)
|
||||
highline (1.7.8)
|
||||
html2haml (2.0.0)
|
||||
hashie (3.6.0)
|
||||
highline (2.0.2)
|
||||
html2haml (2.2.0)
|
||||
erubis (~> 2.7.0)
|
||||
haml (~> 4.0.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
haml (>= 4.0, < 6)
|
||||
nokogiri (>= 1.6.0)
|
||||
ruby_parser (~> 3.5)
|
||||
i18n (0.7.0)
|
||||
i18n_data (0.7.0)
|
||||
htmlentities (4.3.4)
|
||||
i18n (0.9.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n_data (0.8.0)
|
||||
iban-tools (1.1.0)
|
||||
jbuilder (2.2.8)
|
||||
activesupport (>= 3.0.0, < 5)
|
||||
multi_json (~> 1.2)
|
||||
jquery-rails (4.0.3)
|
||||
rails-dom-testing (~> 1.0)
|
||||
jbuilder (2.9.1)
|
||||
activesupport (>= 4.2.0)
|
||||
jquery-rails (4.3.5)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.3)
|
||||
jwt (1.5.6)
|
||||
kaminari (0.16.3)
|
||||
actionpack (>= 3.0.0)
|
||||
activesupport (>= 3.0.0)
|
||||
json (1.8.6)
|
||||
jwt (2.2.1)
|
||||
kaminari (1.1.1)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.1.1)
|
||||
kaminari-activerecord (= 1.1.1)
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-actionview (1.1.1)
|
||||
actionview
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-activerecord (1.1.1)
|
||||
activerecord
|
||||
kaminari-core (= 1.1.1)
|
||||
kaminari-bootstrap (3.0.1)
|
||||
kaminari (>= 0.13.0)
|
||||
rails
|
||||
kgio (2.9.3)
|
||||
kaminari-core (1.1.1)
|
||||
kgio (2.11.2)
|
||||
less (2.6.0)
|
||||
commonjs (~> 0.2.7)
|
||||
less-rails (4.0.0)
|
||||
actionpack (>= 4)
|
||||
less (~> 2.6.0)
|
||||
sprockets (>= 2)
|
||||
libv8 (3.16.14.19)
|
||||
loofah (2.0.3)
|
||||
loofah (2.2.3)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
mime-types (3.1)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
mime-types (3.2.2)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.9.0)
|
||||
multi_json (1.12.1)
|
||||
mime-types-data (3.2019.0331)
|
||||
mimemagic (0.3.3)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.11.3)
|
||||
multi_json (1.13.1)
|
||||
multi_xml (0.6.0)
|
||||
multipart-post (2.0.0)
|
||||
mysql2 (0.3.18)
|
||||
net-scp (1.2.1)
|
||||
net-ssh (>= 2.6.5)
|
||||
multipart-post (2.1.1)
|
||||
mysql2 (0.3.21)
|
||||
net-scp (2.0.0)
|
||||
net-ssh (>= 2.6.5, < 6.0.0)
|
||||
net-sftp (2.1.2)
|
||||
net-ssh (>= 2.6.5)
|
||||
net-ssh (2.7.0)
|
||||
net-ssh-gateway (1.2.0)
|
||||
net-ssh-gateway (1.3.0)
|
||||
net-ssh (>= 2.6.5)
|
||||
nokogiri (1.6.8)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
pkg-config (~> 1.1.7)
|
||||
oauth2 (1.4.0)
|
||||
faraday (>= 0.8, < 0.13)
|
||||
jwt (~> 1.0)
|
||||
nokogiri (1.10.3)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
oauth2 (1.4.1)
|
||||
faraday (>= 0.8, < 0.16.0)
|
||||
jwt (>= 1.0, < 3.0)
|
||||
multi_json (~> 1.3)
|
||||
multi_xml (~> 0.5)
|
||||
rack (>= 1.2, < 3)
|
||||
omniauth (1.6.1)
|
||||
hashie (>= 3.4.6, < 3.6.0)
|
||||
omniauth (1.9.0)
|
||||
hashie (>= 3.4.6, < 3.7.0)
|
||||
rack (>= 1.6.2, < 3)
|
||||
omniauth-facebook (4.0.0)
|
||||
omniauth-facebook (5.0.0)
|
||||
omniauth-oauth2 (~> 1.2)
|
||||
omniauth-oauth2 (1.4.0)
|
||||
oauth2 (~> 1.0)
|
||||
omniauth (~> 1.2)
|
||||
pkg-config (1.1.7)
|
||||
posix-spawn (0.3.11)
|
||||
pygments.rb (0.6.3)
|
||||
posix-spawn (~> 0.3.6)
|
||||
yajl-ruby (~> 1.2.0)
|
||||
rack (1.6.8)
|
||||
omniauth-oauth2 (1.6.0)
|
||||
oauth2 (~> 1.1)
|
||||
omniauth (~> 1.9)
|
||||
posix-spawn (0.3.13)
|
||||
pygments.rb (1.2.1)
|
||||
multi_json (>= 1.0.0)
|
||||
rack (1.6.11)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.2.6)
|
||||
@ -199,98 +219,101 @@ GEM
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.7)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-dom-testing (1.0.9)
|
||||
activesupport (>= 4.2.0, < 5.0)
|
||||
nokogiri (~> 1.6)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (4.2.6)
|
||||
actionpack (= 4.2.6)
|
||||
activesupport (= 4.2.6)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
raindrops (0.13.0)
|
||||
rake (11.2.2)
|
||||
rdoc (4.2.0)
|
||||
json (~> 1.4)
|
||||
redcarpet (3.3.4)
|
||||
raindrops (0.19.0)
|
||||
rake (12.3.2)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
rdoc (4.3.0)
|
||||
redcarpet (3.4.0)
|
||||
ref (2.0.0)
|
||||
rmagick (2.13.4)
|
||||
roo (2.1.1)
|
||||
rmagick (3.1.0)
|
||||
roo (2.8.2)
|
||||
nokogiri (~> 1)
|
||||
rubyzip (~> 1.1, < 2.0.0)
|
||||
roo-xls (1.0.0)
|
||||
rubyzip (>= 1.2.1, < 2.0.0)
|
||||
roo-xls (1.2.0)
|
||||
nokogiri
|
||||
roo (>= 2.0.0beta1, < 3)
|
||||
roo (>= 2.0.0, < 3)
|
||||
spreadsheet (> 0.9.0)
|
||||
ruby-ole (1.2.11.8)
|
||||
ruby_parser (3.6.4)
|
||||
sexp_processor (~> 4.1)
|
||||
rubyzip (1.1.7)
|
||||
ruby-ole (1.2.12.2)
|
||||
ruby_parser (3.13.1)
|
||||
sexp_processor (~> 4.9)
|
||||
rubyzip (1.2.3)
|
||||
rvm-capistrano (1.4.1)
|
||||
capistrano (>= 2.0.0)
|
||||
sass (3.4.22)
|
||||
sass (3.7.4)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sass-rails (5.0.3)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (~> 1.1)
|
||||
sdoc (0.4.1)
|
||||
sdoc (0.4.2)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
rdoc (~> 4.0)
|
||||
sexp_processor (4.4.5)
|
||||
slop (3.6.0)
|
||||
sort_alphabetical (1.0.2)
|
||||
sexp_processor (4.12.1)
|
||||
sixarm_ruby_unaccent (1.2.0)
|
||||
sort_alphabetical (1.1.0)
|
||||
unicode_utils (>= 1.2.2)
|
||||
spreadsheet (1.0.9)
|
||||
spreadsheet (1.2.4)
|
||||
ruby-ole (>= 1.0)
|
||||
spring (1.3.2)
|
||||
sprockets (3.6.2)
|
||||
spring (2.0.2)
|
||||
activesupport (>= 4.2)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.0.4)
|
||||
sprockets-rails (3.2.1)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
temple (0.8.1)
|
||||
therubyracer (0.12.3)
|
||||
libv8 (~> 3.16.14.15)
|
||||
ref
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
tilt (1.4.1)
|
||||
truncate_html (0.9.3)
|
||||
turbolinks (2.5.3)
|
||||
coffee-rails
|
||||
twitter-bootstrap-rails (3.2.0)
|
||||
actionpack (~> 4.1)
|
||||
execjs (~> 2.2)
|
||||
rails (~> 4.1)
|
||||
railties (~> 4.1)
|
||||
twitter-text (1.13.4)
|
||||
unf (~> 0.1.0)
|
||||
tzinfo (1.2.2)
|
||||
turbolinks (5.2.0)
|
||||
turbolinks-source (~> 5.2)
|
||||
turbolinks-source (5.2.0)
|
||||
twitter-bootstrap-rails (3.2.2)
|
||||
actionpack (>= 3.1)
|
||||
execjs (>= 2.2.2, >= 2.2)
|
||||
less-rails (>= 2.5.0)
|
||||
railties (>= 3.1)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (2.7.0)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.2)
|
||||
uglifier (4.1.20)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unicode_utils (1.4.0)
|
||||
unicorn (4.8.3)
|
||||
unicorn (5.5.1)
|
||||
kgio (~> 2.6)
|
||||
rack
|
||||
raindrops (~> 0.7)
|
||||
web-console (2.0.0)
|
||||
activemodel (~> 4.0)
|
||||
web-console (2.3.0)
|
||||
activemodel (>= 4.0)
|
||||
binding_of_caller (>= 0.7.2)
|
||||
railties (~> 4.0)
|
||||
railties (>= 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
wicked_pdf (0.11.0)
|
||||
rails
|
||||
yajl-ruby (1.2.1)
|
||||
wicked_pdf (1.4.0)
|
||||
activesupport
|
||||
zip-zip (0.3)
|
||||
rubyzip (>= 1.0.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@ -298,6 +321,8 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
acts_as_commentable
|
||||
acts_as_tree
|
||||
axlsx (= 3.0.0.pre)
|
||||
axlsx_rails
|
||||
bcrypt (~> 3.1.7)
|
||||
byebug
|
||||
capistrano (= 2.15.9)
|
||||
@ -317,7 +342,7 @@ DEPENDENCIES
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
kaminari-bootstrap
|
||||
mysql2
|
||||
mysql2 (~> 0.3.18)
|
||||
net-ssh (~> 2.7.0)
|
||||
nokogiri
|
||||
omniauth-facebook
|
||||
@ -326,7 +351,7 @@ DEPENDENCIES
|
||||
rails (= 4.2.6)
|
||||
redcarpet
|
||||
rmagick
|
||||
roo (~> 2.1.0)
|
||||
roo (~> 2.8.2)
|
||||
roo-xls
|
||||
rvm-capistrano (= 1.4.1)
|
||||
sass-rails (= 5.0.3)
|
||||
@ -336,11 +361,11 @@ DEPENDENCIES
|
||||
truncate_html
|
||||
turbolinks
|
||||
twitter-bootstrap-rails
|
||||
twitter-text
|
||||
uglifier (>= 1.3.0)
|
||||
unicorn
|
||||
web-console (~> 2.0)
|
||||
wicked_pdf
|
||||
zip-zip
|
||||
|
||||
BUNDLED WITH
|
||||
1.16.1
|
||||
1.16.4
|
||||
|
322
app/controllers/admin/exports_controller.rb
Normal file
322
app/controllers/admin/exports_controller.rb
Normal file
@ -0,0 +1,322 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
class Admin::ExportsController < ApplicationController
|
||||
layout "admin"
|
||||
before_filter :auth_admin
|
||||
|
||||
def prepare_file
|
||||
|
||||
@file = params[:csv_file]
|
||||
|
||||
require 'roo'
|
||||
|
||||
@xlsx = Roo::Spreadsheet.open(@file)
|
||||
#xlsx = Roo::Excelx.new("./new_prices.xlsx")
|
||||
|
||||
# Use the extension option if the extension is ambiguous.
|
||||
#xlsx = Roo::Spreadsheet.open('./rails_temp_upload', extension: :xlsx)
|
||||
|
||||
@xlsx.info
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
require 'csv'
|
||||
|
||||
|
||||
|
||||
@sheet = @xlsx.sheet(0)
|
||||
|
||||
if @sheet.cell(1,1) == "Factures vente enregistrées"
|
||||
@filename = "Export-ventes"
|
||||
@credit = true
|
||||
|
||||
headers = @sheet.row(2)
|
||||
|
||||
@rows = @sheet.parse()
|
||||
|
||||
@rows= @rows.drop(1)
|
||||
@rows= @rows.drop(1)
|
||||
|
||||
@elements = []
|
||||
@rows.each do |r|
|
||||
i = 0
|
||||
t = {}
|
||||
r.each do |c|
|
||||
|
||||
t[headers[i]] = c
|
||||
|
||||
|
||||
i += 1
|
||||
end
|
||||
@elements << t
|
||||
end
|
||||
end
|
||||
|
||||
@table_header = ["compte comptable", "compte client", "client","date", "numero piece","N° projet", "débit", "crédit"]
|
||||
@table = []
|
||||
|
||||
@elements.each do |e|
|
||||
#TTC
|
||||
line = []
|
||||
line << "41100000"
|
||||
line << e["N° client à facturer"]
|
||||
line << e["Nom"]
|
||||
line << e["Date document"]
|
||||
line << e["N°"]
|
||||
line << e["N° projet"]
|
||||
|
||||
if @credit
|
||||
line << ('%.2f' % e["Montant TTC"]).to_s.sub(".",",")
|
||||
line << ""
|
||||
else
|
||||
line << ""
|
||||
line << ('%.2f' % e["Montant TTC"]).to_s.sub(".",",")
|
||||
end
|
||||
|
||||
@table << line
|
||||
|
||||
if e["Centre cout Code"] == "VENTES"
|
||||
cpt = "70100000"
|
||||
elsif e["Centre cout Code"] == "LOCATION"
|
||||
cpt = "70830000"
|
||||
else
|
||||
cpt = ""
|
||||
end
|
||||
|
||||
line = []
|
||||
line << cpt
|
||||
line << e["N° client à facturer"]
|
||||
line << e["Nom"]
|
||||
line << e["Date document"]
|
||||
line << e["N°"]
|
||||
line << e["N° projet"]
|
||||
|
||||
if @credit
|
||||
line << ""
|
||||
line << ('%.2f' % e["Montant"]).to_s.sub(".",",")
|
||||
else
|
||||
line << ('%.2f' % e["Montant"]).to_s.sub(".",",")
|
||||
line << ""
|
||||
end
|
||||
|
||||
|
||||
|
||||
@table << line
|
||||
|
||||
#TVA
|
||||
line = []
|
||||
line << "44566000"
|
||||
line << e["N° client à facturer"]
|
||||
line << e["Nom"]
|
||||
line << e["Date document"]
|
||||
line << e["N°"]
|
||||
line << e["N° projet"]
|
||||
|
||||
if @credit
|
||||
line << ""
|
||||
line << ('%.2f' % (e["Montant TTC"] - e["Montant"])).to_s.sub(".",",")
|
||||
else
|
||||
line << ('%.2f' % (e["Montant TTC"] - e["Montant"])).to_s.sub(".",",")
|
||||
line << ""
|
||||
end
|
||||
|
||||
|
||||
@table << line
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
format.xlsx {
|
||||
response.headers['Content-Disposition'] = "attachment; filename=#{@filename}-#{Time.now.to_s.to_slug}.xlsx"
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if false
|
||||
|
||||
|
||||
require 'csv'
|
||||
|
||||
csv_text = @file.tempfile.read.force_encoding('ISO-8859-1').encode('utf-8')
|
||||
@imported_csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||
|
||||
@headers = [
|
||||
"Opérateur",
|
||||
"Forfait",
|
||||
"Date fin d'engagement",
|
||||
"Numéro de ligne",
|
||||
"Site",
|
||||
"Numéro"
|
||||
|
||||
]
|
||||
|
||||
j_bill_line_types.each do |j_bill_line_type|
|
||||
@headers << j_bill_line_type.name
|
||||
@headers << j_bill_line_type.name
|
||||
|
||||
end
|
||||
|
||||
@headers << "Total"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@csv = CSV.generate(:headers => true, :col_sep => ";") do |csv|
|
||||
csv << @headers
|
||||
date = @start
|
||||
|
||||
line = [
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
]
|
||||
j_bill_line_types.each do |j_bill_line_type|
|
||||
line << "Prix"
|
||||
line << "Volume"
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
line << ""
|
||||
|
||||
|
||||
|
||||
csv << line
|
||||
|
||||
|
||||
j_bills.joins(:j_line).order("j_lines.number ASC").each do |j_bill|
|
||||
j_line = j_bill.j_line
|
||||
|
||||
line = []
|
||||
line << j_bill.j_forfait.j_operateur.name if j_bill.j_forfait and j_bill.j_forfait.j_operateur
|
||||
line << j_bill.j_forfait.name if j_bill.j_forfait
|
||||
if j_bill.j_line and j_bill.j_line.active_forfait
|
||||
line << j_bill.j_line.active_forfait.end_at
|
||||
else
|
||||
line << ""
|
||||
end
|
||||
|
||||
line << number_to_phone(j_bill.j_line.number)
|
||||
line << j_bill.j_line.hardware
|
||||
line << j_bill.bill_number
|
||||
|
||||
|
||||
j_bill_line_types.each do |j_bill_line_type|
|
||||
|
||||
pr = j_bill.j_bill_lines.where(:j_bill_line_type_id => j_bill_line_type.id).sum(:amount)
|
||||
|
||||
v = j_bill.j_bill_lines.where(:j_bill_line_type_id => j_bill_line_type.id).sum("volume").to_f
|
||||
|
||||
if pr != 00 or v != 0
|
||||
if j_bill_line_type.unit == "Secondes"
|
||||
line << short_format_time(v)
|
||||
else
|
||||
line << v
|
||||
end
|
||||
else
|
||||
line << ""
|
||||
end
|
||||
|
||||
if pr != 00
|
||||
line << ActionController::Base.helpers.number_to_currency(pr)
|
||||
|
||||
else
|
||||
line << ""
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
line << ActionController::Base.helpers.number_to_currency(j_bill.amount)
|
||||
|
||||
csv << line
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@data_to_send = @csv.encode('iso-8859-1', :undef => :replace, :replace => '')
|
||||
|
||||
file_path = Rails.root.join("pdf", "export_mois.csv")
|
||||
|
||||
|
||||
|
||||
File.open(file_path, "w+") do |f|
|
||||
f.write(@data_to_send)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html{
|
||||
|
||||
|
||||
|
||||
require 'csv'
|
||||
|
||||
csv_text = File.read(file_path).encode('utf-8')
|
||||
@csv = CSV.parse(csv_text, :headers => true, :col_sep => ";")
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
format.csv {
|
||||
|
||||
|
||||
|
||||
send_file file_path, :filename => "export-csv.csv", :type => 'text/csv; charset=iso-8859-1; header=present'
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def index
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
2
app/models/export_hist.rb
Normal file
2
app/models/export_hist.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class ExportHist < ActiveRecord::Base
|
||||
end
|
4
app/views/admin/exports/index.html.haml
Normal file
4
app/views/admin/exports/index.html.haml
Normal file
@ -0,0 +1,4 @@
|
||||
=form_tag prepare_file_admin_exports_path(:format => :xlsx), multipart: true do
|
||||
=file_field_tag :csv_file
|
||||
|
||||
=submit_tag "importer", :class => "btn btn-primary"
|
21
app/views/admin/exports/prepare_file.html.haml
Normal file
21
app/views/admin/exports/prepare_file.html.haml
Normal file
@ -0,0 +1,21 @@
|
||||
%p{:style => "margin:1em;"}
|
||||
=# link_to ic(:download)+' Télécharger en .xlsx', params.merge(format: :xlsx), :class => "btn btn-primary"
|
||||
|
||||
|
||||
%table.table.table-striped
|
||||
%tr
|
||||
-@table_header.each do |th|
|
||||
%th=th
|
||||
|
||||
-@table.each do |tr|
|
||||
%tr
|
||||
-tr.each do |td|
|
||||
%td=td
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
7
app/views/admin/exports/prepare_file.xlsx.axlsx
Normal file
7
app/views/admin/exports/prepare_file.xlsx.axlsx
Normal file
@ -0,0 +1,7 @@
|
||||
wb = xlsx_package.workbook
|
||||
wb.add_worksheet(name: "import") do |sheet|
|
||||
sheet.add_row @table_header
|
||||
@table.each do |tr|
|
||||
sheet.add_row tr
|
||||
end
|
||||
end
|
@ -77,9 +77,11 @@
|
||||
%li= link_to "Communiqués de presse", admin_press_releases_path
|
||||
|
||||
%li= link_to "Url courte", admin_tiny_urls_path
|
||||
|
||||
|
||||
-if current_admin.contact_role
|
||||
%li= link_to "Contacts", admin_contacts_path
|
||||
%li= link_to "Conversion exports 4PS", admin_exports_path
|
||||
|
||||
|
||||
|
||||
|
@ -2,3 +2,5 @@
|
||||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
||||
|
||||
Mime::Type.register "application/vnd.ms-excel", :xlsx
|
||||
|
@ -482,12 +482,18 @@ end
|
||||
|
||||
|
||||
|
||||
|
||||
get "admin/exports" => "admin/exports#index"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace :admin do
|
||||
resources :exports do
|
||||
collection do
|
||||
post :prepare_file
|
||||
end
|
||||
end
|
||||
|
||||
resources :detenus
|
||||
|
||||
resources :investigation_cats do
|
||||
|
9
db/migrate/20190613184241_create_export_hists.rb
Normal file
9
db/migrate/20190613184241_create_export_hists.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class CreateExportHists < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :export_hists do |t|
|
||||
t.string :piece
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20190424164427) do
|
||||
ActiveRecord::Schema.define(version: 20190613184241) do
|
||||
|
||||
create_table "admins", force: :cascade do |t|
|
||||
t.string "name", limit: 255
|
||||
@ -305,6 +305,12 @@ ActiveRecord::Schema.define(version: 20190424164427) do
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "export_hists", force: :cascade do |t|
|
||||
t.string "piece", limit: 255
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "external_links", force: :cascade do |t|
|
||||
t.string "title", limit: 255
|
||||
t.text "description", limit: 65535
|
||||
|
7
test/fixtures/export_hists.yml
vendored
Normal file
7
test/fixtures/export_hists.yml
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
piece: MyString
|
||||
|
||||
two:
|
||||
piece: MyString
|
7
test/models/export_hist_test.rb
Normal file
7
test/models/export_hist_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ExportHistTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user