--- 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);
--- 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");
--- 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")
--- 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)
--- 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))
--- 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) ++
--- 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)
}
--- 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 @@
<res name="company.pin" lang="en" default="true">Pin</res>
<res name="company.address" lang="en" default="true">Address</res>
<res name="company.postAddress" lang="en" default="true">Post address</res>
+ <res name="company.status" lang="en" default="true">Status</res>
+ <!-- company status -->
+ <res name="company.status.active" lang="en" default="true">Active</res>
+ <res name="company.status.potencial" lang="en" default="true">Potential</res>
+ <res name="company.status.inactive" lang="en" default="true">Inactive</res>
+
<!-- address -->
--- 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 @@
<res name="company.pin" lang="cs">Pin</res>
<res name="company.address" lang="cs">Sídlo</res>
<res name="company.postAddress" lang="cs">Korespondenční adresa</res>
+ <res name="company.status" lang="cs">Status</res>
+ <!-- company status -->
+ <res name="company.status.active" lang="cs">Aktivní</res>
+ <res name="company.status.potencial" lang="cs">Potenciální</res>
+ <res name="company.status.inactive" lang="cs">Neaktivní</res>
<!-- address -->