diff --git a/.gitignore b/.gitignore index 42a48b40..98acc705 100644 --- a/.gitignore +++ b/.gitignore @@ -47,9 +47,9 @@ config/deploy/config/* #Gemfile.lock # For Redis Server log file -dump.rdb +/dump.rdb -# Fonts +# Fonts public/fonts/* # Ruby-Mine IDE folder diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 705b1a97..ab924a87 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,17 +3,9 @@ - - + - - - - - - - - + @@ -28,7 +20,7 @@ - + @@ -55,20 +47,60 @@ - - + + - - + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -76,64 +108,10 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -173,12 +151,6 @@ @@ -303,53 +281,26 @@ - + - - + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +
+
+
+
+ Product +
+
+ +
+
+
+
+
+
+ Qty +
+
+ +
+
+
+
+
+
+ +
+
+ - - - - - - +
+
+
+
+ + + + + +
#ProductBalance
+ + + +
+
+ +
+
+ - - <% @stock_checks.each do |stock_check| %> - - <%= link_to 'Show', stock_check %> - <%= link_to 'Edit', edit_stock_check_path(stock_check) %> - <%= link_to 'Destroy', stock_check, method: :delete, data: { confirm: 'Are you sure?' } %> - - <% end %> - - + diff --git a/app/views/inventory/stock_checks/index.json.jbuilder b/app/views/inventory/stock_checks/index.json.jbuilder deleted file mode 100644 index 23740183..00000000 --- a/app/views/inventory/stock_checks/index.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.array! @stock_checks, partial: 'stock_checks/stock_check', as: :stock_check diff --git a/app/views/inventory/stock_checks/new.html.erb b/app/views/inventory/stock_checks/new.html.erb deleted file mode 100644 index 503af621..00000000 --- a/app/views/inventory/stock_checks/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

New Stock Check

- -<%= render 'form', stock_check: @stock_check %> - -<%= link_to 'Back', stock_checks_path %> diff --git a/app/views/inventory/stock_checks/show.html.erb b/app/views/inventory/stock_checks/show.html.erb index 6c306d8d..4d0e83d0 100644 --- a/app/views/inventory/stock_checks/show.html.erb +++ b/app/views/inventory/stock_checks/show.html.erb @@ -1,4 +1,83 @@ -

<%= notice %>

+
+ +
+
+
+ Check by +
+
+ <%= @check.check_by %> +
+
+
+
+ Check At +
+
+ <%= @check.created_at %>
+
+
+
+ Reason +
+
+ <%= @check.reason %> +
+
+
+
+ + + + + + + + + + <% + count = 0 + @check.stock_check_items.each do |item| + count += 1 + %> + + + + + + + + + <% end %> +
#ProductStock CountStock BalanceDifferentRemark
<%= count %><%= item.item_code %><%= item.stock_count %><%= item.stock_balance %><%= item.different %><%= item.remark %>
+
+
+
+ + + +
+
-<%= link_to 'Edit', edit_stock_check_path(@stock_check) %> | -<%= link_to 'Back', stock_checks_path %> + diff --git a/app/views/inventory/stock_checks/show.json.jbuilder b/app/views/inventory/stock_checks/show.json.jbuilder deleted file mode 100644 index 1a4ad710..00000000 --- a/app/views/inventory/stock_checks/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.partial! "stock_checks/stock_check", stock_check: @stock_check diff --git a/app/views/layouts/inventory.html.erb b/app/views/layouts/inventory.html.erb index 5bcf7e0a..d6bbf436 100644 --- a/app/views/layouts/inventory.html.erb +++ b/app/views/layouts/inventory.html.erb @@ -9,7 +9,7 @@ SmartSales : Restaurant <%= csrf_meta_tags %> - <%= stylesheet_link_tag 'inventory', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> <%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %> <%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %> diff --git a/app/views/origami/in_juties/_assign_in_juty.html.erb b/app/views/origami/in_juties/_assign_in_juty.html.erb index 62531529..b6363195 100644 --- a/app/views/origami/in_juties/_assign_in_juty.html.erb +++ b/app/views/origami/in_juties/_assign_in_juty.html.erb @@ -18,7 +18,7 @@ <%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %> - <%= f.input :out_time, :placeholder => "From Date", :class => "form-control" %> + <%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %>
diff --git a/app/views/origami/in_juties/_edit_in_juty.html.erb b/app/views/origami/in_juties/_edit_in_juty.html.erb index 9eaf8353..a297ac65 100644 --- a/app/views/origami/in_juties/_edit_in_juty.html.erb +++ b/app/views/origami/in_juties/_edit_in_juty.html.erb @@ -1,13 +1,14 @@ -<%= simple_form_for([:origami,@in_juty]) do |f| %> - <%= f.error_notification %> +<%= simple_form_for([:origami, @in_juty]) do |f| %> + <%= f.error_notification %> -
- <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>

- <%= f.input :in_time %> - <%= f.input :out_time %> -
+
+ <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %> +

+ <%= f.input :in_time %> + <%= f.input :out_time %> +
-
- <%= f.button :submit %> -
-<% end %> \ No newline at end of file +
+ <%= f.button :submit %> +
+<% end %> diff --git a/app/views/origami/in_juties/_form.html.erb b/app/views/origami/in_juties/_form.html.erb index d67df51b..9bed9152 100644 --- a/app/views/origami/in_juties/_form.html.erb +++ b/app/views/origami/in_juties/_form.html.erb @@ -1,33 +1,43 @@ -
-<%= simple_form_for([:origami,@in_juty]) do |f| %> - <%= f.error_notification %> +<%= simple_form_for @in_juty, :url => origami_index_in_juty_path(@table.id), :method => :post do |f| %> + + <%= f.error_notification %> + <%= f.hidden_field :id, :class => "form-control col-md-6 " %> + +
+ + <%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %> + + + <%= @table.name %> +
+
+ + + <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %> +

+ + <%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %> + + <%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %> + +

+ +
+ <% f.button :submit, "Create", :class => 'btn btn-primary ', :id => 'create' %> + <% f.button :submit, "Update", :class => 'btn btn-primary ', :disabled => '', :id => 'update' %> + <% f.button :button, "Reset", :class => 'btn btn-danger ', :id => 'reset' %> +
+
+ <%= f.button :submit, :class => 'btn btn-primary' %> +
-
- <%= f.label :dinning_id %> - <%= f.collection_select :dinning_id, DiningFacility.all, :id, :name, {prompt: 'Select Dining Facilities'}, {class: 'form-control'} %>
- <%= f.label :commissioner_ids %> - <%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
- - <%= f.text_field :in_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%>
- - <%= f.text_field :out_time, :value=>DateTime.now.strftime("%Y-%m-%d / %I:%M %p"),:class=>"form-control datepicker"%> -

-
- <%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %> - <%= f.button :submit, class: 'btn btn-info' %> -
<% end %> -
+ \ No newline at end of file + }); + + diff --git a/app/views/origami/in_juties/index.html.erb b/app/views/origami/in_juties/index.html.erb index 6efeb999..ff5a0fd3 100644 --- a/app/views/origami/in_juties/index.html.erb +++ b/app/views/origami/in_juties/index.html.erb @@ -1,38 +1,91 @@ - -
-
- - - - - - - - - - - - - <% @in_juties.each do |in_juty| %> - - - - - - - - - - <% end %> - -
Dining Facility NameCommissioner IdsIn timeOut time
<%= in_juty.dining_facility.name rescue '-' %><%= in_juty.commissioner.name rescue '-' %><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %><%= link_to 'Show', origami_in_juty_path(in_juty) %><%= link_to 'Edit', edit_origami_in_juty_path(in_juty) %><%= link_to 'Destroy', origami_in_juty_path(in_juty), method: :delete, data: {confirm: 'Are you sure?'} %>
+
+
+ + + diff --git a/app/views/origami/in_juties/index_in_juty.html.erb b/app/views/origami/in_juties/index_in_juty.html.erb index bbb9912b..52d79c89 100644 --- a/app/views/origami/in_juties/index_in_juty.html.erb +++ b/app/views/origami/in_juties/index_in_juty.html.erb @@ -22,7 +22,7 @@ <%= in_juty.commissioner.name rescue '-' %> <%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> <%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %> - <%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %> + <%= link_to 'Remove', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %> <% end %> @@ -30,13 +30,14 @@ <%= paginate @juties_in %>
-
- <%= render 'assign_in_juty', in_juty: @in_juty, table: @table %> +
+ <%= render 'form', in_juty: @in_juty, table: @table %>
-
- +
+      +
diff --git a/app/views/origami/in_juties/new.html.erb b/app/views/origami/in_juties/new.html.erb index eb34f01c..f59ff6fd 100644 --- a/app/views/origami/in_juties/new.html.erb +++ b/app/views/origami/in_juties/new.html.erb @@ -6,5 +6,5 @@
  • New
  • - <%= render 'form', in_juty: @in_juty %> + <%= render 'form', in_juty: @in_juty, table: @table %> diff --git a/app/views/settings/promotions/_form.html.erb b/app/views/settings/promotions/_form.html.erb index 6a421ade..bea1f981 100644 --- a/app/views/settings/promotions/_form.html.erb +++ b/app/views/settings/promotions/_form.html.erb @@ -58,32 +58,79 @@
    -
    <%= f.input :original_product,collection: MenuItem.order("name desc").pluck(:name,:item_code),input_html: { selected: 2 } %>
    + <% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> + <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> + <% arr.push(p) %> + <% end %> +
    + + + +
    + + <% sample = [] %> + <% if !@promotion.original_product.nil? %> + <% if !MenuItemInstance.find_by_item_instance_code(@promotion.original_product).nil? %> + <% sample = MenuItemInstance.where("item_instance_code=?",@promotion.original_product).pluck(:item_instance_name,:item_instance_code)%> + <% else %> + <% sample = Product.where("item_code=?",@promotion.original_product).pluck(:name,:item_code)%> + <% end %> + <% end %> +
    <%= f.input :original_product,collection: sample %>
    +
    <%= f.input :min_qty %>

    -
    Item Code
    +
    Item Code
    Min Qty
    Net off
    Net Price
    -
    Percentage
    -
    +
    Percentage
    +
    <%= f.fields_for :promotion_products do |pro| %>
    -
    <%= pro.input :item_code, label: false,collection: MenuItem.order("name desc").pluck(:name,:item_code)%>
    + <% arr = MenuItem.active.order("name desc").pluck(:name,:item_code) %> + <% Product.order("name desc").pluck(:name,:item_code).each do |p| %> + <% arr.push(p) %> + <% end %> +
    + +
    + <% sample = [] %> +
    <%= pro.input :item_code, :class => 'promoproduct', collection: sample,input_html: { selected: 2 }, label: false %>
    <%= pro.input :min_qty , label: false%>
    <%= pro.input :net_off , label: false %>
    <%= pro.input :net_price , label: false %>
    -
    <%= pro.input :percentage , label: false %>
    -
    <%= pro.link_to_remove "X" %>
    +
    <%= pro.input :percentage , label: false %>
    +
    <%= pro.link_to_remove "X" %>
    <% end %>
    -
    <%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary' %>
    +
    <%= f.link_to_add "Add Product", :promotion_products, :class => 'btn btn-primary addProduct' %>
    @@ -114,7 +161,6 @@ $(document).ready(function(){ datepicker:false, format:'H:m' }); -}); @@ -148,5 +194,56 @@ $(".select").click(function() { document.getElementById("promotion_promo_day").value = day; }); - + $("#promotion_original_product").select2(); + $(".item_code_place").select2(); + $(".item_code_place").on('change', function(event) { + var ajax_url = "<%= settings_find_item_instance_path %>"; + var item_code = this.value; + $.ajax({ + type: "GET", + url: ajax_url, + data: 'item_code=' + item_code, + success: function (result) { + $("#promotion_original_product").empty(); + var itemlist; + for (var i = 0; i < result.length; i++) { + itemlist += "" + } + $("#promotion_original_product").append(itemlist); + $("#promotion_original_product").select2(); + } + }); + }); + $(".promotion_promotion_products_item_code select").select2(); + $(".item_code_place1").select2(); + callforpromoproduct(); + $(".addProduct").on('click', function(event) { + setTimeout(function(){ + $(".promotion_promotion_products_item_code select").select2(); + callforpromoproduct(); + }, 0); + }); + function callforpromoproduct(){ + $(".item_code_place1").select2(); + $(".item_code_place1").on('change', function(event) { + id = $(this).parent().next().find("select").attr("id"); + var ajax_url = "<%= settings_find_item_instance_path %>"; + var item_code = this.value; + $.ajax({ + type: "GET", + url: ajax_url, + data: 'item_code=' + item_code, + success: function (result) { + $("#"+id).empty(); + var itemlist; + for (var i = 0; i < result.length; i++) { + itemlist += "" + } + $("#"+id).append(itemlist); + $("#"+id).select2(); + } + }); + }); + } +}); diff --git a/config/routes.rb b/config/routes.rb index 1130bf36..344eab43 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -292,6 +292,7 @@ Rails.application.routes.draw do resources :promotions do resources :promotion_products end + get '/find_item_instance' => 'promotions#find_item_instance', as:'find_item_instance' # commission resources :commissions @@ -334,9 +335,13 @@ Rails.application.routes.draw do # ----------- Inventory --------------------------- namespace :inventory do - get 'inventory' => 'inventory#index' - resources :stock_check_items - resources :stock_checks + get '/' => 'inventory#index' + get '/stock_checks' => 'stock_checks#index' + post 'save_stock' => 'stock_checks#create', as:'stock_check_save' + get '/stock_checks/:id' => 'stock_checks#show' + post 'save_to_journal' => 'stock_checks#save_to_journal', as: 'save_to_journal' + post 'print_stock_check' => 'stock_checks#print_stock_check', as: 'print_stock_check' + # resources :stock_checks resources :stock_journals resources :inventory_definitions end diff --git a/db/migrate/20170824110103_create_inventory_definitions.rb b/db/migrate/20170824110103_create_inventory_definitions.rb index 4278ce89..ad63ac6b 100644 --- a/db/migrate/20170824110103_create_inventory_definitions.rb +++ b/db/migrate/20170824110103_create_inventory_definitions.rb @@ -1,9 +1,12 @@ class CreateInventoryDefinitions < ActiveRecord::Migration[5.1] + # rake db:migrate:down VERSION=20170824110103 def change create_table :inventory_definitions do |t| t.string :item_code t.integer :min_order_level, :default => 0 t.integer :max_stock_level, :default => 0 + t.integer :created_by + t.boolean :is_active, :default => true t.timestamps end end diff --git a/db/migrate/20170824110130_create_stock_check_items.rb b/db/migrate/20170824110130_create_stock_check_items.rb index c8908a1d..578ca893 100644 --- a/db/migrate/20170824110130_create_stock_check_items.rb +++ b/db/migrate/20170824110130_create_stock_check_items.rb @@ -1,7 +1,7 @@ class CreateStockCheckItems < ActiveRecord::Migration[5.1] def change create_table :stock_check_items do |t| - t.integer :stock_check_id, :null => false + t.integer :stock_check_id t.string :item_code, :null => false t.integer :stock_count, :default => 0 t.integer :stock_journal_id diff --git a/dump.rdb b/dump.rdb index 332310c7..c9264423 100644 Binary files a/dump.rdb and b/dump.rdb differ