diff --git a/Gemfile b/Gemfile index a969f19..ce71176 100644 --- a/Gemfile +++ b/Gemfile @@ -88,7 +88,7 @@ gem "nokogiri" gem 'twitter-text' -gem 'pygments.rb' +gem 'pygments.rb', "1.2.1" gem 'redcarpet' gem 'omniauth-facebook' diff --git a/Gemfile.lock b/Gemfile.lock index 892d1ba..9acd03d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,7 +75,7 @@ GEM countries (~> 1.2.0) sort_alphabetical (~> 1.0) crass (1.0.4) - curb (0.8.8) + curb (0.9.10) currencies (0.4.2) debug_inspector (0.0.2) debugger-linecache (1.2.0) @@ -186,10 +186,9 @@ GEM xml-simple paypal-sdk-merchant (1.117.2) paypal-sdk-core (~> 0.3.0) - posix-spawn (0.3.11) - pygments.rb (0.6.3) - posix-spawn (~> 0.3.6) - yajl-ruby (~> 1.2.0) + 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) @@ -311,7 +310,6 @@ GEM wicked_pdf (0.11.0) rails xml-simple (1.1.5) - yajl-ruby (1.2.1) PLATFORMS ruby @@ -344,7 +342,7 @@ DEPENDENCIES omniauth-facebook paypal-sdk-merchant posix-spawn - pygments.rb + pygments.rb (= 1.2.1) rails (= 4.2.10) rails_autolink redcarpet @@ -367,4 +365,4 @@ DEPENDENCIES wicked_pdf BUNDLED WITH - 1.16.2 + 1.17.3 diff --git a/app/controllers/admin/p_customer_sheets_controller.rb b/app/controllers/admin/p_customer_sheets_controller.rb index 28017dd..506b65e 100644 --- a/app/controllers/admin/p_customer_sheets_controller.rb +++ b/app/controllers/admin/p_customer_sheets_controller.rb @@ -65,6 +65,61 @@ class Admin::PCustomerSheetsController < ApplicationController end + + + def dup + + + @past_customer_sheet = PCustomerSheet.find(params[:id]) + + + @p_customer_sheet = PCustomerSheet.new(:p_customer => @past_customer_sheet.p_customer, :wish_start => Date.today, :wish_stop => ((Date.today + 7.day).end_of_week)-2.day) + @p_customer_sheet.particular_bill_id = @past_customer_sheet.particular_bill_id + @p_customer_sheet.particular_send_id = @past_customer_sheet.particular_send_id + @p_customer_sheet.cust_ref = @past_customer_sheet.cust_ref + @past_customer_sheet.p_sheet_lines.each do |p_sheet_line| + + new_p_sheet_line = p_sheet_line.dup + p_sheet_line.p_sheet_line_lines.each do |p_sheet_line_line| + new_p_sheet_line.p_sheet_line_lines << p_sheet_line_line.dup + end + + p_sheet_line.p_sheet_line_stocks.each do |p_sheet_line_stock| + new_p_sheet_line.p_sheet_line_stocks << p_sheet_line_stock.dup + end + + + + + + @p_customer_sheet.p_sheet_lines << new_p_sheet_line + + end + + + + @p_customer_sheet.fdp_force_price = @past_customer_sheet.fdp_force_price + @p_customer_sheet.obs_devis = @past_customer_sheet.obs_devis + @p_customer_sheet.obs_bdc = @past_customer_sheet.obs_bdc + @p_customer_sheet.obs_bdl = @past_customer_sheet.obs_bdl + + + @p_customer_sheet.p_payment_type_id = @past_customer_sheet.p_payment_type_id + @p_customer_sheet.comptant = @past_customer_sheet.comptant + @p_customer_sheet.acompte = @past_customer_sheet.acompte + @p_customer_sheet.acompte_percent = @past_customer_sheet.acompte_percent + @p_customer_sheet.payment_delais = @past_customer_sheet.payment_delais + @p_customer_sheet.payment_fin_de_mois = @past_customer_sheet.payment_fin_de_mois + + + + + @p_customer_sheet.save + + + + redirect_to admin_p_customer_sheets_path() + end diff --git a/app/controllers/admin/p_customers_controller.rb b/app/controllers/admin/p_customers_controller.rb index cc79055..5151ba5 100644 --- a/app/controllers/admin/p_customers_controller.rb +++ b/app/controllers/admin/p_customers_controller.rb @@ -63,6 +63,10 @@ class Admin::PCustomersController < ApplicationController @p_customer = PCustomer.find(params[:id]) end + + + + def create @p_customer = PCustomer.new(params.require(:p_customer).permit!) diff --git a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml index 51ad5c1..abfe017 100644 --- a/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml +++ b/app/views/admin/p_customer_sheets/_p_customer_sheet.html.haml @@ -23,6 +23,10 @@ %td.actions + + + =link_to i(:copy), dup_admin_p_customer_sheet_path(p_customer_sheet), :data => {:confirm => 'Voulez-vous vraiment dupliquer cette commande ?'} + -if p_customer_sheet.state == "brouillon" = link_to i(:"trash-o"), [:admin, p_customer_sheet], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet auteur ? ' } , :remote => true = link_to i(:pencil), edit_admin_p_customer_sheet_path(p_customer_sheet), :remote => false diff --git a/config/routes.rb b/config/routes.rb index 596ab04..41dcfad 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -243,6 +243,8 @@ Rails.application.routes.draw do get :cancel get :uncancel + get :dup + get :set_sheet_line_ship post :set_sheet_line_ship_save