diff --git a/.idea/.generators b/.idea/.generators index d2c02fb2..98526fe7 100644 --- a/.idea/.generators +++ b/.idea/.generators @@ -5,4 +5,4 @@ You are allowed to: 2. Remove generators 3. Add installed generators To add new installed generators automatically delete this file and reload the project. ---> +--> diff --git a/.idea/sxrestaurant.iml b/.idea/sxrestaurant.iml index 169f839c..e1c0cfaa 100644 --- a/.idea/sxrestaurant.iml +++ b/.idea/sxrestaurant.iml @@ -142,6 +142,7 @@ + @@ -180,6 +181,7 @@ + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f494bdeb..de9b54ce 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,12 +2,11 @@ - - - - - + + + + @@ -21,53 +20,77 @@ + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -77,11 +100,12 @@ - origami table_invoice sale_id oqs void + red + origami @@ -95,7 +119,6 @@ @@ -119,10 +161,10 @@ DEFINITION_ORDER - @@ -143,20 +185,6 @@ - - - - - - - - - - @@ -170,6 +198,70 @@ + + + + + + + + + + + + + + + + + + + + @@ -556,35 +730,37 @@ - + + + - - + - + - + + + - - @@ -598,29 +774,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -628,9 +781,7 @@ - - @@ -652,46 +803,259 @@ - - - - + + - - - + + - - - - - - - - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gemfile b/Gemfile index 67348308..7b2cdca5 100644 --- a/Gemfile +++ b/Gemfile @@ -31,6 +31,7 @@ gem 'coffee-rails', '~> 4.2' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby gem 'simple_form' +gem 'nested_form' gem 'bootstrap', '~> 4.0.0.alpha3' gem 'tether-rails' gem "font-awesome-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 45b9b826..912f79ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -123,6 +123,7 @@ GEM multi_json (1.12.1) multi_xml (0.6.0) mysql2 (0.4.6) + nested_form (0.3.2) nio4r (2.1.0) nokogiri (1.8.0) mini_portile2 (~> 2.2.0) @@ -269,6 +270,7 @@ DEPENDENCIES kaminari (~> 1.0.1) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) + nested_form pg prawn prawn-table diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index bd7c9761..cd056d1c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,6 +11,7 @@ // about supported directives. // //= require jquery +//= require jquery_nested_form //= require tether //= require bootstrap //= require jquery_ujs @@ -26,14 +27,14 @@ $(document).on('turbolinks:load', function() { autoclose: true }); $('.datepicker').attr('ReadOnly','true'); - $('.datepicker').css('cursor','pointer'); + $('.datepicker').css('cursor','pointer'); // Image Upload $("#simple_menu_item_image_path").fileinput({ previewFileType: "image", allowedFileExtensions: ["jpg", "gif", "png"], browseClass: "btn btn-success", - browseLabel: "Pick Image", + browseLabel: "Pick Image", browseIcon: " ", removeClass: "btn btn-danger", removeLabel: "Delete", @@ -41,10 +42,30 @@ $(document).on('turbolinks:load', function() { showUpload: false, // uploadClass: "btn btn-info", // uploadLabel: "Upload", - // uploadIcon: " ", + // uploadIcon: " ", previewTemplates: { image: '
\n' + - ' {caption}\n' + + ' {caption}\n' + + '
\n', + } + }); + + $("#product_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + '
\n', } }); @@ -52,7 +73,7 @@ $(document).on('turbolinks:load', function() { $(document).on("focus", "[data-behaviour~='datepicker']", function(e){ $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); - $('.dropdown-toggle').dropdown(); + $('.dropdown-toggle').dropdown(); }); function export_to(path) @@ -60,7 +81,3 @@ function export_to(path) var form_params = $("#frm_report").serialize(); window.location = path+"?"+ form_params; } - - - - diff --git a/app/assets/javascripts/commissioners.coffee b/app/assets/javascripts/commissioners.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/commissioners.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/commissions.coffee b/app/assets/javascripts/commissions.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/commissions.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/commissioners.scss b/app/assets/stylesheets/commissioners.scss new file mode 100644 index 00000000..348090c2 --- /dev/null +++ b/app/assets/stylesheets/commissioners.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Commissioners controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/commissions.scss b/app/assets/stylesheets/commissions.scss new file mode 100644 index 00000000..96690bb7 --- /dev/null +++ b/app/assets/stylesheets/commissions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Commissions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/origami/commissioners_controller.rb b/app/controllers/origami/commissioners_controller.rb new file mode 100644 index 00000000..ae107ecf --- /dev/null +++ b/app/controllers/origami/commissioners_controller.rb @@ -0,0 +1,75 @@ +class Origami::CommissionersController < BaseOrigamiController + before_action :set_commissioner, only: [:show, :edit, :update, :destroy] + + # GET /commissioners + # GET /commissioners.json + def index + @commissioners = Commissioner.all + end + + # GET /commissioners/1 + # GET /commissioners/1.json + def show + end + + # GET /commissioners/new + def new + @commissioner = Commissioner.new + @employee = Employee.all.order('name asc') + end + + # GET /commissioners/1/edit + def edit + end + + # POST /commissioners + # POST /commissioners.json + def create + @commissioner = Commissioner.new(commissioner_params) + @commissioner.created_by = current_user.id + respond_to do |format| + if @commissioner.save + format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully created.' } + format.json { render :show, status: :created, location: @commissioner } + else + format.html { render :new } + format.json { render json: @commissioner.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /commissioners/1 + # PATCH/PUT /commissioners/1.json + def update + respond_to do |format| + if @commissioner.update(commissioner_params) + format.html { redirect_to origami_commissioner_path(@commissioner) , notice: 'Commissioner was successfully updated.' } + format.json { render :show, status: :ok, location: @commissioner } + else + format.html { render :edit } + format.json { render json: @commissioner.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /commissioners/1 + # DELETE /commissioners/1.json + def destroy + @commissioner.destroy + respond_to do |format| + format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_commissioner + @commissioner = Commissioner.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def commissioner_params + params.require(:commissioner).permit(:name,:emp_id,:created_by,:commission_type, :is_active) + end +end diff --git a/app/controllers/origami/commissions_controller.rb b/app/controllers/origami/commissions_controller.rb new file mode 100644 index 00000000..fdd1bf73 --- /dev/null +++ b/app/controllers/origami/commissions_controller.rb @@ -0,0 +1,74 @@ +class Origami::CommissionsController < BaseOrigamiController + before_action :set_commission, only: [:show, :edit, :update, :destroy] + + # GET /commissions + # GET /commissions.json + def index + @commissions = Commission.all + end + + # GET /commissions/1 + # GET /commissions/1.json + def show + end + + # GET /commissions/new + def new + @commission = Commission.new + end + + # GET /commissions/1/edit + def edit + end + + # POST /commissions + # POST /commissions.json + def create + @commission = Commission.new(commission_params) + + respond_to do |format| + if @commission.save + format.html { redirect_to origami_commissions_path , notice: 'Commission was successfully created.' } + format.json { render :show, status: :created, location: @commission } + else + format.html { render :new } + format.json { render json: @commission.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /commissions/1 + # PATCH/PUT /commissions/1.json + def update + respond_to do |format| + if @commission.update(commission_params) + format.html { redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.' } + format.json { render :show, status: :ok, location: @commission } + else + format.html { render :edit } + format.json { render json: @commission.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /commissions/1 + # DELETE /commissions/1.json + def destroy + @commission.destroy + respond_to do |format| + format.html { redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_commission + @commission = Commission.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def commission_params + params.require(:commission).permit(:product_id,:amount,:commission_type, :is_active) + end +end diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb new file mode 100644 index 00000000..f3f05ab9 --- /dev/null +++ b/app/controllers/origami/product_commissions_controller.rb @@ -0,0 +1,74 @@ +class Origami::ProductCommissionsController < ApplicationController + before_action :set_product_commission, only: [:show, :edit, :update, :destroy] + + # GET /product_commissions + # GET /product_commissions.json + def index + @product_commissions = ProductCommission.all + end + + # GET /product_commissions/1 + # GET /product_commissions/1.json + def show + end + + # GET /product_commissions/new + def new + @product_commission = ProductCommission.new + end + + # GET /product_commissions/1/edit + def edit + end + + # POST /product_commissions + # POST /product_commissions.json + def create + @product_commission = ProductCommission.new(product_commission_params) + + respond_to do |format| + if @product_commission.save + format.html { redirect_to @product_commission, notice: 'Product commission was successfully created.' } + format.json { render :show, status: :created, location: @product_commission } + else + format.html { render :new } + format.json { render json: @product_commission.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /product_commissions/1 + # PATCH/PUT /product_commissions/1.json + def update + respond_to do |format| + if @product_commission.update(product_commission_params) + format.html { redirect_to @product_commission, notice: 'Product commission was successfully updated.' } + format.json { render :show, status: :ok, location: @product_commission } + else + format.html { render :edit } + format.json { render json: @product_commission.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /product_commissions/1 + # DELETE /product_commissions/1.json + def destroy + @product_commission.destroy + respond_to do |format| + format.html { redirect_to product_commissions_url, notice: 'Product commission was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_product_commission + @product_commission = ProductCommission.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def product_commission_params + params.fetch(:product_commission, {}) + end +end diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index 7eda6084..e65abc85 100644 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -22,7 +22,7 @@ class Origami::VoucherController < BaseOrigamiController def create cash = params[:amount] sale_id = params[:sale_id] - sale_id = params[:refnumber] + voucher_no = params[:refnumber] if(Sale.exists?(sale_id)) customer_data= Customer.find_by_customer_id(sale_data.customer_id) if customer_data @@ -37,11 +37,12 @@ class Origami::VoucherController < BaseOrigamiController auth_token = member_actions.auth_token.to_s # membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token) # if membership_data["status"]==true + # app_token: token,membership_id:membership_id, + # campaign_type_id:campaign_type_id,merchant_uid:merchant_uid, + # auth_token:auth_token begin response = HTTParty.get(url, - :body => { app_token: token,membership_id:membership_id, - campaign_type_id:campaign_type_id,merchant_uid:merchant_uid, - auth_token:auth_token + :body => { voucher_no: voucher_no,membership_id:membership_id }.to_json, :headers => { 'Content-Type' => 'application/json', diff --git a/app/controllers/settings/promotion_products_controller.rb b/app/controllers/settings/promotion_products_controller.rb new file mode 100644 index 00000000..29248e1f --- /dev/null +++ b/app/controllers/settings/promotion_products_controller.rb @@ -0,0 +1,77 @@ +class Settings::PromotionProductsController < ApplicationController + before_action :set_promotion, only: [:show, :edit, :update, :destroy,:new] + before_action :set_promotion_product, only: [:show, :edit, :update, :destroy] + + # GET /promotion_products + # GET /promotion_products.json + def index + @promotion_products = PromotionProduct.all + end + + # GET /promotion_products/1 + # GET /promotion_products/1.json + def show + end + + # GET /promotion_products/new + def new + @promotion_product = PromotionProduct.new + end + + # GET /promotion_products/1/edit + def edit + end + + # POST /promotion_products + # POST /promotion_products.json + def create + @promotion_product = PromotionProduct.new(promotion_params) + respond_to do |format| + if @promotion_product.save + format.html { redirect_to edit_settings_promotion_path(@promotion), notice: 'PromotionProduct was successfully created.' } + format.json { render :show, status: :created, location: @promotion_product } + else + format.html { render :new } + format.json { render json: @promotion_product.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /promotion_products/1 + # PATCH/PUT /promotion_products/1.json + def update + respond_to do |format| + if @promotion_product.update(promotion_params) + format.html { redirect_to edit_settings_promotion_path(@promotion), notice: 'PromotionProduct was successfully updated.' } + format.json { render :show, status: :ok, location: @promotion_product } + else + format.html { render :edit } + format.json { render json: @promotion_product.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /promotion_products/1 + # DELETE /promotion_products/1.json + def destroy + @promotion_product.destroy + respond_to do |format| + format.html { redirect_to edit_settings_promotion_path(@promotion) , notice: 'PromotionProduct 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[:promotion_id]) + end + def set_promotion_product + @promotion_product = PromotionProduct.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def promotion_params + params.require(:promotion_product).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/controllers/settings/promotions_controller.rb b/app/controllers/settings/promotions_controller.rb index 277cf62d..246bd51b 100644 --- a/app/controllers/settings/promotions_controller.rb +++ b/app/controllers/settings/promotions_controller.rb @@ -71,6 +71,7 @@ class Settings::PromotionsController < ApplicationController # 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) + 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, + :promotion_products_attributes => [:item_code, :min_qty, :net_off, :net_price, :percentage, :_destroy]) end end diff --git a/app/helpers/commissioners_helper.rb b/app/helpers/commissioners_helper.rb new file mode 100644 index 00000000..6d7c66be --- /dev/null +++ b/app/helpers/commissioners_helper.rb @@ -0,0 +1,2 @@ +module CommissionersHelper +end diff --git a/app/helpers/commissions_helper.rb b/app/helpers/commissions_helper.rb new file mode 100644 index 00000000..02f2dddf --- /dev/null +++ b/app/helpers/commissions_helper.rb @@ -0,0 +1,2 @@ +module CommissionsHelper +end diff --git a/app/helpers/origami/product_commissions_helper.rb b/app/helpers/origami/product_commissions_helper.rb new file mode 100644 index 00000000..1d191b16 --- /dev/null +++ b/app/helpers/origami/product_commissions_helper.rb @@ -0,0 +1,2 @@ +module Origami::ProductCommissionsHelper +end diff --git a/app/models/commission.rb b/app/models/commission.rb new file mode 100644 index 00000000..8d14db70 --- /dev/null +++ b/app/models/commission.rb @@ -0,0 +1,2 @@ +class Commission < ApplicationRecord +end diff --git a/app/models/commissioner.rb b/app/models/commissioner.rb new file mode 100644 index 00000000..c6d4ab4c --- /dev/null +++ b/app/models/commissioner.rb @@ -0,0 +1,3 @@ +class Commissioner < ApplicationRecord + has_many :employees +end diff --git a/app/models/employee.rb b/app/models/employee.rb index 85aeaec1..a6b52f21 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -1,6 +1,6 @@ class Employee < ApplicationRecord has_secure_password - + belongs_to :commissioner has_many :shit_sales validates_presence_of :name, :role validates_presence_of :password, :on => [:create] diff --git a/app/models/product.rb b/app/models/product.rb index 042e1730..8f6811e2 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,3 +1,6 @@ class Product < ApplicationRecord validates_presence_of :name + + # Product Image Uploader + mount_uploader :image_path, ProductImageUploader end diff --git a/app/models/product_commission.rb b/app/models/product_commission.rb new file mode 100644 index 00000000..70de81f8 --- /dev/null +++ b/app/models/product_commission.rb @@ -0,0 +1,2 @@ +class ProductCommission < ApplicationRecord +end diff --git a/app/models/promotion.rb b/app/models/promotion.rb index 9b5c4c12..b255ceec 100644 --- a/app/models/promotion.rb +++ b/app/models/promotion.rb @@ -1,2 +1,12 @@ class Promotion < ApplicationRecord + validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_day,:promo_type,:original_product,:min_qty + + has_many :promotion_products + + accepts_nested_attributes_for :promotion_products , :allow_destroy => true + + PROMO_TYPE1 = "Quantity" + PROMO_TYPE2 = "Net_off" + PROMO_TYPE3 = "Net_price" + PROMO_TYPE4 = "Percentage" end diff --git a/app/models/promotion_product.rb b/app/models/promotion_product.rb new file mode 100644 index 00000000..c853ebdc --- /dev/null +++ b/app/models/promotion_product.rb @@ -0,0 +1,3 @@ +class PromotionProduct < ApplicationRecord + belongs_to :promotion +end diff --git a/app/uploaders/product_image_uploader.rb b/app/uploaders/product_image_uploader.rb new file mode 100644 index 00000000..04049127 --- /dev/null +++ b/app/uploaders/product_image_uploader.rb @@ -0,0 +1,58 @@ +class ProductImageUploader < CarrierWave::Uploader::Base + + # Include RMagick or MiniMagick support: + # include CarrierWave::RMagick + # include CarrierWave::MiniMagick + + # Choose what kind of storage to use for this uploader: + storage :file + # storage :fog + + def root + Rails.root.join 'public/' + end + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "image/product_images" + # "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # def cache_dir + # '/tmp/images' + # end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url(*args) + # # For Rails 3.1+ asset pipeline compatibility: + # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) + # + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process scale: [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process resize_to_fit: [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + def extension_whitelist + %w(jpg jpeg gif png) + end + + # Override the filename of the uploaded files: + # Avoid using model.id or version_name here, see uploader/store.rb for details. + # def filename + # "something.jpg" if original_filename + # end + +end diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index 0df28c6f..08991091 100644 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -30,7 +30,7 @@
- Origami + Cashier
@@ -66,8 +66,7 @@

- Administrator - + Administrator

@@ -105,7 +104,7 @@
  • OQS

  • -
  • Origami

  • +
  • Cashier

  • CRM
@@ -115,8 +114,7 @@

- Manager - + Manager

@@ -152,7 +150,7 @@
  • OQS

  • -
  • Origami

  • +
  • Cashier

  • CRM
@@ -162,8 +160,7 @@

- Supervisor - + Supervisor

@@ -185,14 +182,13 @@

- Cashier - + Cashier

    -
  • Orgami Panel except Edit and Void
  • +
  • Cashier Panel except Edit and Void
  • Sale and Order
  • and Queue in CRM
@@ -203,8 +199,7 @@

- Accountant - + Accountant

@@ -223,11 +218,11 @@
-