diff --git a/app/assets/javascripts/admin.coffee b/app/assets/javascripts/admin.coffee index a52b69b..13246d8 100644 --- a/app/assets/javascripts/admin.coffee +++ b/app/assets/javascripts/admin.coffee @@ -231,11 +231,14 @@ $(window).on 'beforeunload', -> $(document).ready -> adjust_trunk() - $(document).on 'click', 'input.datepicker', -> - $(this).datetimepicker( - language: 'fr' - pickTime: false - ).focus(); + $(document).on 'focus', 'input.datepicker', -> + if !$(this).hasClass("dtpok") + $(this).datetimepicker( + language: 'fr' + pickTime: false + ); + + $(this).addClass "dtpok" $(document).on 'click', 'input.datetimepicker', -> $(this).datetimepicker( diff --git a/app/controllers/admin/i_hebergements_controller.rb b/app/controllers/admin/i_hebergements_controller.rb new file mode 100644 index 0000000..590b985 --- /dev/null +++ b/app/controllers/admin/i_hebergements_controller.rb @@ -0,0 +1,79 @@ +# -*- encoding : utf-8 -*- + +class Admin::IHebergementsController < ApplicationController + layout "admin" + before_filter :auth_admin + + before_filter :admin_space + + def admin_space + @admin_space = "sites" + end + + + + + def index + @i_hebergements = IHebergement.order("p_customer_id ASC").all + + + end + + def show + @i_hebergement = IHebergement.find(params[:id]) + + end + + def new + + + @i_hebergement = IHebergement.new + + + end + + + + def edit + + + @i_hebergement = IHebergement.find(params[:id]) + end + + def create + @i_hebergement = IHebergement.new(params.require(:i_hebergement).permit!) + + + if @i_hebergement.save + @i_hebergements = IHebergement.order("p_customer_id ASC").all + + else + render action: "new" + + end + + end + + + def update + @i_hebergement = IHebergement.find(params[:id]) + + + if @i_hebergement.update_attributes(params.require(:i_hebergement).permit!) + + @i_hebergements = IHebergement.order("p_customer_id ASC").all + else + render action: "edit" + + end + + end + + + def destroy + @i_hebergement = IHebergement.find(params[:id]) + @i_hebergement.destroy + + + end +end diff --git a/app/controllers/admin/i_websites_controller.rb b/app/controllers/admin/i_websites_controller.rb index 93e9f0b..38aa5f4 100644 --- a/app/controllers/admin/i_websites_controller.rb +++ b/app/controllers/admin/i_websites_controller.rb @@ -7,7 +7,7 @@ class Admin::IWebsitesController < ApplicationController before_filter :admin_space def admin_space - @admin_space = "stocks" + @admin_space = "sites" end diff --git a/app/inputs/date_input.rb b/app/inputs/date_input.rb new file mode 100644 index 0000000..8a7d668 --- /dev/null +++ b/app/inputs/date_input.rb @@ -0,0 +1,26 @@ +class DateInput < Formtastic::Inputs::TextInput + include FormtasticBootstrap::Inputs::Base + + + def to_html + r = rand(1000000000000000000000000000) + bootstrap_wrapping do + builder.text_field(method.to_s, input_html_options.merge!(:class => "datepicker form-control")) + end + end + + + def to_htmldffgddfg + r = rand(1000000000000000000000000000) + + + input_wrapping do + label_html + + template.content_tag(:fieldset, template.text_field_tag("cible_name", (object.cible ? object.cible.cible_name : "aucuns élément séléctionné"), :id =>"name_#{r}" ) + + self.manager_select_cible_link(method, options, r) + builder.hidden_field(method.to_s+"_id", input_html_options.merge!(:id => "input_id_"+r.to_s)) + + builder.hidden_field(method.to_s+"_type", input_html_options.merge!(:id => "input_type_"+r.to_s)) ) + end + + end + +end diff --git a/app/inputs/qi_date_picker_input.rb b/app/inputs/qi_date_picker_input.rb deleted file mode 100644 index 375ee2a..0000000 --- a/app/inputs/qi_date_picker_input.rb +++ /dev/null @@ -1,12 +0,0 @@ - -class QiDatePickerInput < Formtastic::Inputs::TextInput - include FormtasticBootstrap::Inputs::Base - - def to_html - r = rand(1000000000000000000000000000) - bootstrap_wrapping do - builder.text_field(method.to_s, input_html_options.merge!(:class => "datepicker form-control")) - end - end - -end diff --git a/app/models/i_hebergement.rb b/app/models/i_hebergement.rb new file mode 100644 index 0000000..f835f5d --- /dev/null +++ b/app/models/i_hebergement.rb @@ -0,0 +1,7 @@ +class IHebergement < ActiveRecord::Base + has_many :i_hebergement_i_websites + has_many :i_websites, :through => :i_hebergement_i_websites + + belongs_to :p_customer + +end diff --git a/app/models/i_hebergement_i_website.rb b/app/models/i_hebergement_i_website.rb new file mode 100644 index 0000000..350aeff --- /dev/null +++ b/app/models/i_hebergement_i_website.rb @@ -0,0 +1,5 @@ +class IHebergementIWebsite < ActiveRecord::Base + belongs_to :i_hebergement + belongs_to :i_website + +end diff --git a/app/models/i_website.rb b/app/models/i_website.rb index d2e8e05..5d4604c 100644 --- a/app/models/i_website.rb +++ b/app/models/i_website.rb @@ -1,4 +1,8 @@ class IWebsite < ActiveRecord::Base belongs_to :p_customer + + def show_name + self.name.to_s+(" - "+self.url.to_s if self.url?).to_s+(" - "+self.prov_url.to_s if self.prov_url?).to_s + end end diff --git a/app/views/admin/admin_spaces/_sites.html.haml b/app/views/admin/admin_spaces/_sites.html.haml new file mode 100644 index 0000000..fadd66d --- /dev/null +++ b/app/views/admin/admin_spaces/_sites.html.haml @@ -0,0 +1,2 @@ +%li= link_to "Sites", admin_i_websites_path +%li= link_to "Hébergements", admin_i_hebergements_path diff --git a/app/views/admin/admin_spaces/_tournees.html.haml b/app/views/admin/admin_spaces/_tournees.html.haml deleted file mode 100644 index 4104fdc..0000000 --- a/app/views/admin/admin_spaces/_tournees.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -%li= link_to "Tournées", admin_p_ship_tours_path -%li= link_to "Camions", admin_p_trucks_path -%li= link_to "Chauffeurs", admin_p_drivers_path diff --git a/app/views/admin/i_hebergements/_form.html.haml b/app/views/admin/i_hebergements/_form.html.haml new file mode 100755 index 0000000..9b95f8b --- /dev/null +++ b/app/views/admin/i_hebergements/_form.html.haml @@ -0,0 +1,29 @@ +=semantic_form_for [:admin, @i_hebergement], :remote => true, :html => {:autocomplete => "off"} do |f| + + .content + =f.inputs do + = f.input :p_customer_id, :label => "Clients :", :collection => PCustomer.all, :as => :select, :include_blank => false, :member_label => :show_name + = f.input :name, :label => "Nom :" + + + + = f.input :start_at, :label => "Début :", :as => :date + + + = f.input :bill_to, :label => "Facturé jusqu'à :" , :as => :date + + + = f.input :price_ht, :label => "Prix HT :" + + + = f.input :i_websites, :label => "Sites concernés :", :collection => IWebsite.all, :member_label => "show_name", :as => :check_boxes + + + =# f.input :status, :label => "Nom :" + + + + + + + .actions=f.submit "sauvegarder", :class => "btn btn-primary" diff --git a/app/views/admin/i_hebergements/_i_hebergement.html.haml b/app/views/admin/i_hebergements/_i_hebergement.html.haml new file mode 100644 index 0000000..1a7d027 --- /dev/null +++ b/app/views/admin/i_hebergements/_i_hebergement.html.haml @@ -0,0 +1,20 @@ +%tr#i_hebergement{:id => i_hebergement.id} + + %td= i_hebergement.p_customer.show_name if i_hebergement.p_customer + %td= i_hebergement.name + + %td=l i_hebergement.start_at + + %td + - i_hebergement.i_websites.each do |i_website| + =i_website.name + + + + + + + %td.actions + = link_to i(:"trash-o"), [:admin, i_hebergement], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer ce projet ? ' } , :remote => true + = link_to i(:pencil), edit_admin_i_hebergement_path(i_hebergement), :remote => true + diff --git a/app/views/admin/i_hebergements/create.js.erb b/app/views/admin/i_hebergements/create.js.erb new file mode 100644 index 0000000..6a2739f --- /dev/null +++ b/app/views/admin/i_hebergements/create.js.erb @@ -0,0 +1,2 @@ +$('#i_hebergements_rows').html("<%= escape_javascript(render(@i_hebergements))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/app/views/admin/i_hebergements/destroy.js.erb b/app/views/admin/i_hebergements/destroy.js.erb new file mode 100644 index 0000000..f9f9b9a --- /dev/null +++ b/app/views/admin/i_hebergements/destroy.js.erb @@ -0,0 +1 @@ +$('#i_hebergement_<%= @i_hebergement.id %>').remove(); \ No newline at end of file diff --git a/app/views/admin/i_hebergements/edit.html.haml b/app/views/admin/i_hebergements/edit.html.haml new file mode 100644 index 0000000..684eb81 --- /dev/null +++ b/app/views/admin/i_hebergements/edit.html.haml @@ -0,0 +1,4 @@ +%h1 Modifier un distributeur + += render 'form' + diff --git a/app/views/admin/i_hebergements/edit.js.erb b/app/views/admin/i_hebergements/edit.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/i_hebergements/edit.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/i_hebergements/import.html.haml b/app/views/admin/i_hebergements/import.html.haml new file mode 100644 index 0000000..276b6d1 --- /dev/null +++ b/app/views/admin/i_hebergements/import.html.haml @@ -0,0 +1,32 @@ +-@import= true + +-i = 0 +-@csv.each do |csv| + -i += 1 + + =csv["code"] + -if csv["code"].to_s != "" + sfsd + -PFournisseur.create(:code => csv["code"],:name => csv["nom"],:address1 => csv["adresse 1"],:address2 => csv["adresse 2"],:cp => csv["code postal"],:city => csv["city"],:country => csv["country"],:email => csv["email"],:tel => csv["tel"]) + + + +.qi_header + %h2 Importation + +-if false + =semantic_form_for [:admin, @j_contrat], :url => import_save_admin_j_lines_path(), :html => {:method => :post}, :remote => false do |f| + + =hidden_field_tag :id, @j_contrat.id + + .j_lines_form + =f.semantic_fields_for :j_lines do |form| + =render :partial => "admin/j_lines/inline_form", :locals => {:f => form} + + %center + =f.submit "Importer", :class => "btn btn-primary" + %br + %br + %br + + diff --git a/app/views/admin/i_hebergements/index.html.haml b/app/views/admin/i_hebergements/index.html.haml new file mode 100644 index 0000000..0f821a5 --- /dev/null +++ b/app/views/admin/i_hebergements/index.html.haml @@ -0,0 +1,24 @@ +.qi_header + .right= link_to 'Ajouter un hébergement', new_admin_i_hebergement_path(), :class => "btn btn-primary", :remote => true + %h1 + Hébergement + + +.qi_row + .qi_pannel.qi_plain.padding + %table.table + %tr + %th Client + + + %th Nom + %th Url provisoire + %th Url + %th Status + %th + + + %tbody#i_hebergements_rows + =render @i_hebergements + + \ No newline at end of file diff --git a/app/views/admin/i_hebergements/new.html.haml b/app/views/admin/i_hebergements/new.html.haml new file mode 100644 index 0000000..3b1635e --- /dev/null +++ b/app/views/admin/i_hebergements/new.html.haml @@ -0,0 +1,4 @@ +%h1 Ajouter un distributeur + += render 'form' + diff --git a/app/views/admin/i_hebergements/new.js.erb b/app/views/admin/i_hebergements/new.js.erb new file mode 100644 index 0000000..6c8f015 --- /dev/null +++ b/app/views/admin/i_hebergements/new.js.erb @@ -0,0 +1 @@ +show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900); \ No newline at end of file diff --git a/app/views/admin/i_hebergements/show.html.haml b/app/views/admin/i_hebergements/show.html.haml new file mode 100644 index 0000000..813a144 --- /dev/null +++ b/app/views/admin/i_hebergements/show.html.haml @@ -0,0 +1,10 @@ +%h1=@i_hebergement.name + +%h2 Marques +=link_to "ajouter une marque", new_admin_label_marque_path(:i_hebergement_id => @i_hebergement.id), :class => "btn btn-primary" +%table.table + =render @i_hebergement.label_marques.order(:name) +%br +%br +%br +%br \ No newline at end of file diff --git a/app/views/admin/i_hebergements/update.js.erb b/app/views/admin/i_hebergements/update.js.erb new file mode 100644 index 0000000..6a2739f --- /dev/null +++ b/app/views/admin/i_hebergements/update.js.erb @@ -0,0 +1,2 @@ +$('#i_hebergements_rows').html("<%= escape_javascript(render(@i_hebergements))%>"); +close_pane_hover(); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 82e828a..5ee00f7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -111,6 +111,7 @@ Rails.application.routes.draw do end namespace :admin do + resources :i_hebergements resources :i_websites resources :p_ship_bills resources :p_stats diff --git a/db/migrate/20181110151820_create_i_hebergements.rb b/db/migrate/20181110151820_create_i_hebergements.rb new file mode 100644 index 0000000..811e25a --- /dev/null +++ b/db/migrate/20181110151820_create_i_hebergements.rb @@ -0,0 +1,17 @@ +class CreateIHebergements < ActiveRecord::Migration + def change + create_table :i_hebergements do |t| + t.string :name + t.date :start_at + t.date :last_bill_at + t.date :bill_to + t.decimal :price_ht + t.integer :frequence + t.date :end_at + t.references :p_customer + + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20181110152121_create_i_hebergement_i_websites.rb b/db/migrate/20181110152121_create_i_hebergement_i_websites.rb new file mode 100644 index 0000000..f4db555 --- /dev/null +++ b/db/migrate/20181110152121_create_i_hebergement_i_websites.rb @@ -0,0 +1,10 @@ +class CreateIHebergementIWebsites < ActiveRecord::Migration + def change + create_table :i_hebergement_i_websites do |t| + t.integer :i_hebergement_id + t.integer :i_website_id + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index bce07ac..32b9eae 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20181108201122) do +ActiveRecord::Schema.define(version: 20181110152121) do create_table "admin_admin_roles", force: :cascade do |t| t.integer "admin_id", limit: 4 @@ -411,6 +411,26 @@ ActiveRecord::Schema.define(version: 20181108201122) do t.datetime "updated_at" end + create_table "i_hebergement_i_websites", force: :cascade do |t| + t.integer "i_hebergement_id", limit: 4 + t.integer "i_website_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "i_hebergements", force: :cascade do |t| + t.string "name", limit: 255 + t.date "start_at" + t.date "last_bill_at" + t.date "bill_to" + t.decimal "price_ht", precision: 10 + t.integer "frequence", limit: 4 + t.date "end_at" + t.integer "p_customer_id", limit: 4 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "i_websites", force: :cascade do |t| t.string "name", limit: 255 t.string "url", limit: 255 diff --git a/test/fixtures/i_hebergement_i_websites.yml b/test/fixtures/i_hebergement_i_websites.yml new file mode 100644 index 0000000..6a367cc --- /dev/null +++ b/test/fixtures/i_hebergement_i_websites.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + i_hebergement_id: 1 + i_website_id.integer: MyString + +two: + i_hebergement_id: 1 + i_website_id.integer: MyString diff --git a/test/fixtures/i_hebergements.yml b/test/fixtures/i_hebergements.yml new file mode 100644 index 0000000..ff9d456 --- /dev/null +++ b/test/fixtures/i_hebergements.yml @@ -0,0 +1,19 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + start_at: 2018-11-10 + last_bill_at: 2018-11-10 + bill_to: 2018-11-10 + price_ht: 9.99 + frequence: 1 + end_at: 2018-11-10 + +two: + name: MyString + start_at: 2018-11-10 + last_bill_at: 2018-11-10 + bill_to: 2018-11-10 + price_ht: 9.99 + frequence: 1 + end_at: 2018-11-10 diff --git a/test/models/i_hebergement_i_website_test.rb b/test/models/i_hebergement_i_website_test.rb new file mode 100644 index 0000000..08cf0c6 --- /dev/null +++ b/test/models/i_hebergement_i_website_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class IHebergementIWebsiteTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/i_hebergement_test.rb b/test/models/i_hebergement_test.rb new file mode 100644 index 0000000..90e1087 --- /dev/null +++ b/test/models/i_hebergement_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class IHebergementTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end