Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create
- user_ids = params[:promocode][:user_id]
- if params[:promocode][:type] == 'default'
- promo = Promocode.where("end_date > #{params[:promocode][:start_date]} AND type='default'")
- path = Rails.root.join('public/my_log.txt')
- File.open(path, 'a+') do |f|
- current_time = Time.now.strftime("%d/%m/%Y %H:%M")
- f.puts '-----------------------------------------'
- f.puts 'Date : '+current_time.rjust(34)
- f.puts "\n"
- f.puts 'IP : '+request.remote_ip.rjust(36)
- f.puts 'Action : save promo'
- f.puts promo
- f.puts '-----------------------------------------'
- end
- else
- @promocode = Promocode.create(start_date: params[:promocode][:start_date], end_date: params[:promocode][:end_date], promo_code: params[:promocode][:promo_code], type: params[:promocode][:type], amount: params[:promocode][:amount], note: params[:promocode][:note], user_id: user_ids)
- if @promocode.valid?
- Notification.send_admin_offer_notifications(user_ids, params[:promocode][:note], 'PROMOCODE')
- redirect_to admin_promocodes_path, :notice => "Promo code is being created for #{user_ids[0] == 'all' ? 'All' : user_ids.length} user(s)"
- else
- render 'new'
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement