Sha256: 608431cf38cdc84f1ac344a8377b4d2cb5d761936d1e067480fab9107cffb14d

Contents?: true

Size: 1.49 KB

Versions: 33

Compression:

Stored size: 1.49 KB

Contents

module ErpApp
  module Organizer
    module Crm
      class RelationshipController < ErpApp::Organizer::BaseController


        #RESTful controller for party relationship
        #data
        def index

          render :inline => if request.get?
            get_party_relationships
          end
        end

        # This method returns all party relationships
        # that involve the params[:party_id] and the passed in
        # relationship type.  Use this when you just need generic
        # information about a relationship passed back.
        # Formats into a hash for consumption by an
        # ExtJS GridPanel
        #
        def get_party_relationships
          party = Party.find(params[:party_id])
          relationships = party.find_relationships_by_type(params[:relationship_type])

          total_count = relationships.length

          {:totalCount => total_count,
            :data => relationships.collect do |relation|
              related_party = relation.to_party
              {
                :party_id => related_party.id,
                :party_desc => related_party.description,
                :relationship => relation.description,
                :created_at => relation.created_at,
                :updated_at => relation.updated_at,
                :from_date => relation.from_date,
                :thru_date => relation.thru_date,
                :role_type => relation.to_role
              }
            end
          }.to_json
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
erp_app-3.1.16 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.15 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.14 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.13 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.12 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.11 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.10 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.9 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.8 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.7 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.6 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.5 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.4 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.3 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.2 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.0.16 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.0.15 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.1 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.1.0 app/controllers/erp_app/organizer/crm/relationship_controller.rb
erp_app-3.0.14 app/controllers/erp_app/organizer/crm/relationship_controller.rb