diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 6a706ecac7..1391da0cdb 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -55,6 +55,7 @@ def show # GET /proposals/new.xml def new @proposal = Proposal.new(:user => @current_user) + @abbreviation = Setting.proposal_abbreviation[0..-1] @users = User.except(@current_user).all if params[:related] model, id = params[:related].split("_") diff --git a/app/models/proposal.rb b/app/models/proposal.rb index ac470c5f81..a421d40b2f 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -6,11 +6,29 @@ # :access, :string, :limit => 8, :default => "Private" # :user_id, :integer # :assigned_to, :integer +# add_column :proposals, :abbreviation, :string, :default => "WEB" +# add_column :proposals, :state, :string, :default => "draft" +# add_column :proposals, :deadline, :date +# add_column :proposals, :client_account_id, :integer +# add_column :proposals, :client_contact_id, :integer +# add_column :proposals, :client_technical_contact_id, :integer +# add_column :proposals, :employee_contact_id, :integer +# add_column :proposals, :employee_technical_contact_id, :integer # class Proposal < ActiveRecord::Base - belongs_to :user - belongs_to :assignee, :class_name => "User", :foreign_key => :assigned_to - has_many :tasks, :as => :asset, :dependent => :destroy, :order => 'created_at DESC' + enum_attr :abbreviation, %w(WEB FS LVN) + + belongs_to :user + belongs_to :assignee, :class_name => "User", :foreign_key => :assigned_to + + belongs_to :client_account, :class_name => "Account" + belongs_to :client_contact, :class_name => "Contact" + belongs_to :client_technical_contact, :class_name => "Contact" + # TODO when we have an employees module we should link proposals to employees instead of contacts. we assume that contacts are persons not working in the crm organisation but in other companies (clients). + belongs_to :employee_contact, :class_name => "Contact" + belongs_to :employee_technical_contact, :class_name => "Contact" + + has_many :tasks, :as => :asset, :dependent => :destroy, :order => 'created_at DESC' has_many :activities, :as => :subject, :order => 'created_at DESC' named_scope :created_by, lambda { |user| { :conditions => "user_id = #{user.id}" } } @@ -18,7 +36,8 @@ class Proposal < ActiveRecord::Base simple_column_search :name, :match => :middle, :escape => lambda { |query| query.gsub(/[^\w\s\-\.']/, "").strip } - versioned + # versioning plugin not installed properly -> disable versioning + #versioned uses_user_permissions acts_as_commentable acts_as_paranoid diff --git a/app/views/proposals/_proposal.html.haml b/app/views/proposals/_proposal.html.haml index 1765fb22a0..9ada3659f8 100644 --- a/app/views/proposals/_proposal.html.haml +++ b/app/views/proposals/_proposal.html.haml @@ -7,11 +7,10 @@ = link_to_delete(proposal) + " " = link_to(proposal.name, proposal) << " – " %tt - = proposal.category_id + = proposal.name == added #{time_ago_in_words(proposal.created_at)} ago by == #{proposal.user.id == @current_user.id ? "me" : proposal.user.full_name} - unless @current_user.preference[:proposal_outline] == "brief" %dt - = number_to_currency(proposal.price) << " | " - = pluralize(proposal.proposal_packages.count, "packaged proposals") + = proposal.abbreviation = hook(:proposal_bottom, self, :proposal => proposal) diff --git a/app/views/proposals/_top_section.html.haml b/app/views/proposals/_top_section.html.haml index 54660f2d70..c16ad9144d 100644 --- a/app/views/proposals/_top_section.html.haml +++ b/app/views/proposals/_top_section.html.haml @@ -1,11 +1,24 @@ .section %table{ :width => 500, :cellpadding => 0, :cellspacing => 0 } %tr - %td{ :valign => :top } + %td{ :colspan => 3, :valign => :top } .label.top.req Name: = f.text_field :name, :style => "width:324px" %tr - %td{ :valign => :top } + %td{ :colspan => 3, :valign => :top } + .label.top.req Abbreviation + %tr + %td + .label Start Date: + = f.text_field :start_date, :value => f.object.start_date ? f.object.start_date.to_s(:mmddyyyy) : "", :style => "width:110px", :autocomplete => :off + %td + .label End Date: + = f.text_field :end_date, :value => f.object.end_date ? f.object.end_date.to_s(:mmddyyyy) : "", :style => "width:110px", :autocomplete => :off + %td + .label Deadline: + = f.text_field :deadline, :value => f.object.deadline ? f.object.deadline.to_s(:mmddyyyy) : "", :style => "width:110px", :autocomplete => :off + %tr + %td{ :colspan => 3, :valign => :top } .label.top.req Assigned to: = collection_select :proposal, :assigned_to, @users, :id, :full_name, { :include_blank => "Myself" }, { :style => "width:160px" } = hook(:proposal_top_section_bottom, self, :f => f) diff --git a/app/views/proposals/create.js.rjs b/app/views/proposals/create.js.rjs index a727a958f7..633e6fb4f0 100644 --- a/app/views/proposals/create.js.rjs +++ b/app/views/proposals/create.js.rjs @@ -9,6 +9,9 @@ if @proposal.valid? page.call "crm.flick", :empty, :remove else page[:create_proposal].replace_html :partial => "create" + page.call "crm.date_select_popup", :proposal_start_date + page.call "crm.date_select_popup", :proposal_end_date + page.call "crm.date_select_popup", :proposal_deadline page[:create_proposal].visual_effect :shake, :duration => 0.25, :distance => 6 page[:proposal_name].focus end diff --git a/config/settings.yml b/config/settings.yml index 2fce29e78d..e15e4880aa 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -161,3 +161,10 @@ task_completed: [ [ "This month", :completed_this_month ], [ "Last month", :completed_last_month ] ] + +# NOTE: no tabs allowed. use spaces instead. +proposal_abbreviation: [ + [ "WEB", :WEB ], + [ "FS", :FS ], + [ "LVN", :LVN ] +]