# HG changeset patch # User Tomas Zeman # Date 1335909249 -7200 # Node ID 494b3b9db4632e16d543e60eb4b7332637edc683 # Parent 39d3fc08414cf42e9f9620684c5d7106ed388e4c Company status diff -r 39d3fc08414c -r 494b3b9db463 db/db-data.sql --- a/db/db-data.sql Tue May 01 23:32:41 2012 +0200 +++ b/db/db-data.sql Tue May 01 23:54:09 2012 +0200 @@ -117,3 +117,23 @@ VALUES ('task_type', nextval('code_list_item_id_seq'), true, 'Task type 2', 2, false, 0, 0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); + +-- Company status +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('company_status', nextval('code_list_item_id_seq'), true, 'company.status.active', 10, true, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('company_status', nextval('code_list_item_id_seq'), true, 'company.status.potencial', 20, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); +INSERT INTO code_list_item +(code_list, id, i18n, name, rank, dflt, i1, +i2, i3, l1, l2, l3, s1, s2, s3, created_at, updated_at, deleted) +VALUES +('company_status', nextval('code_list_item_id_seq'), true, 'company.status.inactive', 30, false, 0, +0, 0, 0, 0, 0, '', '', '', current_timestamp, current_timestamp, false); diff -r 39d3fc08414c -r 494b3b9db463 db/db-schema.sql --- a/db/db-schema.sql Tue May 01 23:32:41 2012 +0200 +++ b/db/db-schema.sql Tue May 01 23:54:09 2012 +0200 @@ -113,6 +113,7 @@ "id" bigint primary key not null, "ico" varchar(40) not null, "note" varchar(10240), + "status" bigint not null, "created_at" timestamp not null, "created_by" bigint, "address_id" bigint not null, @@ -209,23 +210,24 @@ alter table "address" add constraint "addressFK1" foreign key ("city_id") references "city"("id"); alter table "city" add constraint "cityFK2" foreign key ("country_id") references "country"("id"); alter table "location" add constraint "locationFK3" foreign key ("address_id") references "address"("id"); -alter table "company" add constraint "companyFK4" foreign key ("address_id") references "address"("id"); -alter table "company" add constraint "companyFK5" foreign key ("post_adress_id") references "address"("id") on delete set null; -alter table "bank_account" add constraint "bank_accountFK6" foreign key ("company_id") references "company"("id") on delete cascade; -alter table "project" add constraint "projectFK11" foreign key ("responsible") references "user"("id"); -alter table "project" add constraint "projectFK12" foreign key ("product_line") references "code_list_item"("id") on delete set null; -alter table "project" add constraint "projectFK13" foreign key ("state") references "code_list_item"("id"); -alter table "task" add constraint "taskFK14" foreign key ("responsible") references "user"("id"); -alter table "task" add constraint "taskFK15" foreign key ("task_type") references "code_list_item"("id"); -alter table "task" add constraint "taskFK16" foreign key ("state") references "code_list_item"("id"); -alter table "task" add constraint "taskFK17" foreign key ("project_id") references "project"("id"); -alter table "comment" add constraint "commentFK18" foreign key ("task_id") references "task"("id") on delete cascade; -alter table "company_contact" add constraint "company_contactFK7" foreign key ("entity") references "company"("id") on delete cascade; -alter table "company_contact" add constraint "company_contactFK8" foreign key ("contact") references "contact"("id") on delete cascade; -alter table "user_contact" add constraint "user_contactFK9" foreign key ("entity") references "user"("id") on delete cascade; -alter table "user_contact" add constraint "user_contactFK10" foreign key ("contact") references "contact"("id") on delete cascade; -alter table "project_company" add constraint "project_companyFK19" foreign key ("project") references "project"("id") on delete cascade; -alter table "project_company" add constraint "project_companyFK20" foreign key ("company") references "company"("id") on delete cascade; +alter table "company" add constraint "companyFK4" foreign key ("status") references "code_list_item"("id"); +alter table "company" add constraint "companyFK5" foreign key ("address_id") references "address"("id"); +alter table "company" add constraint "companyFK6" foreign key ("post_adress_id") references "address"("id") on delete set null; +alter table "bank_account" add constraint "bank_accountFK7" foreign key ("company_id") references "company"("id") on delete cascade; +alter table "project" add constraint "projectFK12" foreign key ("responsible") references "user"("id"); +alter table "project" add constraint "projectFK13" foreign key ("product_line") references "code_list_item"("id") on delete set null; +alter table "project" add constraint "projectFK14" foreign key ("state") references "code_list_item"("id"); +alter table "task" add constraint "taskFK15" foreign key ("responsible") references "user"("id"); +alter table "task" add constraint "taskFK16" foreign key ("task_type") references "code_list_item"("id"); +alter table "task" add constraint "taskFK17" foreign key ("state") references "code_list_item"("id"); +alter table "task" add constraint "taskFK18" foreign key ("project_id") references "project"("id"); +alter table "comment" add constraint "commentFK19" foreign key ("task_id") references "task"("id") on delete cascade; +alter table "company_contact" add constraint "company_contactFK8" foreign key ("entity") references "company"("id") on delete cascade; +alter table "company_contact" add constraint "company_contactFK9" foreign key ("contact") references "contact"("id") on delete cascade; +alter table "user_contact" add constraint "user_contactFK10" foreign key ("entity") references "user"("id") on delete cascade; +alter table "user_contact" add constraint "user_contactFK11" foreign key ("contact") references "contact"("id") on delete cascade; +alter table "project_company" add constraint "project_companyFK20" foreign key ("project") references "project"("id") on delete cascade; +alter table "project_company" add constraint "project_companyFK21" foreign key ("company") references "company"("id") on delete cascade; -- composite key indexes : alter table "company_contact" add constraint "company_contactCPK" unique("entity","contact"); alter table "user_contact" add constraint "user_contactCPK" unique("entity","contact"); diff -r 39d3fc08414c -r 494b3b9db463 src/main/scala/fis/crm/model/Company.scala --- a/src/main/scala/fis/crm/model/Company.scala Tue May 01 23:32:41 2012 +0200 +++ b/src/main/scala/fis/crm/model/Company.scala Tue May 01 23:54:09 2012 +0200 @@ -16,6 +16,7 @@ package fis.crm.model import fis.base.model.Entity +import fis.cl.model.CodeListItemField import fis.geo.model._ import net.liftweb.common._ import net.liftweb.record.{MetaRecord, Record} @@ -31,6 +32,7 @@ val ico = new StringField(this, 40) with FL val dic = new StringField(this, 40) with FL val pin = new IntField(this) with FL + val status = new CodeListItemField(this, 'company_status) with FL @Column(name="address_id") val address = new LongField(this) with AddressField with FL @Column(name="post_adress_id") diff -r 39d3fc08414c -r 494b3b9db463 src/main/scala/fis/crm/model/CrmSchema.scala --- a/src/main/scala/fis/crm/model/CrmSchema.scala Tue May 01 23:32:41 2012 +0200 +++ b/src/main/scala/fis/crm/model/CrmSchema.scala Tue May 01 23:54:09 2012 +0200 @@ -16,10 +16,11 @@ package fis.crm.model import fis.base.model.{BaseSchema, Entity} +import fis.cl.model.CodeListSchema import fis.geo.model.GeoSchema import net.liftweb.squerylrecord.RecordTypeMode._ -trait CrmSchema extends BaseSchema with GeoSchema { +trait CrmSchema extends BaseSchema with CodeListSchema with GeoSchema { val contactT = tableWithSeq[Contact] @@ -42,6 +43,9 @@ val companyT = tableWithSeq[Company] + val companyStatus = oneToManyRelation(cli, companyT). + via((i, c) => i.id === c.status) + val companyAddress = oneToManyRelation(addressT, companyT). via((a, c) => c.address === a.id) diff -r 39d3fc08414c -r 494b3b9db463 src/main/scala/fis/crm/ui/CompanyPanel.scala --- a/src/main/scala/fis/crm/ui/CompanyPanel.scala Tue May 01 23:32:41 2012 +0200 +++ b/src/main/scala/fis/crm/ui/CompanyPanel.scala Tue May 01 23:54:09 2012 +0200 @@ -22,7 +22,7 @@ object CompanyPanel { def fields(c: Company): List[BaseField] = - List(c.name, c.ico, c.dic, c.address) ++ + List(c.name, c.ico, c.dic, c.status, c.address) ++ c.postAddress.get.map{_ => c.postAddress} ++ Seq(c.note) def apply(c: Company) = ViewPanel(fields(c)) diff -r 39d3fc08414c -r 494b3b9db463 src/main/scala/fis/crm/ui/CompanySnippet.scala --- a/src/main/scala/fis/crm/ui/CompanySnippet.scala Tue May 01 23:32:41 2012 +0200 +++ b/src/main/scala/fis/crm/ui/CompanySnippet.scala Tue May 01 23:54:09 2012 +0200 @@ -108,7 +108,7 @@ fields(company) flatMap(_.allFields) private def fields(c: Company): List[FieldContainer] = { - List[FieldContainer](c.name, c.ico, c.dic, + List[FieldContainer](c.name, c.ico, c.dic, c.status, ReadOnlyField.labelOnly(c.address)) ++ address.formFields ++ List[FieldContainer](hasPostAddr) ++ diff -r 39d3fc08414c -r 494b3b9db463 src/main/scala/fis/crm/ui/CompanyTable.scala --- a/src/main/scala/fis/crm/ui/CompanyTable.scala Tue May 01 23:32:41 2012 +0200 +++ b/src/main/scala/fis/crm/ui/CompanyTable.scala Tue May 01 23:54:09 2012 +0200 @@ -19,7 +19,7 @@ import fis.base.ui._ object CompanyTable extends FieldTable[Company] { - def fields(c: Company) = EntityLink(c) ++ Seq(c.ico, c.dic, c.note) + def fields(c: Company) = EntityLink(c) ++ Seq(c.ico, c.dic, c.status, c.note) def apply(l: Iterable[Company]) = build(Company, l) } diff -r 39d3fc08414c -r 494b3b9db463 src/main/webapp/templates-hidden/_resources.html --- a/src/main/webapp/templates-hidden/_resources.html Tue May 01 23:32:41 2012 +0200 +++ b/src/main/webapp/templates-hidden/_resources.html Tue May 01 23:54:09 2012 +0200 @@ -154,6 +154,12 @@ Pin Address Post address + Status + + Active + Potential + Inactive + diff -r 39d3fc08414c -r 494b3b9db463 src/main/webapp/templates-hidden/_resources_cs.html --- a/src/main/webapp/templates-hidden/_resources_cs.html Tue May 01 23:32:41 2012 +0200 +++ b/src/main/webapp/templates-hidden/_resources_cs.html Tue May 01 23:54:09 2012 +0200 @@ -148,6 +148,11 @@ Pin Sídlo Korespondenční adresa + Status + + Aktivní + Potenciální + Neaktivní