This commit is contained in:
Nicolas Bally 2018-11-10 22:25:56 +01:00
parent f525442d8a
commit 0bb1993bdd
30 changed files with 353 additions and 22 deletions

View File

@ -231,11 +231,14 @@ $(window).on 'beforeunload', ->
$(document).ready ->
adjust_trunk()
$(document).on 'click', 'input.datepicker', ->
$(document).on 'focus', 'input.datepicker', ->
if !$(this).hasClass("dtpok")
$(this).datetimepicker(
language: 'fr'
pickTime: false
).focus();
);
$(this).addClass "dtpok"
$(document).on 'click', 'input.datetimepicker', ->
$(this).datetimepicker(

View File

@ -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

View File

@ -7,7 +7,7 @@ class Admin::IWebsitesController < ApplicationController
before_filter :admin_space
def admin_space
@admin_space = "stocks"
@admin_space = "sites"
end

26
app/inputs/date_input.rb Normal file
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
class IHebergementIWebsite < ActiveRecord::Base
belongs_to :i_hebergement
belongs_to :i_website
end

View File

@ -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

View File

@ -0,0 +1,2 @@
%li= link_to "Sites", admin_i_websites_path
%li= link_to "Hébergements", admin_i_hebergements_path

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -0,0 +1,2 @@
$('#i_hebergements_rows').html("<%= escape_javascript(render(@i_hebergements))%>");
close_pane_hover();

View File

@ -0,0 +1 @@
$('#i_hebergement_<%= @i_hebergement.id %>').remove();

View File

@ -0,0 +1,4 @@
%h1 Modifier un distributeur
= render 'form'

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,4 @@
%h1 Ajouter un distributeur
= render 'form'

View File

@ -0,0 +1 @@
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);

View File

@ -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

View File

@ -0,0 +1,2 @@
$('#i_hebergements_rows').html("<%= escape_javascript(render(@i_hebergements))%>");
close_pane_hover();

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

19
test/fixtures/i_hebergements.yml vendored Normal file
View File

@ -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

View File

@ -0,0 +1,7 @@
require 'test_helper'
class IHebergementIWebsiteTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class IHebergementTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end