Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. def create
  2. user_ids = params[:promocode][:user_id]
  3. if params[:promocode][:type] == 'default'
  4. promo = Promocode.where("end_date > #{params[:promocode][:start_date]} AND type='default'")
  5. path = Rails.root.join('public/my_log.txt')
  6. File.open(path, 'a+') do |f|
  7. current_time = Time.now.strftime("%d/%m/%Y %H:%M")
  8. f.puts '-----------------------------------------'
  9. f.puts 'Date : '+current_time.rjust(34)
  10. f.puts "\n"
  11. f.puts 'IP : '+request.remote_ip.rjust(36)
  12. f.puts 'Action : save promo'
  13. f.puts promo
  14. f.puts '-----------------------------------------'
  15. end
  16. else
  17. @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)
  18. if @promocode.valid?
  19. Notification.send_admin_offer_notifications(user_ids, params[:promocode][:note], 'PROMOCODE')
  20. redirect_to admin_promocodes_path, :notice => "Promo code is being created for #{user_ids[0] == 'all' ? 'All' : user_ids.length} user(s)"
  21. else
  22. render 'new'
  23. end
  24. end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement