product commission transaction in commissioner
This commit is contained in:
@@ -27,13 +27,19 @@ class Settings::CommissionersController < ApplicationController
|
||||
def create
|
||||
@commissioner = Commissioner.new(commissioner_params)
|
||||
@commissioner.created_by = current_user.id
|
||||
unless @commissioner.joined_date.nil?
|
||||
@commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d')
|
||||
end
|
||||
unless @commissioner.resigned_date.nil?
|
||||
@commissioner.resigned_date = @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d')
|
||||
end
|
||||
respond_to do |format|
|
||||
if @commissioner.save
|
||||
format.html { redirect_to settings_commissioners_path , notice: 'Commissioner was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @commissioner }
|
||||
format.html {redirect_to settings_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 }
|
||||
format.html {render :new}
|
||||
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -43,11 +49,11 @@ class Settings::CommissionersController < ApplicationController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @commissioner.update(commissioner_params)
|
||||
format.html { redirect_to settings_commissioner_path(@commissioner) , notice: 'Commissioner was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @commissioner }
|
||||
format.html {redirect_to settings_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 }
|
||||
format.html {render :edit}
|
||||
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -57,19 +63,31 @@ class Settings::CommissionersController < ApplicationController
|
||||
def destroy
|
||||
@commissioner.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_commissioners_path , notice: 'Commissioner was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
format.html {redirect_to settings_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])
|
||||
def get_transaction_by_commissioner
|
||||
commissioner_id = params[:commissioner_id]
|
||||
@transactions = []
|
||||
@product_commissions = ProductCommission.where(commissioner_id: commissioner_id).order('updated_at desc')
|
||||
@product_commissions.each_with_index do |p, i|
|
||||
@transactions[i] = []
|
||||
@transactions[i] << p
|
||||
@transactions[i] << p.commission.menu_item.name
|
||||
end
|
||||
render json: @transactions
|
||||
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_id,:joined_date,:resigned_date, :is_active)
|
||||
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_id, :joined_date, :resigned_date, :is_active)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user