Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MembersAreaController < PublicBaseController
- before_filter :verify_member, :get_member
- include ApplicationHelper
- def change_login_email_address
- @message_to_user="You must enter a valid email address to proceed."
- error_happened=true
- if !params[:member_change_password].blank?
- email_to_set_to=params[:member_change_password]
- if email_to_set_to =~ /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/ and validate_email_domain(email_to_set_to)
- #update the email
- existing_email_address=MemberEmail.find_by_email(email_to_set_to)
- if existing_email_address.blank?
- existing_email_address=User.find_by_login(email_to_set_to)
- end
- #p "$$$$$$$$$$$$$$$$$$$#{existing_email_address.to_s}"
- if existing_email_address.blank?
- user_account=User.find_by_member_id(@member.id)
- user_account.login=email_to_set_to
- user_account.email=email_to_set_to
- user_account.save
- if !@member.member_emails.include? email_to_set_to
- #insert this email address into the users account
- new_email=MemberEmail.new
- new_email.member_id=@member.id
- new_email.email=email_to_set_to
- new_email.email_type=DEFAULT_EMAIL_TYPE
- new_email.save
- end
- @message_to_user="Your login email address has been updated."
- error_happened=false
- else
- #the email address already exists in our system
- if existing_email_address.member_id != @member.id
- @message_to_user="The email address you entered is already in use by another user. Please correct your entry and try again."
- error_happened=true
- else
- #the member is switching to an email address that exists already that they own
- user_account=User.find_by_member_id(@member.id)
- user_account.login=email_to_set_to
- user_account.email=email_to_set_to
- user_account.save
- @message_to_user="Your login email address has been updated."
- error_happened=false
- end
- end
- else
- @message_to_user="The email address you entered is not a valid email address. Please correct your entry and try again."
- error_happened=true
- end
- end
- render :update do |page|
- if error_happened
- page[:message_to_user].replace_html :partial => 'shared/message_to_user_error'
- page[:message_to_user].visual_effect :highlight
- else
- page[:message_to_user].replace_html :partial => 'shared/message_to_user_success'
- page[:message_to_user].visual_effect :highlight
- end
- end
- end
- def edit_profile
- render :update do |page|
- page[:general].replace_html :partial => 'general_form'
- end
- end
- def update_profile
- differences=""
- if !params[:work_address].blank?
- test=@member.get_work_address
- address=@member.get_work_address
- if address.nil?
- address=Address.new
- address.member_id=@member.id
- address.address_type="Work Address"
- end
- address.street=params[:work_address]['street'] rescue nil
- address.address1=params[:work_address]['address1'] rescue nil
- address.address2=params[:work_address]['address2'] rescue nil
- address.address3=params[:work_address]['address3'] rescue nil
- address.suite=params[:work_address]['suite'] rescue nil
- address.city=params[:work_address]['city'] rescue nil
- address.province=params[:work_address]['province'] rescue nil
- address.postal_code=params[:work_address]['postal_code'] rescue nil
- address.save
- if !address.eql?(test)
- differences+="<br><br>#{nice_date(Time.now)}: Member's Business address has changed to:#{address.nice_address}"
- end
- end
- if !params[:work_phone].blank?
- test=@member.get_work_phone
- phone=@member.get_work_phone
- if phone.nil?
- phone=Phone.new
- phone.member_id=@member.id
- phone.phone_type="Work Phone"
- end
- phone.phone=params[:work_phone][:phone] rescue nil
- phone.save
- if !phone.eql?(test)
- differences+="<br><br>#{nice_date(Time.now)}: Member's Business phone has changed to:#{phone.phone}"
- end
- end
- if !params[:home_address].blank?
- test=@member.get_home_address
- address=@member.get_home_address
- if address.nil?
- address=Address.new
- address.member_id=@member.id
- address.address_type="Home Address"
- end
- address.street=params[:home_address][:street] rescue nil
- address.address1=params[:home_address][:address1] rescue nil
- address.address2=params[:home_address][:address2] rescue nil
- address.address3=params[:home_address][:address3] rescue nil
- address.suite=params[:home_address][:suite] rescue nil
- address.city=params[:home_address][:city] rescue nil
- address.province=params[:home_address][:province] rescue nil
- address.postal_code=params[:home_address][:postal_code] rescue nil
- address.save
- if !address.eql?(test)
- differences+="<br><br>#{nice_date(Time.now)}: Member's Home address has changed to:#{address.nice_address}"
- end
- end
- if !params[:home_phone].blank?
- test=@member.get_home_phone
- phone=@member.get_home_phone
- if phone.nil?
- phone=Phone.new
- phone.member_id=@member.id
- phone.phone_type="Home Phone"
- end
- phone.phone=params[:home_phone][:phone] rescue nil
- phone.save
- if !phone.eql?(test)
- differences+="<br><br>#{nice_date(Time.now)}: Member's Home phone has changed to:#{phone.phone}"
- end
- end
- if differences!=""
- history=MemberHistory.find_by_member_id(@member.id)
- if history.nil?
- history=MemberHistory.new
- end
- history.note+=differences
- history.save
- end
- render :update do |page|
- page[:general].replace_html :partial => 'general'
- end
- end
- def change_password_submit
- message=''
- if !params['_password'].blank? && params[:id].to_i > 0
- if params['_password']==params['_password_confirm']
- user=User.find_by_member_id(params[:id])
- if !user.nil?
- user.password=params['_password_confirm']
- user.password_confirmation=params['_password_confirm']
- if user.save
- message='Your password has been saved'
- else
- message='Error saving password'
- end
- else
- message='Error saving password'
- end
- else
- message='The password and password confirmation do not match'
- end
- else
- message='change_password_message', ' '
- end
- render :update do |page|
- page.insert_html :bottom, 'change_password_message', message + "<br><br>"
- end
- end
- def pay_fees
- @program_offering=ProgramOffering.find_by_academic_year_id(get_current_academic_year.id,:conditions=>"name like '#{PROGRAM_OFFERING_MEMBERSHIP_PREFIX}%'")
- @debits=MemberDebit.find_all_by_program_offering_id_and_member_id(@program_offering.id,@member.id)
- @invoiced=MemberDebit.sum(:debit_amount,:conditions=>"member_id=#{@member.id} AND program_offering_id=#{@program_offering.id}").to_f
- @credits=0.0
- @debits.each do |deb|
- @credits+=MemberCredit.sum(:credit_amount,:conditions=>"member_debit_id=#{deb.id} AND payment_status=#{PAYMENT_CHEQUE_CLEARED_STATUS}").to_f
- end
- @amount_owing=@invoiced-@credits
- @order_number=MemberDebit.find_by_program_offering_id_and_member_id_and_parent_id(@program_offering.id,@member.id,nil).invoice_id rescue -1
- if @amount_owing<=0.0
- redirect_to URL_BASE_MEMBERS_AREA
- end
- #order_info="#{@order_number};#{@amount_owing};#{@member.id};#{Time.now.to_s}"
- #@order_encrypted_data=scramble(order_info)
- end
- def do_pending_payment
- if params['pending_payment_amount'].to_f > 0.0
- if params['payment_method'].to_i >0
- program_offering=ProgramOffering.find_by_academic_year_id(get_current_academic_year.id)
- order_number=MemberDebit.find_by_program_offering_id_and_member_id_and_parent_id(program_offering.id,@member.id,nil)
- #PAYMENT_PENDING_CHEQUE_PAYMENT_STATUS
- mc=MemberCredit.new
- mc.member_debit_id=order_number.id
- mc.credit_amount=params['pending_payment_amount'].to_f
- mc.payment_method=params['payment_method'].to_i
- mc.payment_status=PAYMENT_PENDING_CHEQUE_PAYMENT_STATUS
- mc.payment_pending_date=Time.now
- mc.notes=PAYMENT_NOTE_FROM_WEBSITE
- mc.date_of_transaction=Time.now
- render :update do |page|
- if mc.save
- page.redirect_to "pay_thank_you"
- else
- page << "alert('There was an error entering your payment, please try again. If the problem persists please contact our administration. Thank You.');"
- end
- end
- end
- end
- end
- def index
- end
- def show
- end
- def my_services
- @debits = @member.get_active_debits_without_late_fee
- mpi=MemberPUFInfo.find_by_program_offering_id_and_member_id(ProgramOffering.find_by_academic_year_id(get_current_academic_year.id,:conditions=>"name like '#{PROGRAM_OFFERING_MEMBERSHIP_PREFIX}%'"),@member.id)
- if mpi.blank?
- @puf_completed=false
- else
- @puf_completed=true
- end
- end
- def send_contact_admin
- ca = ContactAdmin.new(params[:contact_admin])
- @member.contact_admins << ca
- PostOffice.deliver_contact_admin(ca)
- flash[:notice] = "<strong>Message successfully sent to Administrator</strong>"
- render :action => :contact_admin
- end
- def pay_success
- @spoof=false
- @refreshed_browser=false
- @cleared=false
- #make sure no one is spoofing the payment info
- transaction_copy=""
- params.each_pair {|key, value| transaction_copy+="#{key}=#{value};"}
- if !params['trnOrderNumber'].blank?
- payinfo="#{params['trnOrderNumber']};#{params['trnAmount']}" rescue nil
- if params['messageText']=='Approved'
- if !payinfo.blank?
- if payinfo.include? ";"
- tmp_array=payinfo.split(";")
- #get the amount owing based on the invoiceiD
- debits=MemberDebit.find_all_by_invoice_id(params['trnOrderNumber'])
- if debits!={}
- invoiced=MemberDebit.sum(:debit_amount,:conditions=>"invoice_id='#{params['trnOrderNumber']}'").to_f
- credits=0.0
- debits.each do |deb|
- credits+=MemberCredit.sum(:credit_amount,:conditions=>"member_debit_id=#{deb.id} AND payment_status=#{PAYMENT_CHEQUE_CLEARED_STATUS}").to_f
- end
- amount_owing=invoiced-credits
- else
- amount_owing=0.0
- end
- #transaction_copy+="decrypted_data=#{payinfo}"
- #p "^^^^^^^^#{tmp_array}"
- if amount_owing>0.0
- md=MemberDebit.find_by_invoice_id(tmp_array[0])
- if !md.blank?
- #check to see if the user has hit refresh on the page
- find_dupe_mc=MemberCredit.find_by_member_debit_id_and_credit_amount_and_payment_method_and_payment_status(md.id,amount_owing,PAYMENT_CREDITCARD_TYPE,PAYMENT_CHEQUE_CLEARED_STATUS)
- if find_dupe_mc.blank?
- mc=MemberCredit.new
- mc.member_debit_id=md.id
- mc.credit_amount=amount_owing
- mc.payment_method=PAYMENT_CREDITCARD_TYPE
- mc.payment_status=PAYMENT_CHEQUE_CLEARED_STATUS
- mc.payment_pending_date=Time.now
- mc.payment_received_date=Time.now
- mc.payment_paid_date=Time.now
- mc.notes=PAYMENT_NOTE_FROM_WEBSITE
- mc.date_of_transaction=Time.now
- if mc.save
- @cleared=true
- end
- else
- @refreshed_browser=true
- @cleared=true #the member hit refresh, lets not show scary message
- end
- end
- else
- @refreshed_browser=true
- @cleared=true #the member hit refresh, lets not show scary message
- end
- end
- end
- end
- end
- if !@refreshed_browser
- #create the transaction log
- cctl=CreditCardTranscationLog.new
- cctl.message=transaction_copy
- cctl.cleared=@cleared
- cctl.member_id=@member.id
- cctl.save
- end
- end
- def pay_fail
- end
- end
Add Comment
Please, Sign In to add comment