spree_suppliers 0.60.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- metadata +41 -215
- data/README +0 -46
- data/Rakefile +0 -137
- data/app/controllers/admin/pickup_locations_controller.rb +0 -52
- data/app/controllers/admin/pickups_controller.rb +0 -84
- data/app/controllers/admin/shipping_options_controller.rb +0 -32
- data/app/controllers/admin/supplier_taxons_controller.rb +0 -65
- data/app/controllers/admin/suppliers_controller.rb +0 -203
- data/app/controllers/admin/vendor_overview_controller.rb +0 -18
- data/app/controllers/dash/base_controller.rb +0 -10
- data/app/controllers/dash/overview_controller.rb +0 -6
- data/app/controllers/dash/pickup_locations_controller.rb +0 -27
- data/app/controllers/dash/pickups_controller.rb +0 -40
- data/app/controllers/dash/products_controller.rb +0 -15
- data/app/controllers/messages_controller.rb +0 -17
- data/app/controllers/suppliers_controller.rb +0 -19
- data/app/controllers/user_sessions_decorator.rb +0 -39
- data/app/helpers/admin/suppliers_helper.rb +0 -21
- data/app/helpers/cities_helper.rb +0 -2
- data/app/helpers/dragonfly_helper.rb +0 -16
- data/app/helpers/messages_helper.rb +0 -2
- data/app/helpers/suppliers_helper.rb +0 -16
- data/app/mailers/supplier_mailer.rb +0 -11
- data/app/models/ability_decorator.rb +0 -19
- data/app/models/delivery.rb +0 -6
- data/app/models/hour.rb +0 -4
- data/app/models/item.rb +0 -5
- data/app/models/message.rb +0 -3
- data/app/models/pickup.rb +0 -10
- data/app/models/pickup_date.rb +0 -3
- data/app/models/pickup_location.rb +0 -7
- data/app/models/supplier.rb +0 -33
- data/app/models/supplier_invoice.rb +0 -5
- data/app/views/admin/orders/index.html.erb +0 -107
- data/app/views/admin/orders/show.html.erb +0 -35
- data/app/views/admin/orders/user.html.erb +0 -19
- data/app/views/admin/pickup_locations/_pickup_location.html.erb +0 -10
- data/app/views/admin/pickup_locations/edit.html.erb +0 -44
- data/app/views/admin/pickup_locations/new.html.erb +0 -48
- data/app/views/admin/pickup_locations/show.html.erb +0 -1
- data/app/views/admin/pickups/_pickup.erb +0 -0
- data/app/views/admin/pickups/index.html.erb +0 -44
- data/app/views/admin/pickups/new.html.erb +0 -33
- data/app/views/admin/pickups/show.html.erb +0 -42
- data/app/views/admin/products/_suppliers_form.html.erb +0 -5
- data/app/views/admin/shared/_order_tabs_decide.html.erb +0 -5
- data/app/views/admin/shared/_vendor_order_tabs.html.erb +0 -39
- data/app/views/admin/shipping_options/edit.html.erb +0 -38
- data/app/views/admin/supplier_taxons/_form.html.erb +0 -23
- data/app/views/admin/supplier_taxons/_taxon_table.html.erb +0 -23
- data/app/views/admin/supplier_taxons/available.js.erb +0 -33
- data/app/views/admin/supplier_taxons/edit.html.erb +0 -11
- data/app/views/admin/supplier_taxons/remove.html.erb +0 -1
- data/app/views/admin/supplier_taxons/select.js.erb +0 -2
- data/app/views/admin/supplier_taxons/selected.html.erb +0 -51
- data/app/views/admin/suppliers/_edit_form.html.erb +0 -75
- data/app/views/admin/suppliers/_edit_hours_form.html.erb +0 -18
- data/app/views/admin/suppliers/_form.html.erb +0 -72
- data/app/views/admin/suppliers/_hours_form.html.erb +0 -11
- data/app/views/admin/suppliers/_image_form.html.erb +0 -40
- data/app/views/admin/suppliers/_supplier.html.erb +0 -37
- data/app/views/admin/suppliers/_supplier_tabs.html.erb +0 -18
- data/app/views/admin/suppliers/_suppliers_table.html.erb +0 -25
- data/app/views/admin/suppliers/_upload_image.html.erb +0 -14
- data/app/views/admin/suppliers/available.js.erb +0 -34
- data/app/views/admin/suppliers/edit.html.erb +0 -20
- data/app/views/admin/suppliers/index.html.erb +0 -102
- data/app/views/admin/suppliers/line_items.html.erb +0 -20
- data/app/views/admin/suppliers/new.html.erb +0 -22
- data/app/views/admin/suppliers/remove.html.erb +0 -1
- data/app/views/admin/suppliers/select.html.erb +0 -1
- data/app/views/admin/suppliers/selected.html.erb +0 -40
- data/app/views/admin/suppliers/show.html.erb +0 -2
- data/app/views/admin/users/_form.html.erb +0 -40
- data/app/views/admin/vendor_overview/index.html.erb +0 -1
- data/app/views/checkout/_delivery.html.erb +0 -5
- data/app/views/dash/overview/index.html.erb +0 -58
- data/app/views/dash/pickup_locations/_pickup_location.html.erb +0 -3
- data/app/views/dash/pickup_locations/new.html.erb +0 -47
- data/app/views/dash/pickups/_pickup.erb +0 -3
- data/app/views/dash/pickups/new.html.erb +0 -24
- data/app/views/dash/products/new.html.erb +0 -38
- data/app/views/layouts/admin.html.erb +0 -81
- data/app/views/messages/_message_form.html.erb +0 -17
- data/app/views/messages/create.html.erb +0 -2
- data/app/views/messages/destroy.html.erb +0 -2
- data/app/views/messages/new.html.erb +0 -2
- data/app/views/shared/_deliveries.html.erb +0 -113
- data/app/views/shared/_hours.html.erb +0 -21
- data/app/views/shared/_products_vendor.html.erb +0 -49
- data/app/views/shared/_supplier_invoices.html.erb +0 -67
- data/app/views/supplier_mailer/invoice_email.html.erb +0 -72
- data/app/views/suppliers/_supplier.html.erb +0 -7
- data/app/views/suppliers/_supplier_list.erb +0 -20
- data/app/views/suppliers/index.html.erb +0 -17
- data/app/views/suppliers/show.html.erb +0 -106
- data/app/views/suppliers/supplier_list.erb +0 -14
- data/config/initializers/dragonfly.rb +0 -8
- data/config/initializers/supplier_invoice_mailer.rb +0 -10
- data/config/locales/en-US.yml +0 -13
- data/config/routes.rb +0 -48
- data/db/migrate/20091209201716_supplier_setup.rb +0 -36
- data/db/migrate/20110922213437_create_messages.rb +0 -18
- data/db/migrate/20110928203155_create_hours.rb +0 -21
- data/db/migrate/20111006185052_create_pickups.rb +0 -17
- data/db/migrate/20111010191125_add_location_to_addresses.rb +0 -9
- data/db/migrate/20111010214313_create_pickup_dates.rb +0 -14
- data/db/migrate/20111011180211_add_supplier_id_to_user.rb +0 -9
- data/db/migrate/20111012211422_create_pickup_locations.rb +0 -21
- data/db/migrate/20111013155257_create_supplier_invoices.rb +0 -16
- data/db/migrate/20111013161225_create_items.rb +0 -18
- data/db/migrate/20111018133543_add_attributes_to_products.rb +0 -17
- data/db/migrate/20111028190454_add_attributes_to_assets.rb +0 -11
- data/db/migrate/20111029230805_create_suppliers_taxons.rb +0 -16
- data/db/migrate/20111101165933_create_deliveries.rb +0 -17
- data/db/migrate/20111108213108_create_shipping_methods_suppliers.rb +0 -16
- data/db/seeds.rb +0 -14
- data/lib/spree_suppliers.rb +0 -411
- data/lib/spree_suppliers_hooks.rb +0 -40
- data/lib/tasks/spree_suppliers.rake +0 -27
- data/public/javascripts/jquery-ui.js +0 -312
- data/public/javascripts/jquery-ui.multidatespicker.js +0 -398
- data/public/javascripts/jquery.ui.datepicker.js +0 -1791
- data/public/stylesheets/suppliers.css +0 -676
- data/spec/controllers/cities_controller_spec.rb +0 -157
- data/spec/controllers/shipping_options_controller_spec.rb +0 -12
- data/spec/helpers/cities_helper_spec.rb +0 -15
- data/spec/models/city_spec.rb +0 -5
- data/spec/models/comment_spec.rb +0 -64
- data/spec/models/item_spec.rb +0 -5
- data/spec/models/message_spec.rb +0 -5
- data/spec/models/pickup_date_spec.rb +0 -5
- data/spec/models/pickup_location_spec.rb +0 -5
- data/spec/models/pickup_spec.rb +0 -5
- data/spec/models/rating_spec.rb +0 -24
- data/spec/models/supplier_invoice_spec.rb +0 -5
- data/spec/models/supplier_spec.rb +0 -11
- data/spec/requests/cities_spec.rb +0 -11
- data/spec/routing/cities_routing_spec.rb +0 -35
- data/spec/spec.opts +0 -6
- data/spec/spec_helper.rb +0 -37
- data/spec/views/cities/edit.html.erb_spec.rb +0 -22
- data/spec/views/cities/index.html.erb_spec.rb +0 -28
- data/spec/views/cities/new.html.erb_spec.rb +0 -22
- data/spec/views/cities/show.html.erb_spec.rb +0 -21
- data/spec/views/shipping_options/edit.html.erb_spec.rb +0 -5
- data/spree_suppliers.gemspec +0 -24
@@ -1,14 +0,0 @@
|
|
1
|
-
<li>
|
2
|
-
<div class="vendor-image">
|
3
|
-
<%= link_to sized_image(supplier.images.first, '75x75#'), supplier_path(supplier) %>
|
4
|
-
</div>
|
5
|
-
|
6
|
-
<div class="article-content">
|
7
|
-
<h3><%= link_to supplier.title, supplier_path(supplier) %> </h3>
|
8
|
-
<span class="city-state"><%= supplier.city.name %>, <%= supplier.state.name %></span>TEST 2
|
9
|
-
<p class="supplier_about">
|
10
|
-
<%= supplier.notes%> <br />
|
11
|
-
<%= supplier.address1 %> - <%= supplier.city.name %>, <%= supplier.state.name %><br />
|
12
|
-
<span class="phone"><%= supplier.phone %></span></p>
|
13
|
-
</div>
|
14
|
-
</li>
|
data/config/locales/en-US.yml
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
---
|
2
|
-
en:
|
3
|
-
suppliers: "Vendors"
|
4
|
-
pickups: "Pickups"
|
5
|
-
supplier_name: "Vendor Name"
|
6
|
-
new_supplier: "New Vendor"
|
7
|
-
available_suppliers: "Available Vendors"
|
8
|
-
editing_supplier: "Editing Vendor"
|
9
|
-
fax: "Fax"
|
10
|
-
notes: "Description"
|
11
|
-
suppliers_description: "Manage Vendors"
|
12
|
-
count_on_hand: "Count On Hand"
|
13
|
-
upload: "Upload"
|
data/config/routes.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
Rails.application.routes.draw do
|
2
|
-
resources :suppliers
|
3
|
-
resources :messages
|
4
|
-
resources :deliveries
|
5
|
-
|
6
|
-
namespace :admin do
|
7
|
-
|
8
|
-
resources :suppliers do
|
9
|
-
get 'feature'
|
10
|
-
resources :taxons, :controller => "supplier_taxons" do
|
11
|
-
member do
|
12
|
-
get :select
|
13
|
-
delete :remove
|
14
|
-
end
|
15
|
-
collection do
|
16
|
-
post :available
|
17
|
-
post :batch_select
|
18
|
-
get :selected
|
19
|
-
post :update_taxons
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
match "upload_image" => "suppliers#upload_image"
|
24
|
-
match "destroy_image" => "suppliers#destroy_image"
|
25
|
-
match "make_logo" => "suppliers#make_logo"
|
26
|
-
match "feature_image" => "suppliers#feature_image"
|
27
|
-
|
28
|
-
resources :overview
|
29
|
-
resources :pickups
|
30
|
-
resources :pickup_locations
|
31
|
-
resources :shipping_options
|
32
|
-
|
33
|
-
resources :products do
|
34
|
-
resources :suppliers, :member => {:select => :post, :remove => :post}, :collection => {:available => :post, :selected => :get}
|
35
|
-
member do
|
36
|
-
get :publish
|
37
|
-
get :unpublish
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
resources :orders do
|
42
|
-
resources :suppliers, :collection => {:line_items => :get}
|
43
|
-
end
|
44
|
-
|
45
|
-
resources :vendor_overview
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
class SupplierSetup < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :suppliers do |t|
|
4
|
-
t.string :name
|
5
|
-
t.string :title
|
6
|
-
t.string :description2
|
7
|
-
t.string :address1
|
8
|
-
t.string :address2
|
9
|
-
t.string :town
|
10
|
-
t.string :state_id
|
11
|
-
t.string :zip_code
|
12
|
-
t.string :phone
|
13
|
-
t.string :fax
|
14
|
-
t.string :email
|
15
|
-
t.string :website
|
16
|
-
t.string :twitter
|
17
|
-
t.string :facebook
|
18
|
-
t.text :notes
|
19
|
-
t.text :products_sold
|
20
|
-
t.float :latitude
|
21
|
-
t.float :longitude
|
22
|
-
t.boolean :gmaps
|
23
|
-
t.boolean :featured
|
24
|
-
t.string :slug
|
25
|
-
t.integer :user_id
|
26
|
-
|
27
|
-
t.timestamps
|
28
|
-
end
|
29
|
-
add_column :products, :supplier_id, :integer
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.down
|
33
|
-
drop_table :suppliers
|
34
|
-
remove_column :products, :supplier_id
|
35
|
-
end
|
36
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class CreateMessages < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :messages do |t|
|
4
|
-
t.integer :supplier_id
|
5
|
-
t.string :title
|
6
|
-
t.string :text
|
7
|
-
t.integer :user_id
|
8
|
-
t.boolean :opened
|
9
|
-
t.string :author
|
10
|
-
|
11
|
-
t.timestamps
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.down
|
16
|
-
drop_table :messages
|
17
|
-
end
|
18
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class CreateHours < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :hours do |t|
|
4
|
-
t.string :monday
|
5
|
-
t.string :tuesday
|
6
|
-
t.string :wednesday
|
7
|
-
t.string :thursday
|
8
|
-
t.string :friday
|
9
|
-
t.string :saturday
|
10
|
-
t.string :sunday
|
11
|
-
t.integer :supplier_id
|
12
|
-
t.integer :pickup_location_id
|
13
|
-
|
14
|
-
t.timestamps
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.down
|
19
|
-
drop_table :cities
|
20
|
-
end
|
21
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class CreatePickups < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :pickups do |t|
|
4
|
-
t.string :name
|
5
|
-
t.integer :address_id
|
6
|
-
t.integer :supplier_id
|
7
|
-
t.integer :pickup_location_id
|
8
|
-
t.integer :delivery_id
|
9
|
-
|
10
|
-
t.timestamps
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.down
|
15
|
-
drop_table :pickups
|
16
|
-
end
|
17
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class CreatePickupLocations < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :pickup_locations do |t|
|
4
|
-
t.string :location_name
|
5
|
-
t.string :address1
|
6
|
-
t.string :address2
|
7
|
-
t.string :city
|
8
|
-
t.integer :state_id
|
9
|
-
t.string :zipcode
|
10
|
-
t.integer :country_id
|
11
|
-
t.integer :supplier_id
|
12
|
-
t.boolean :featured
|
13
|
-
|
14
|
-
t.timestamps
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.down
|
19
|
-
drop_table :pickup_locations
|
20
|
-
end
|
21
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class CreateSupplierInvoices < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :supplier_invoices do |t|
|
4
|
-
t.integer :order_id
|
5
|
-
t.integer :item_count
|
6
|
-
t.integer :supplier_id
|
7
|
-
t.decimal :invoice_total, :precision => 8, :scale => 2, :default => 0.0, :null => false
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.down
|
14
|
-
drop_table :supplier_invoices
|
15
|
-
end
|
16
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class CreateItems < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :items do |t|
|
4
|
-
t.integer :product_id
|
5
|
-
t.string :delivery_type
|
6
|
-
t.integer :pickup_id
|
7
|
-
t.integer :quantity
|
8
|
-
t.integer :supplier_invoice_id
|
9
|
-
t.integer :line_item_id
|
10
|
-
|
11
|
-
t.timestamps
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.down
|
16
|
-
drop_table :items
|
17
|
-
end
|
18
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class AddAttributesToProducts < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
add_column :products, :number_of_units, :decimal
|
4
|
-
add_column :products, :unit, :string
|
5
|
-
add_column :products, :cost_per_unit, :decimal
|
6
|
-
add_column :products, :shipping_method_id, :integer
|
7
|
-
add_column :products, :shipping, :boolean
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.down
|
11
|
-
remove_column :products, :number_of_units
|
12
|
-
remove_column :products, :unit
|
13
|
-
remove_column :products, :cost_per_unit
|
14
|
-
remove_column :products, :shipping_method_id
|
15
|
-
remove_column :products, :shipping
|
16
|
-
end
|
17
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class CreateSuppliersTaxons < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :suppliers_taxons, :id => false do |t|
|
4
|
-
t.integer :supplier_id
|
5
|
-
t.integer :taxon_id
|
6
|
-
end
|
7
|
-
add_index :suppliers_taxons, :supplier_id
|
8
|
-
add_index :suppliers_taxons, :taxon_id
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.down
|
12
|
-
remove_index :suppliers_taxons, :column => :taxon_id
|
13
|
-
remove_index :suppliers_taxons, :column => :supplier_id
|
14
|
-
drop_table :suppliers_taxons
|
15
|
-
end
|
16
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class CreateDeliveries < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :deliveries do |t|
|
4
|
-
t.integer :supplier_id
|
5
|
-
t.integer :order_id
|
6
|
-
t.boolean :pick_up
|
7
|
-
t.integer :shipping_method_id
|
8
|
-
t.integer :pickup_id
|
9
|
-
|
10
|
-
t.timestamps
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.down
|
15
|
-
drop_table :deliveries
|
16
|
-
end
|
17
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
class CreateShippingMethodsSuppliers < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :shipping_methods_suppliers, :id => false do |t|
|
4
|
-
t.integer :supplier_id
|
5
|
-
t.integer :shipping_method_id
|
6
|
-
end
|
7
|
-
add_index :shipping_methods_suppliers, :supplier_id
|
8
|
-
add_index :shipping_methods_suppliers, :shipping_method_id
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.down
|
12
|
-
remove_index :shipping_methods_suppliers, :column => :shipping_method_id
|
13
|
-
remove_index :shipping_methods_suppliers, :column => :supplier_id
|
14
|
-
drop_table :shipping_methods_suppliers
|
15
|
-
end
|
16
|
-
end
|
data/db/seeds.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# Use this file to load your own seed data from extensions.
|
2
|
-
# See the db/seeds.rb file in the Spree core for some ideas on what you can do here.
|
3
|
-
#
|
4
|
-
Rake::Task["db:load_dir"].invoke( "default" )
|
5
|
-
puts "Default data has been loaded"
|
6
|
-
|
7
|
-
puts "Create Taxonomy"
|
8
|
-
|
9
|
-
t = Taxonomy.create :name => "Products"
|
10
|
-
|
11
|
-
puts "Create Vendor Role"
|
12
|
-
|
13
|
-
r = Role.create :name => "vendor"
|
14
|
-
|
data/lib/spree_suppliers.rb
DELETED
@@ -1,411 +0,0 @@
|
|
1
|
-
require 'spree_core'
|
2
|
-
require 'spree_suppliers_hooks'
|
3
|
-
require 'gmaps4rails'
|
4
|
-
require 'dragonfly'
|
5
|
-
require 'rack-cache'
|
6
|
-
|
7
|
-
module SpreeSuppliers
|
8
|
-
class Engine < Rails::Engine
|
9
|
-
config.autoload_paths += %W(#{config.root}/lib)
|
10
|
-
|
11
|
-
def self.activate
|
12
|
-
Ability.register_ability(AbilityDecorator)
|
13
|
-
#### Modify the controllers with changes that are only associated with the Suppliers extension
|
14
|
-
|
15
|
-
# Append the checkout controller
|
16
|
-
#
|
17
|
-
CheckoutController.class_eval do
|
18
|
-
def edit
|
19
|
-
@order_products = @order.products
|
20
|
-
@suppliers = @order_products.collect{|item| item.supplier_id}.uniq
|
21
|
-
@delivery = Delivery.new
|
22
|
-
end
|
23
|
-
# Updates the order and advances to the next state (when possible.)
|
24
|
-
def update
|
25
|
-
@order_products = @order.products
|
26
|
-
@suppliers = @order_products.collect{|item| item.supplier_id}.uniq
|
27
|
-
if @order.update_attributes(object_params)
|
28
|
-
if @order.next
|
29
|
-
state_callback(:after)
|
30
|
-
else
|
31
|
-
flash[:error] = I18n.t(:payment_processing_failed)
|
32
|
-
respond_with(@order, :location => checkout_state_path(@order.state))
|
33
|
-
return
|
34
|
-
end
|
35
|
-
if @order.state == "payment"
|
36
|
-
@suppliers.each do |s|
|
37
|
-
delivery = @order.deliveries.find_or_create_by_supplier_id(s)
|
38
|
-
if delivery
|
39
|
-
if !params["shipping_method"].nil?
|
40
|
-
delivery.update_attributes(:pick_up => params["deliveries"][s.to_s], :pickup_id => params["pickups"][s.to_s], :shipping_method_id => params["shipping_method"][s.to_s])
|
41
|
-
else
|
42
|
-
delivery.update_attributes(:pick_up => params["deliveries"][s.to_s], :pickup_id => params["pickups"][s.to_s])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
if @order.state == "complete" || @order.completed?
|
48
|
-
# This is where the SupplierInvoices are generated
|
49
|
-
# Back to the normal checkout process
|
50
|
-
flash[:notice] = I18n.t(:order_processed_successfully)
|
51
|
-
flash[:commerce_tracking] = "nothing special"
|
52
|
-
respond_with(@order, :location => completion_route)
|
53
|
-
else
|
54
|
-
respond_with(@order, :location => checkout_state_path(@order.state))
|
55
|
-
end
|
56
|
-
else
|
57
|
-
respond_with(@order) { |format| format.html { render :edit } }
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
# Append the admin orders controller
|
63
|
-
#
|
64
|
-
Admin::OrdersController.class_eval do
|
65
|
-
def show
|
66
|
-
load_order
|
67
|
-
@fee = "0.86".to_d
|
68
|
-
if current_user.has_role?("vendor")
|
69
|
-
@invoices = @order.supplier_invoices
|
70
|
-
@invoices.select! {|s| s.supplier_id == current_user.supplier.id}
|
71
|
-
else
|
72
|
-
@invoices = @order.supplier_invoices
|
73
|
-
end
|
74
|
-
respond_with(@order)
|
75
|
-
end
|
76
|
-
def index
|
77
|
-
params[:search] ||= {}
|
78
|
-
params[:search][:completed_at_is_not_null] ||= '1' if Spree::Config[:show_only_complete_orders_by_default]
|
79
|
-
@show_only_completed = params[:search][:completed_at_is_not_null].present?
|
80
|
-
params[:search][:meta_sort] ||= @show_only_completed ? 'completed_at.desc' : 'created_at.desc'
|
81
|
-
@search = Order.metasearch(params[:search])
|
82
|
-
if !params[:search][:created_at_greater_than].blank?
|
83
|
-
params[:search][:created_at_greater_than] = Time.zone.parse(params[:search][:created_at_greater_than]).beginning_of_day rescue ""
|
84
|
-
end
|
85
|
-
if !params[:search][:created_at_less_than].blank?
|
86
|
-
params[:search][:created_at_less_than] = Time.zone.parse(params[:search][:created_at_less_than]).end_of_day rescue ""
|
87
|
-
end
|
88
|
-
if @show_only_completed
|
89
|
-
params[:search][:completed_at_greater_than] = params[:search].delete(:created_at_greater_than)
|
90
|
-
params[:search][:completed_at_less_than] = params[:search].delete(:created_at_less_than)
|
91
|
-
end
|
92
|
-
@orders = Order.metasearch(params[:search]).paginate(
|
93
|
-
:include => [:user, :shipments, :payments],
|
94
|
-
:per_page => Spree::Config[:orders_per_page],
|
95
|
-
:page => params[:page])
|
96
|
-
if current_user.has_role?("vendor")
|
97
|
-
@orders.select! {|o| o.supplier_invoices.select {|s| s.supplier_id == current_user.supplier.id}.size > 0}
|
98
|
-
end
|
99
|
-
respond_with(@orders)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# Append the admin products controller
|
104
|
-
#
|
105
|
-
Admin::ProductsController.class_eval do
|
106
|
-
before_filter :load
|
107
|
-
before_filter :load_index, :only => [:index]
|
108
|
-
before_filter :edit_before, :only => [:edit]
|
109
|
-
create.before :create_before
|
110
|
-
create.fails :reset
|
111
|
-
update.before :update_taxons
|
112
|
-
def load
|
113
|
-
@suppliers = Supplier.find(:all, :order => "name")
|
114
|
-
if !Taxon.find_by_name("Products").nil?
|
115
|
-
@options = Taxon.all
|
116
|
-
end
|
117
|
-
end
|
118
|
-
def load_index
|
119
|
-
if current_user.roles.member?(Role.find_by_name("vendor"))
|
120
|
-
@collection.select! {|c| c.supplier_id == current_user.supplier.id}
|
121
|
-
end
|
122
|
-
end
|
123
|
-
#indicate that we want to create a new product
|
124
|
-
def new
|
125
|
-
@object = Product.new()
|
126
|
-
@status = true
|
127
|
-
end
|
128
|
-
def edit_before
|
129
|
-
@status = false
|
130
|
-
end
|
131
|
-
def taxon_push object
|
132
|
-
object.taxons = []
|
133
|
-
Taxon.all.map {|m| object.taxons.push(Taxon.find_by_id(params[m.name])) if params.member?(m.name)}
|
134
|
-
return object
|
135
|
-
end
|
136
|
-
def reset
|
137
|
-
@status = true
|
138
|
-
end
|
139
|
-
def update_taxons
|
140
|
-
@object = taxon_push(@object)
|
141
|
-
end
|
142
|
-
def create_before
|
143
|
-
if current_user.has_role?("vendor")
|
144
|
-
@object = current_user.supplier.products.build(params[:product])
|
145
|
-
else
|
146
|
-
@object = Product.new(params[:product])
|
147
|
-
end
|
148
|
-
@object = taxon_push(@object)
|
149
|
-
end
|
150
|
-
def publish
|
151
|
-
p = Product.find_by_name(params[:id])
|
152
|
-
p.available_on = Date.today
|
153
|
-
p.save
|
154
|
-
redirect_to edit_admin_product_path(p)
|
155
|
-
end
|
156
|
-
def unpublish
|
157
|
-
p = Product.find_by_name(params[:id])
|
158
|
-
p.available_on = nil
|
159
|
-
p.save
|
160
|
-
redirect_to edit_admin_product_path(p)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
UserSessionsController.class_eval do
|
165
|
-
def create
|
166
|
-
authenticate_user!
|
167
|
-
if user_signed_in?
|
168
|
-
if current_user.has_role?("vendor")
|
169
|
-
redirect_to admin_orders_path
|
170
|
-
else
|
171
|
-
respond_to do |format|
|
172
|
-
format.html {
|
173
|
-
flash[:notice] = I18n.t("logged_in_succesfully")
|
174
|
-
redirect_back_or_default(products_path)
|
175
|
-
}
|
176
|
-
format.js {
|
177
|
-
user = resource.record
|
178
|
-
render :json => {:ship_address => user.ship_address, :bill_address => user.bill_address}.to_json
|
179
|
-
}
|
180
|
-
end
|
181
|
-
end
|
182
|
-
else
|
183
|
-
flash[:error] = I18n.t("devise.failure.invalid")
|
184
|
-
render :new
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
#### Modify the Models with changes that are only associated with the Suppliers extension
|
190
|
-
# Append the product model
|
191
|
-
#
|
192
|
-
Product.class_eval do
|
193
|
-
belongs_to :supplier
|
194
|
-
has_one :item
|
195
|
-
end
|
196
|
-
|
197
|
-
# Append the order model
|
198
|
-
#
|
199
|
-
LineItem.class_eval do
|
200
|
-
has_many :items
|
201
|
-
end
|
202
|
-
|
203
|
-
Image.class_eval do
|
204
|
-
attachment_definitions[:attachment][:styles] = {
|
205
|
-
:mini => '48x48>', # thumbs under image
|
206
|
-
:small => '100x100>', # images on category view
|
207
|
-
:product => '240x240>', # full product image
|
208
|
-
:large => '600x600>' # light box image
|
209
|
-
}
|
210
|
-
end
|
211
|
-
|
212
|
-
# Append the order model
|
213
|
-
#
|
214
|
-
Order.class_eval do
|
215
|
-
has_many :supplier_invoices
|
216
|
-
has_many :deliveries
|
217
|
-
def generate_invoices(order)
|
218
|
-
@order = order
|
219
|
-
@order_products = @order.line_items
|
220
|
-
@suppliers = @order_products.collect{|item| item.product.supplier_id}.uniq
|
221
|
-
@invoices = @suppliers.count
|
222
|
-
|
223
|
-
for i in 0..@invoices - 1
|
224
|
-
@supplier_products = @order_products.select{|x| x.product.supplier_id == @suppliers[i]}
|
225
|
-
@product_count = @supplier_products.count
|
226
|
-
invoice = SupplierInvoice.create(:order_id => @order.id, :supplier_id => @suppliers[i], :item_count => @product_count)
|
227
|
-
|
228
|
-
@supplier_products.each do |item|
|
229
|
-
invoice.items.create(:product_id => item.product.id, :quantity => item.quantity, :line_item_id => item.id)
|
230
|
-
end
|
231
|
-
|
232
|
-
item_total = "0.00".to_d
|
233
|
-
invoice.items.each do |i|
|
234
|
-
item_total = (i.line_item.variant.price * i.quantity) + item_total
|
235
|
-
end
|
236
|
-
invoice.update_attributes(:invoice_total => item_total)
|
237
|
-
@invoice = invoice
|
238
|
-
#SupplierMailer.invoice_email(@invoice).deliver
|
239
|
-
end
|
240
|
-
end
|
241
|
-
def finalize!
|
242
|
-
update_attribute(:completed_at, Time.now)
|
243
|
-
self.out_of_stock_items = InventoryUnit.assign_opening_inventory(self)
|
244
|
-
# lock any optional adjustments (coupon promotions, etc.)
|
245
|
-
adjustments.optional.each { |adjustment| adjustment.update_attribute("locked", true) }
|
246
|
-
# generate the invoices for each supplier
|
247
|
-
generate_invoices(self)
|
248
|
-
OrderMailer.confirm_email(self).deliver
|
249
|
-
|
250
|
-
self.state_events.create({
|
251
|
-
:previous_state => "cart",
|
252
|
-
:next_state => "complete",
|
253
|
-
:name => "order" ,
|
254
|
-
:user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id
|
255
|
-
})
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
# Append the state model
|
260
|
-
#
|
261
|
-
State.class_eval do
|
262
|
-
has_many :suppliers
|
263
|
-
end
|
264
|
-
|
265
|
-
# Append the user model
|
266
|
-
#
|
267
|
-
User.class_eval do
|
268
|
-
belongs_to :supplier
|
269
|
-
def user_address
|
270
|
-
"#{self.bill_address.address1}, #{self.bill_address.city}, #{self.bill_address.state.country.name}"
|
271
|
-
end
|
272
|
-
def vendor?
|
273
|
-
self.roles.member?(Role.find_by_name("vendor"))
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
Taxon.class_eval do
|
278
|
-
has_and_belongs_to_many :suppliers
|
279
|
-
end
|
280
|
-
|
281
|
-
Admin::UsersController.class_eval do
|
282
|
-
def new
|
283
|
-
@user = User.new
|
284
|
-
end
|
285
|
-
def create
|
286
|
-
@user.create(params[:user])
|
287
|
-
if @user.save
|
288
|
-
@user.supplier_id = params[:user][:supplier_id]
|
289
|
-
@user.save
|
290
|
-
flash[:notice] = "User updated successfully."
|
291
|
-
redirect_to :back
|
292
|
-
else
|
293
|
-
flash[:error] = "There was an error updating the user."
|
294
|
-
redirect_to :back
|
295
|
-
end
|
296
|
-
end
|
297
|
-
def edit
|
298
|
-
@user = User.find(params[:id])
|
299
|
-
end
|
300
|
-
def update
|
301
|
-
@user.update_attributes(params[:user])
|
302
|
-
if @user.save
|
303
|
-
@user.supplier_id = params[:user][:supplier_id]
|
304
|
-
@user.save
|
305
|
-
flash[:notice] = "User updated successfully."
|
306
|
-
redirect_to :back
|
307
|
-
else
|
308
|
-
flash[:error] = "There was an error updating the user."
|
309
|
-
redirect_to :back
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
### UGLY HACK
|
315
|
-
Admin::ProductsController.class_eval do
|
316
|
-
def authorize_admin
|
317
|
-
authorize! :admin, Product
|
318
|
-
authorize! params[:action].to_sym, Product
|
319
|
-
end
|
320
|
-
end
|
321
|
-
|
322
|
-
Admin::PromotionsController.class_eval do
|
323
|
-
def authorize_admin
|
324
|
-
authorize! :admin, Promotion
|
325
|
-
authorize! params[:action].to_sym, Promotion
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
Admin::VariantsController.class_eval do
|
330
|
-
def authorize_admin
|
331
|
-
authorize! :admin, Variant
|
332
|
-
authorize! params[:action].to_sym, Variant
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
Admin::OptionTypesController.class_eval do
|
337
|
-
def authorize_admin
|
338
|
-
authorize! :admin, OptionType
|
339
|
-
authorize! params[:action].to_sym, OptionType
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
Admin::PropertiesController.class_eval do
|
344
|
-
def authorize_admin
|
345
|
-
authorize! :admin , Property
|
346
|
-
authorize! params[:action].to_sym, Property
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
Admin::PrototypesController.class_eval do
|
351
|
-
def authorize_admin
|
352
|
-
authorize! :admin, Prototype
|
353
|
-
authorize! params[:action].to_sym, Prototype
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
Admin::ProductGroupsController.class_eval do
|
358
|
-
def authorize_admin
|
359
|
-
authorize! :admin, ProductGroup
|
360
|
-
authorize! params[:action].to_sym, ProductGroup
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
Admin::ProductPropertiesController.class_eval do
|
365
|
-
def authorize_admin
|
366
|
-
authorize! :admin, Product
|
367
|
-
authorize! params[:action].to_sym, Product
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
Admin::TaxonsController.class_eval do
|
372
|
-
def authorize_admin
|
373
|
-
authorize! :admin, Taxon
|
374
|
-
authorize! params[:action].to_sym, Taxon
|
375
|
-
end
|
376
|
-
end
|
377
|
-
|
378
|
-
Admin::PickupsController.class_eval do
|
379
|
-
def authorize_admin
|
380
|
-
authorize! :admin, Pickup
|
381
|
-
authorize! params[:action].to_sym, Pickup
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
Admin::PickupLocationsController.class_eval do
|
386
|
-
def authorize_admin
|
387
|
-
authorize! :admin, PickupLocation
|
388
|
-
authorize! params[:action].to_sym, PickupLocation
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
Admin::OrdersController.class_eval do
|
393
|
-
def authorize_admin
|
394
|
-
authorize! :admin, Order
|
395
|
-
authorize! params[:action].to_sym, Order
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
Admin::SuppliersController.class_eval do
|
400
|
-
def authorize_admin
|
401
|
-
authorize! :admin, Supplier
|
402
|
-
authorize! params[:action].to_sym, Supplier
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
|
-
### END UGLY HACK
|
407
|
-
end
|
408
|
-
|
409
|
-
config.to_prepare &method(:activate).to_proc
|
410
|
-
end
|
411
|
-
end
|