From 3e9b9c6b8b3a428818b16da5be0c50d99947489b Mon Sep 17 00:00:00 2001 From: yamin Date: Wed, 16 Aug 2017 10:46:03 +0630 Subject: [PATCH 1/4] CalculatePriceInDiningCharges --- .../settings/dining_charges_controller.rb | 2 +- .../settings/dining_charges/_form.html.erb | 43 +++++++++++++++++-- .../settings/dining_charges/new.html.erb | 6 +-- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/app/controllers/settings/dining_charges_controller.rb b/app/controllers/settings/dining_charges_controller.rb index 31763b02..854354c2 100644 --- a/app/controllers/settings/dining_charges_controller.rb +++ b/app/controllers/settings/dining_charges_controller.rb @@ -97,6 +97,6 @@ class Settings::DiningChargesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def dining_charge_params # params.fetch(:dining_charge, {}) - params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id) + params.require(:dining_charge).permit(:item_code, :unit_price, :taxable, :charge_type,:minimum_free_time ,:charge_block,:time_rounding,:time_rounding_block, :zone_id, :time_rounding_block_price) end end diff --git a/app/views/settings/dining_charges/_form.html.erb b/app/views/settings/dining_charges/_form.html.erb index 2349025a..5cc25062 100644 --- a/app/views/settings/dining_charges/_form.html.erb +++ b/app/views/settings/dining_charges/_form.html.erb @@ -3,13 +3,14 @@
<%= f.input :item_code, :input_html => { :id => 'item_code' } %> - <%= f.input :unit_price %> + <%= f.input :unit_price, :input_html => { :id => 'unit_price'} %> <%= f.input :taxable %> <%= f.input :charge_type, :collection => [:hr, :day] %> <%= f.input :minimum_free_time %> - <%= f.input :charge_block %> + <%= f.input :charge_block, :input_html => { :id => 'charge_block'} %> <%= f.input :time_rounding %> - <%= f.input :time_rounding_block %> + <%= f.input :time_rounding_block, :input_html => { :id => 'time_rounding_block'} %> + <%= f.input :time_rounding_block_price, :input_html => { :id => 'time_rounding_block_price'} %>
@@ -17,3 +18,39 @@
<% end %> + diff --git a/app/views/settings/dining_charges/new.html.erb b/app/views/settings/dining_charges/new.html.erb index 2aa13a4b..bece2a2e 100644 --- a/app/views/settings/dining_charges/new.html.erb +++ b/app/views/settings/dining_charges/new.html.erb @@ -16,8 +16,9 @@ <%= render 'form', dining_charge: @dining_charge %> + \ No newline at end of file From db43ae186c45812bc9213e58f320ca5fae1d15e1 Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 16 Aug 2017 11:00:37 +0630 Subject: [PATCH 2/4] DB for promtion, promotion product,product --- config/routes.rb | 3 +++ db/migrate/20170815044557_create_promotion.rb | 18 ++++++++++++++++++ .../20170815051517_create_promotion_product.rb | 13 +++++++++++++ db/migrate/20170816042256_create_product.rb | 17 +++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 db/migrate/20170815044557_create_promotion.rb create mode 100644 db/migrate/20170815051517_create_promotion_product.rb create mode 100644 db/migrate/20170816042256_create_product.rb diff --git a/config/routes.rb b/config/routes.rb index 9e62023c..241c3826 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -264,6 +264,9 @@ Rails.application.routes.draw do end end + #promotion + resources :promotions + end #--------- Transactions Sections ------------# diff --git a/db/migrate/20170815044557_create_promotion.rb b/db/migrate/20170815044557_create_promotion.rb new file mode 100644 index 00000000..124ad8d9 --- /dev/null +++ b/db/migrate/20170815044557_create_promotion.rb @@ -0,0 +1,18 @@ +class CreatePromotion < ActiveRecord::Migration[5.1] + def change + create_table :promotions do |t| + t.string :promo_code, :limit => 16 + + t.datetime :promo_start_date, :null => false + t.datetime :promo_end_date, :null => false + t.time :promo_start_hour, :null => false + t.time :promo_end_hour, :null => false + t.string :promo_day, :null => false, :default => "[0,1,2,3,4,5,6]" + t.string :promo_type, :null => false, :default => "Quantity" + t.string :original_product + t.integer :min_qty + t.string :created_by, :null => false + t.timestamps + end + end +end diff --git a/db/migrate/20170815051517_create_promotion_product.rb b/db/migrate/20170815051517_create_promotion_product.rb new file mode 100644 index 00000000..dbbc198a --- /dev/null +++ b/db/migrate/20170815051517_create_promotion_product.rb @@ -0,0 +1,13 @@ +class CreatePromotionProduct < ActiveRecord::Migration[5.1] + def change + create_table :promotion_products do |t| + t.references :promotion, foreign_key: true + t.string :item_code, :null => false + t.integer :min_qty + t.integer :net_off + t.integer :net_price + t.integer :percentage + t.timestamps + end + end +end diff --git a/db/migrate/20170816042256_create_product.rb b/db/migrate/20170816042256_create_product.rb new file mode 100644 index 00000000..a329d69b --- /dev/null +++ b/db/migrate/20170816042256_create_product.rb @@ -0,0 +1,17 @@ +class CreateProduct < ActiveRecord::Migration[5.1] + def change + create_table :products do |t| + t.string :item_code, :limit => 16 + + t.string :name, :null => false + t.string :alt_name + t.integer :unit_price + t.string :image_path + t.string :description + t.string :information + t.boolean :taxable + t.string :created_by, :null => false + t.timestamps + end + end +end From 4fc748e877512213d373b132e292fe70c8807994 Mon Sep 17 00:00:00 2001 From: yamin Date: Wed, 16 Aug 2017 18:19:20 +0630 Subject: [PATCH 3/4] CRUDforProducts --- .../settings/products_controller.rb | 76 +++++++++++++++++++ app/models/product.rb | 3 + app/views/layouts/_header.html.erb | 2 + app/views/settings/products/_form.html.erb | 18 +++++ .../products/_settings_product.json.jbuilder | 2 + app/views/settings/products/edit.html.erb | 10 +++ app/views/settings/products/index.html.erb | 45 +++++++++++ .../settings/products/index.json.jbuilder | 1 + app/views/settings/products/new.html.erb | 26 +++++++ app/views/settings/products/show.html.erb | 33 ++++++++ .../settings/products/show.json.jbuilder | 1 + config/routes.rb | 2 + ...rb => 20170816042256_settings_products.rb} | 2 +- 13 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 app/controllers/settings/products_controller.rb create mode 100644 app/models/product.rb create mode 100644 app/views/settings/products/_form.html.erb create mode 100644 app/views/settings/products/_settings_product.json.jbuilder create mode 100644 app/views/settings/products/edit.html.erb create mode 100644 app/views/settings/products/index.html.erb create mode 100644 app/views/settings/products/index.json.jbuilder create mode 100644 app/views/settings/products/new.html.erb create mode 100644 app/views/settings/products/show.html.erb create mode 100644 app/views/settings/products/show.json.jbuilder rename db/migrate/{20170816042256_create_product.rb => 20170816042256_settings_products.rb} (87%) diff --git a/app/controllers/settings/products_controller.rb b/app/controllers/settings/products_controller.rb new file mode 100644 index 00000000..0c2fa15d --- /dev/null +++ b/app/controllers/settings/products_controller.rb @@ -0,0 +1,76 @@ +class Settings::ProductsController < ApplicationController + before_action :set_settings_product, only: [:show, :edit, :update, :destroy] + + # GET /settings/products + # GET /settings/products.json + def index + @settings_products = Product.all + end + + # GET /settings/products/1 + # GET /settings/products/1.json + def show + end + + # GET /settings/products/new + def new + @settings_product = Product.new + end + + # GET /settings/products/1/edit + def edit + end + + # POST /settings/products + # POST /settings/products.json + def create + + @settings_product = Product.new(settings_product_params) + @settings_product.created_by = current_user.name + respond_to do |format| + if @settings_product.save + format.html { redirect_to settings_products_path, notice: 'Product was successfully created.' } + format.json { render :show, status: :created, location: @settings_product } + else + format.html { render :new } + format.json { render json: @settings_product.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /settings/products/1 + # PATCH/PUT /settings/products/1.json + def update + respond_to do |format| + if @settings_product.update(settings_product_params) + format.html { redirect_to settings_product_path, notice: 'Product was successfully updated.' } + format.json { render :show, status: :ok, location: @settings_product } + else + format.html { render :edit } + format.json { render json: @settings_product.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /settings/products/1 + # DELETE /settings/products/1.json + def destroy + @settings_product.destroy + respond_to do |format| + format.html { redirect_to settings_products_path, notice: 'Product was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_settings_product + @settings_product = Product.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def settings_product_params + params.require(:product).permit(:item_code, :name, :alt_name, :unit_price, :image_path, :description, :information, :taxable,:created_by) + end + +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100644 index 00000000..042e1730 --- /dev/null +++ b/app/models/product.rb @@ -0,0 +1,3 @@ +class Product < ApplicationRecord + validates_presence_of :name +end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index bc5ce498..441cfe91 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -28,6 +28,8 @@
  • <%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %>

  • <%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %>
  • +
    +
  • <%= link_to "Products", settings_products_path, :tabindex =>"-1" %>
  • diff --git a/app/views/settings/products/_form.html.erb b/app/views/settings/products/_form.html.erb new file mode 100644 index 00000000..37a049c6 --- /dev/null +++ b/app/views/settings/products/_form.html.erb @@ -0,0 +1,18 @@ +<%= simple_form_for([:settings,@settings_product]) do |f| %> + <%= f.error_notification %> + +
    + <%= f.input :item_code, :input_html => { :id => 'item_code' } %> + <%= f.input :name %> + <%= f.input :alt_name %> + <%= f.input :unit_price %> + <%= f.input :image_path %> + <%= f.input :description %> + <%= f.input :information %> + +
    + +
    + <%= f.button :submit %> +
    +<% end %> diff --git a/app/views/settings/products/_settings_product.json.jbuilder b/app/views/settings/products/_settings_product.json.jbuilder new file mode 100644 index 00000000..608fdefb --- /dev/null +++ b/app/views/settings/products/_settings_product.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! settings_product, :id, :created_at, :updated_at +json.url settings_product_url(settings_product, format: :json) diff --git a/app/views/settings/products/edit.html.erb b/app/views/settings/products/edit.html.erb new file mode 100644 index 00000000..634381df --- /dev/null +++ b/app/views/settings/products/edit.html.erb @@ -0,0 +1,10 @@ +
    + + <%= render 'form', settings_product: @settings_product %> +
    diff --git a/app/views/settings/products/index.html.erb b/app/views/settings/products/index.html.erb new file mode 100644 index 00000000..3f49a401 --- /dev/null +++ b/app/views/settings/products/index.html.erb @@ -0,0 +1,45 @@ + + +
    +
    + + + + + + + + + + + + + + + + + <% @settings_products.each do |settings_product| %> + + + + + + + + + + + + + <% end %> + +
    Item CodeNameAlt NameUnit PriceDescriptionInformationTaxable
    <%= settings_product.item_code %><%= settings_product.name %><%= settings_product.alt_name %><%= settings_product.unit_price %><%= settings_product.description %><%= settings_product.information %><%= settings_product.taxable %><%= link_to 'Show', settings_product_path(settings_product) %><%= link_to 'Edit', edit_settings_product_path(settings_product) %><%= link_to 'Destroy', settings_product_path(settings_product), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    diff --git a/app/views/settings/products/index.json.jbuilder b/app/views/settings/products/index.json.jbuilder new file mode 100644 index 00000000..bc08f2a7 --- /dev/null +++ b/app/views/settings/products/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @settings_products, partial: 'settings_products/settings_product', as: :settings_product diff --git a/app/views/settings/products/new.html.erb b/app/views/settings/products/new.html.erb new file mode 100644 index 00000000..e971f70d --- /dev/null +++ b/app/views/settings/products/new.html.erb @@ -0,0 +1,26 @@ +
    + + <%= render 'form', settings_product: @settings_product %> +
    + + diff --git a/app/views/settings/products/show.html.erb b/app/views/settings/products/show.html.erb new file mode 100644 index 00000000..f16b5426 --- /dev/null +++ b/app/views/settings/products/show.html.erb @@ -0,0 +1,33 @@ + +
    +
    +

    Product

    + + + + + + + + + + + + + + + + +
    Item code<%= @settings_product.item_code %>
    Name<%= @settings_product.name %>
    Alt name<%= @settings_product.alt_name %>
    Unit price<%= @settings_product.unit_price %>
    Image path<%= image_tag @settings_product.image_path, :size => '200x200'%>
    Description<%= @settings_product.description %>
    Information<%= @settings_product.information %>
    Taxable<%= @settings_product.taxable %>
    <%= link_to 'Edit', edit_settings_product_path(@settings_product) %><%= link_to 'Destroy', settings_product_path(@settings_product), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    +
    + + diff --git a/app/views/settings/products/show.json.jbuilder b/app/views/settings/products/show.json.jbuilder new file mode 100644 index 00000000..aef1705d --- /dev/null +++ b/app/views/settings/products/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "settings_products/settings_product", settings_product: @settings_product diff --git a/config/routes.rb b/config/routes.rb index 51431474..93a7985a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -237,6 +237,8 @@ Rails.application.routes.draw do resources :menu_item_options #tax_profiles resources :tax_profiles + #products + resources :products #lookups resources :lookups #cashier_terminals diff --git a/db/migrate/20170816042256_create_product.rb b/db/migrate/20170816042256_settings_products.rb similarity index 87% rename from db/migrate/20170816042256_create_product.rb rename to db/migrate/20170816042256_settings_products.rb index a329d69b..69c790fc 100644 --- a/db/migrate/20170816042256_create_product.rb +++ b/db/migrate/20170816042256_settings_products.rb @@ -1,4 +1,4 @@ -class CreateProduct < ActiveRecord::Migration[5.1] +class SettingsProducts < ActiveRecord::Migration[5.1] def change create_table :products do |t| t.string :item_code, :limit => 16 From fc2927b341a7a55d8bd24f1bbbbaaa6a5ce51468 Mon Sep 17 00:00:00 2001 From: Phyo Date: Wed, 16 Aug 2017 18:36:23 +0630 Subject: [PATCH 4/4] Promotion CRUD --- .../settings/promotions_controller.rb | 76 +++++++++++++++++++ app/helpers/settings/promotions_helper.rb | 2 + app/models/promotion.rb | 2 + app/views/layouts/_header.html.erb | 2 + app/views/settings/promotions/_form.html.erb | 48 ++++++++++++ .../promotions/_promotion.json.jbuilder | 2 + app/views/settings/promotions/edit.html.erb | 10 +++ app/views/settings/promotions/index.html.erb | 58 ++++++++++++++ .../settings/promotions/index.json.jbuilder | 1 + app/views/settings/promotions/new.html.erb | 17 +++++ app/views/settings/promotions/show.html.erb | 4 + .../settings/promotions/show.json.jbuilder | 1 + db/migrate/20170815044557_create_promotion.rb | 4 +- 13 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 app/controllers/settings/promotions_controller.rb create mode 100644 app/helpers/settings/promotions_helper.rb create mode 100644 app/models/promotion.rb create mode 100644 app/views/settings/promotions/_form.html.erb create mode 100644 app/views/settings/promotions/_promotion.json.jbuilder create mode 100644 app/views/settings/promotions/edit.html.erb create mode 100644 app/views/settings/promotions/index.html.erb create mode 100644 app/views/settings/promotions/index.json.jbuilder create mode 100644 app/views/settings/promotions/new.html.erb create mode 100644 app/views/settings/promotions/show.html.erb create mode 100644 app/views/settings/promotions/show.json.jbuilder diff --git a/app/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb new file mode 100644 index 00000000..277cf62d --- /dev/null +++ b/app/controllers/settings/promotions_controller.rb @@ -0,0 +1,76 @@ +class Settings::PromotionsController < ApplicationController + before_action :set_promotion, only: [:show, :edit, :update, :destroy] + + # GET /promotions + # GET /promotions.json + def index + @promotions = Promotion.all + end + + # GET /promotions/1 + # GET /promotions/1.json + def show + end + + # GET /promotions/new + def new + @promotion = Promotion.new + @promotion.promo_start_date = DateTime.now + @promotion.promo_end_date = DateTime.now + end + + # GET /promotions/1/edit + def edit + end + + # POST /promotions + # POST /promotions.json + def create + @promotion = Promotion.new(promotion_params) + @promotion.created_by = current_login_employee.id + respond_to do |format| + if @promotion.save + format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully created.' } + format.json { render :show, status: :created, location: @promotion } + else + format.html { render :new } + format.json { render json: @promotion.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /promotions/1 + # PATCH/PUT /promotions/1.json + def update + respond_to do |format| + if @promotion.update(promotion_params) + format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully updated.' } + format.json { render :show, status: :ok, location: @promotion } + else + format.html { render :edit } + format.json { render json: @promotion.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /promotions/1 + # DELETE /promotions/1.json + def destroy + @promotion.destroy + respond_to do |format| + format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_promotion + @promotion = Promotion.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def promotion_params + params.require(:promotion).permit(:promo_code, :promo_start_date, :promo_end_date, :promo_start_hour,:promo_end_hour ,:promo_day, :promo_type,:original_product ,:min_qty ,:created_by) + end +end diff --git a/app/helpers/settings/promotions_helper.rb b/app/helpers/settings/promotions_helper.rb new file mode 100644 index 00000000..787c2194 --- /dev/null +++ b/app/helpers/settings/promotions_helper.rb @@ -0,0 +1,2 @@ +module Settings::PromotionsHelper +end diff --git a/app/models/promotion.rb b/app/models/promotion.rb new file mode 100644 index 00000000..9b5c4c12 --- /dev/null +++ b/app/models/promotion.rb @@ -0,0 +1,2 @@ +class Promotion < ApplicationRecord +end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index bc5ce498..df1e13ce 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -28,6 +28,8 @@
  • <%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %>

  • <%= link_to "Accounts", settings_accounts_path, :tabindex =>"-1" %>
  • +
    +
  • <%= link_to "Promotion", settings_promotions_path, :tabindex =>"-1" %>
  • diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb new file mode 100644 index 00000000..98dbb7fe --- /dev/null +++ b/app/views/settings/promotions/_form.html.erb @@ -0,0 +1,48 @@ +<%= simple_form_for([:settings,@promotion]) do |f| %> + <%= f.error_notification %> + +
    +
    +
    +
    <%= f.input :promo_code %>
    +
    +
    +
    +
    + Promo Start Date + <%= f.date_field :promo_start_date, :placeholder => "From Date" , :class => "form-control"%> +
    +
    +
    + Promo End Date + <%= f.date_field :promo_end_date ,:placeholder => "To Date" , :class => "form-control"%> +
    +
    +
    +
    + <%= f.input :promo_start_hour %> + +
    +
    <%= f.input :promo_end_hour %>
    +
    +
    +
    <%= f.input :promo_day %>
    +
    +
    +
    + <%= f.input :promo_type,input_html: { class: "" }, + collection: %w{Quantity Net_off Net_price Percentage},:class => 'form-control' ,:label => "" %> +
    +
    +
    +
    <%= f.input :original_product,collection: MenuItem.order("name desc"),input_html: { selected: 2 } %>
    +
    <%= f.input :min_qty %>
    +
    +
    +
    + +
    + <%= f.button :submit %> +
    +<% end %> diff --git a/app/views/settings/promotions/_promotion.json.jbuilder b/app/views/settings/promotions/_promotion.json.jbuilder new file mode 100644 index 00000000..d9b08aef --- /dev/null +++ b/app/views/settings/promotions/_promotion.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! promotion, :id, :created_at, :updated_at +json.url promotion_url(promotion, format: :json) diff --git a/app/views/settings/promotions/edit.html.erb b/app/views/settings/promotions/edit.html.erb new file mode 100644 index 00000000..47a01b80 --- /dev/null +++ b/app/views/settings/promotions/edit.html.erb @@ -0,0 +1,10 @@ +
    + + <%= render 'form', promotion: @promotion %> +
    diff --git a/app/views/settings/promotions/index.html.erb b/app/views/settings/promotions/index.html.erb new file mode 100644 index 00000000..606b138b --- /dev/null +++ b/app/views/settings/promotions/index.html.erb @@ -0,0 +1,58 @@ +

    <%= notice %>

    + + + + +
    +
    + + + + + + + + + + + + + + + + + + <% @promotions.each do |pro| %> + + + + + + + + + <% if Employee.exists?(pro.created_by) %> + + <% else %> + + <% end %> + + + + + <% end %> + +
    Promotion CodeStart DateEnd DateStart TimeEnd TimePromotion DayOriginal ProductCreated ByCreated At
    <%= link_to pro.promo_code, settings_promotion_path(pro) %><%= pro.promo_start_date %><%= pro.promo_end_date %><%= pro.promo_start_hour.strftime("%I:%M %P") rescue "-" %><%= pro.promo_end_hour.strftime("%I:%M %P") rescue "-" %><%= pro.promo_day %> + <% if MenuItem.exists?(pro.original_product) %> + <%= MenuItem.find(pro.original_product).name %> + <% end %> + <%= Employee.find(pro.created_by).name %><%= pro.created_by %><%= pro.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Edit', edit_settings_promotion_path(pro) %><%= link_to 'Destroy', settings_promotion_path(pro), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    diff --git a/app/views/settings/promotions/index.json.jbuilder b/app/views/settings/promotions/index.json.jbuilder new file mode 100644 index 00000000..1c9c5f97 --- /dev/null +++ b/app/views/settings/promotions/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @promotions, partial: 'promotions/promotion', as: :promotion diff --git a/app/views/settings/promotions/new.html.erb b/app/views/settings/promotions/new.html.erb new file mode 100644 index 00000000..c7748bb6 --- /dev/null +++ b/app/views/settings/promotions/new.html.erb @@ -0,0 +1,17 @@ + +
    + + <%= render 'form', promotion: @promotion %> +
    + diff --git a/app/views/settings/promotions/show.html.erb b/app/views/settings/promotions/show.html.erb new file mode 100644 index 00000000..4dd7e593 --- /dev/null +++ b/app/views/settings/promotions/show.html.erb @@ -0,0 +1,4 @@ +

    <%= notice %>

    + +<%= link_to 'Edit', edit_promotion_path(@promotion) %> | +<%= link_to 'Back', promotions_path %> diff --git a/app/views/settings/promotions/show.json.jbuilder b/app/views/settings/promotions/show.json.jbuilder new file mode 100644 index 00000000..52507108 --- /dev/null +++ b/app/views/settings/promotions/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "promotions/promotion", promotion: @promotion diff --git a/db/migrate/20170815044557_create_promotion.rb b/db/migrate/20170815044557_create_promotion.rb index 124ad8d9..fddf293b 100644 --- a/db/migrate/20170815044557_create_promotion.rb +++ b/db/migrate/20170815044557_create_promotion.rb @@ -3,8 +3,8 @@ class CreatePromotion < ActiveRecord::Migration[5.1] create_table :promotions do |t| t.string :promo_code, :limit => 16 - t.datetime :promo_start_date, :null => false - t.datetime :promo_end_date, :null => false + t.date :promo_start_date, :null => false + t.date :promo_end_date, :null => false t.time :promo_start_hour, :null => false t.time :promo_end_hour, :null => false t.string :promo_day, :null => false, :default => "[0,1,2,3,4,5,6]"