Guest User

Untitled

a guest
Jul 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. def update_contact_phone
  2. @phone = params[:contact_phone][:phone]
  3. @phone = 0 if @phone.blank?
  4. notice = "V polju telefon je potrebno vnesti le številke, <br /> brez minusov, pik, presledkov, itd...!" if not is_a_number?(@phone)
  5. @phone = "xxxxxxx" if @phone == 0 and params[:area][:code].size == 2
  6. @phone = "xxxxxx" if @phone == 0 and params[:area][:code].size == 3
  7. @phone = "xxxxx" if @phone == 0 and params[:area][:code].size == 4
  8. # notice = "Dolžina telefonske številke je napačna!" if @phone.size != 7 and params[:area][:code].size == 2
  9. # notice = "Dolžina telefonske številke je napačna!" if @phone.size != 6 and params[:area][:code].size == 3
  10. # notice = "Dolžina telefonske številke je napačna!" if @phone.size != 5 and params[:area][:code].size == 4
  11. if notice
  12. render :update do |page|
  13. page.replace_html "notice_row", notice
  14. end
  15. else
  16. @contact_phone = ContactPhone.find params[:id]
  17. @contact_phone.phone = params[:area][:code] + "-" + @phone
  18. @contact_phone.save
  19. @contacts = @contact_phone.company_contact.company.company_contacts
  20. render :update do |page|
  21. page.replace_html "edit_contact", ""
  22. page.replace_html "edit-user", :partial => 'list_company_contacts', :locals => {:contacts => @contacts}
  23. end
  24. end
  25.  
  26. end
Add Comment
Please, Sign In to add comment