diff --git a/db/property_manager.sql b/db/property_manager.sql index 4292874..ac53c80 100644 --- a/db/property_manager.sql +++ b/db/property_manager.sql @@ -239,8 +239,6 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_contact_addresses` WRITE; /*!40000 ALTER TABLE `pmgr_contact_addresses` DISABLE KEYS */; -INSERT INTO `pmgr_contact_addresses` VALUES (1,'1324 N Liberty Lake Rd\nPMB 263','Liberty Lake','WA','99019','USA',NULL); -INSERT INTO `pmgr_contact_addresses` VALUES (2,'5221 W Myrtlewood Ct','Spokane','WA','99208','USA',NULL); INSERT INTO `pmgr_contact_addresses` VALUES (3,'PO Box 275','Valley','WA','99181','USA',NULL); INSERT INTO `pmgr_contact_addresses` VALUES (4,'4045 Hesseltine Rd','Springdale','WA','99173','USA',NULL); INSERT INTO `pmgr_contact_addresses` VALUES (5,'PO Box 275','Valley','WA','99181','USA',NULL); @@ -309,9 +307,6 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_contact_emails` WRITE; /*!40000 ALTER TABLE `pmgr_contact_emails` DISABLE KEYS */; -INSERT INTO `pmgr_contact_emails` VALUES (1,'abijah@PerkinsHouse.com',NULL); -INSERT INTO `pmgr_contact_emails` VALUES (2,'abijah@PerkinsREI.com',NULL); -INSERT INTO `pmgr_contact_emails` VALUES (3,'abijah@ValleyStorage.info',NULL); /*!40000 ALTER TABLE `pmgr_contact_emails` ENABLE KEYS */; UNLOCK TABLES; @@ -339,11 +334,6 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_contact_phones` WRITE; /*!40000 ALTER TABLE `pmgr_contact_phones` DISABLE KEYS */; -INSERT INTO `pmgr_contact_phones` VALUES (1,'MOBILE','5098445573',NULL,NULL); -INSERT INTO `pmgr_contact_phones` VALUES (2,'MOBILE','5098445973',NULL,NULL); -INSERT INTO `pmgr_contact_phones` VALUES (3,'VIRTUAL','5095901112',NULL,NULL); -INSERT INTO `pmgr_contact_phones` VALUES (4,'VIRTUAL','8774488664',NULL,NULL); -INSERT INTO `pmgr_contact_phones` VALUES (5,'FAX','8662960131',NULL,NULL); INSERT INTO `pmgr_contact_phones` VALUES (6,'LANDLINE','5099374611',NULL,NULL); INSERT INTO `pmgr_contact_phones` VALUES (7,'LANDLINE','5092182061',NULL,NULL); INSERT INTO `pmgr_contact_phones` VALUES (8,'LANDLINE','5099374611',NULL,NULL); @@ -421,7 +411,7 @@ CREATE TABLE `pmgr_contacts` ( `middle_name` varchar(255) DEFAULT NULL, `last_name` varchar(255) DEFAULT NULL, `company_name` varchar(255) DEFAULT NULL, - `display_name` varchar(512) DEFAULT NULL, + `display_name` varchar(512) NOT NULL, `id_federal` varchar(16) DEFAULT NULL, `id_local` varchar(16) DEFAULT NULL, `id_local_state` char(2) DEFAULT NULL, @@ -437,7 +427,6 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_contacts` WRITE; /*!40000 ALTER TABLE `pmgr_contacts` DISABLE KEYS */; -INSERT INTO `pmgr_contacts` VALUES (1,'Abijah',NULL,'Perkins',NULL,'Perkins, Abijah',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (2,'Vern',NULL,'Emert',NULL,'Emert, Vern',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (3,'Georgann',NULL,'Dahlen',NULL,'Dahlen, Georgann',NULL,'DAHLEGS501DS','WA',NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (4,'Vicky',NULL,'Emert',NULL,'Emert, Vicky',NULL,NULL,NULL,NULL,NULL); @@ -452,7 +441,7 @@ INSERT INTO `pmgr_contacts` VALUES (12,'Joe',NULL,'Barrett',NULL,'Barrett, Joe', INSERT INTO `pmgr_contacts` VALUES (13,'Tabbi',NULL,'Barrett',NULL,'Barrett, Tabbi',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (14,'Scott',NULL,'Riese',NULL,'Riese, Scott',NULL,'RIESESL339MD','WA',NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (15,'James',NULL,'McBride',NULL,'McBride, James',NULL,'MCBRIJC432C1','WA',NULL,NULL); -INSERT INTO `pmgr_contacts` VALUES (16,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_contacts` VALUES (16,NULL,NULL,NULL,NULL,'McBride Contact - Unknown',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (17,'Glen',NULL,'Wittner',NULL,'Wittner, Glen',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (18,'Marlana',NULL,'Francis',NULL,'Francis, Marlana',NULL,'FRANCMM371JS','WA',NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (19,'Don',NULL,'Francis',NULL,'Francis, Don',NULL,NULL,NULL,NULL,NULL); @@ -490,9 +479,9 @@ INSERT INTO `pmgr_contacts` VALUES (50,'Vivian',NULL,'McMahon',NULL,'McMahon, Vi INSERT INTO `pmgr_contacts` VALUES (51,'Murray',NULL,'McMahon',NULL,'McMahon, Murray',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (52,'Ron',NULL,'Linhoff',NULL,'Linhoff, Ron',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (53,'Ed',NULL,'Hatcher',NULL,'Hatcher, Ed',NULL,'HATCHEW441D9','WA',NULL,NULL); -INSERT INTO `pmgr_contacts` VALUES (54,NULL,NULL,NULL,'Valley Bible Church',NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_contacts` VALUES (54,NULL,NULL,NULL,'Valley Bible Church','Valley Bible Church',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (55,'Pamela',NULL,'Hovland',NULL,'Hovland, Pamela',NULL,'HIGGIPD461L7','WA',NULL,NULL); -INSERT INTO `pmgr_contacts` VALUES (56,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_contacts` VALUES (56,NULL,NULL,NULL,NULL,'Hoveland Contact - Unknown ',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (57,'R.R.',NULL,'Hooke',NULL,'Hooke, R.R.',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (58,'Bill',NULL,'Clark',NULL,'Clark, Bill',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (59,'Shirley',NULL,'Jackson',NULL,'Jackson, Shirley',NULL,NULL,NULL,NULL,NULL); @@ -633,7 +622,7 @@ CREATE TABLE `pmgr_contacts_methods` ( `method` enum('ADDRESS','PHONE','EMAIL') NOT NULL, `method_id` int(10) unsigned NOT NULL, `type` enum('MAIN','HOME','BUSINESS','OTHER') NOT NULL DEFAULT 'MAIN', - `preference` enum('PRIMARY','WORK','ALTERNATE','EMERGENCY') NOT NULL DEFAULT 'PRIMARY', + `preference` enum('PRIMARY','ALTERNATE','EMERGENCY') NOT NULL DEFAULT 'PRIMARY', `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`contact_id`,`method`,`method_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; @@ -645,16 +634,6 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_contacts_methods` WRITE; /*!40000 ALTER TABLE `pmgr_contacts_methods` DISABLE KEYS */; -INSERT INTO `pmgr_contacts_methods` VALUES (1,'ADDRESS',1,'MAIN','PRIMARY',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'ADDRESS',2,'HOME','ALTERNATE',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'PHONE',1,'MAIN','PRIMARY',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'PHONE',2,'MAIN','ALTERNATE',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'PHONE',3,'BUSINESS','WORK',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'PHONE',4,'BUSINESS','WORK',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'PHONE',5,'BUSINESS','WORK',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'EMAIL',1,'HOME','PRIMARY',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'EMAIL',2,'HOME','WORK',NULL); -INSERT INTO `pmgr_contacts_methods` VALUES (1,'EMAIL',3,'BUSINESS','WORK',NULL); INSERT INTO `pmgr_contacts_methods` VALUES (2,'ADDRESS',3,'HOME','PRIMARY',NULL); INSERT INTO `pmgr_contacts_methods` VALUES (2,'PHONE',6,'MAIN','PRIMARY',NULL); INSERT INTO `pmgr_contacts_methods` VALUES (3,'ADDRESS',4,'HOME','PRIMARY',NULL); @@ -5685,6 +5664,11 @@ SET character_set_client = utf8; CREATE TABLE `pmgr_unit_types` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(12) NOT NULL, + `residential` tinyint(1) unsigned NOT NULL DEFAULT '0', + `enclosed` tinyint(1) unsigned NOT NULL DEFAULT '0', + `climate` tinyint(1) unsigned NOT NULL DEFAULT '0', + `outdoor` tinyint(1) unsigned NOT NULL DEFAULT '0', + `covered` tinyint(1) unsigned NOT NULL DEFAULT '0', `name` varchar(80) NOT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) @@ -5697,9 +5681,9 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_unit_types` WRITE; /*!40000 ALTER TABLE `pmgr_unit_types` DISABLE KEYS */; -INSERT INTO `pmgr_unit_types` VALUES (1,'xxx','Self Storage',NULL); -INSERT INTO `pmgr_unit_types` VALUES (2,'xxx','Yard Parking',NULL); -INSERT INTO `pmgr_unit_types` VALUES (3,'xxx','Apartment',NULL); +INSERT INTO `pmgr_unit_types` VALUES (1,'xxx',0,1,0,0,0,'Self Storage',NULL); +INSERT INTO `pmgr_unit_types` VALUES (2,'xxx',0,0,0,1,0,'Yard Parking',NULL); +INSERT INTO `pmgr_unit_types` VALUES (3,'xxx',1,0,0,0,0,'Apartment',NULL); /*!40000 ALTER TABLE `pmgr_unit_types` ENABLE KEYS */; UNLOCK TABLES; @@ -5716,7 +5700,6 @@ CREATE TABLE `pmgr_units` ( `code` varchar(12) NOT NULL, `name` varchar(80) NOT NULL, `status` enum('DELETED','DAMAGED','COMPANY','UNAVAILABLE','RESERVED','DIRTY','VACANT','OCCUPIED','LOCKED','LIENED') NOT NULL DEFAULT 'VACANT', - `current_lease_id` int(10) unsigned DEFAULT NULL, `sort_order` mediumint(8) unsigned NOT NULL, `walk_order` mediumint(8) unsigned NOT NULL, `deposit` float(12,2) DEFAULT NULL, @@ -5732,84 +5715,84 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_units` WRITE; /*!40000 ALTER TABLE `pmgr_units` DISABLE KEYS */; -INSERT INTO `pmgr_units` VALUES (1,1,'10','10','OCCUPIED',11,23,10,25.00,90.00,NULL); -INSERT INTO `pmgr_units` VALUES (2,1,'11','11','VACANT',13,24,9,25.00,90.00,NULL); -INSERT INTO `pmgr_units` VALUES (3,1,'12','12','VACANT',NULL,25,8,25.00,90.00,NULL); -INSERT INTO `pmgr_units` VALUES (4,1,'13','13','OCCUPIED',18,26,7,25.00,90.00,NULL); -INSERT INTO `pmgr_units` VALUES (5,2,'14','14','OCCUPIED',3,27,6,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (6,2,'15','15','VACANT',47,28,5,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (7,2,'16','16','OCCUPIED',21,29,4,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (8,2,'17','17','VACANT',8,30,3,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (9,2,'18','18','OCCUPIED',27,31,2,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (10,2,'19','19','VACANT',10,32,1,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (11,2,'22','22','UNAVAILABLE',NULL,33,50,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (12,2,'23','23','VACANT',50,34,49,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (13,2,'24','24','OCCUPIED',33,35,48,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (14,2,'25','25','VACANT',NULL,36,47,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (15,2,'26','26','OCCUPIED',22,37,46,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (16,2,'27','27','OCCUPIED',5,38,45,25.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (17,1,'28','28','VACANT',17,39,31,25.00,90.00,NULL); -INSERT INTO `pmgr_units` VALUES (18,1,'29','29','OCCUPIED',2,40,30,25.00,90.00,NULL); -INSERT INTO `pmgr_units` VALUES (19,1,'30','30','OCCUPIED',15,41,29,25.00,90.00,NULL); -INSERT INTO `pmgr_units` VALUES (20,3,'31','31','OCCUPIED',NULL,42,28,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (21,3,'32','32','VACANT',37,43,27,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (22,3,'33','33','OCCUPIED',49,44,26,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (23,3,'34','34','OCCUPIED',51,45,25,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (24,3,'35','35','VACANT',26,46,24,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (25,3,'36','36','OCCUPIED',38,47,23,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (26,4,'37','37','OCCUPIED',31,48,22,25.00,50.00,NULL); -INSERT INTO `pmgr_units` VALUES (27,4,'38','38','UNAVAILABLE',NULL,49,21,25.00,50.00,NULL); -INSERT INTO `pmgr_units` VALUES (28,5,'39','39','OCCUPIED',14,50,68,25.00,80.00,NULL); -INSERT INTO `pmgr_units` VALUES (29,6,'40','40','LOCKED',NULL,51,67,25.00,55.00,NULL); -INSERT INTO `pmgr_units` VALUES (30,6,'41','41','LOCKED',NULL,52,66,25.00,55.00,NULL); -INSERT INTO `pmgr_units` VALUES (31,6,'42','42','OCCUPIED',NULL,53,65,25.00,55.00,NULL); -INSERT INTO `pmgr_units` VALUES (32,6,'43','43','VACANT',NULL,54,64,25.00,55.00,NULL); -INSERT INTO `pmgr_units` VALUES (33,6,'44','44','VACANT',NULL,55,63,25.00,55.00,NULL); -INSERT INTO `pmgr_units` VALUES (34,6,'45','45','OCCUPIED',4,56,62,25.00,55.00,NULL); -INSERT INTO `pmgr_units` VALUES (35,7,'A01','A01','VACANT',35,1,39,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (36,7,'A02','A02','VACANT',NULL,2,40,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (37,7,'A03','A03','OCCUPIED',9,3,41,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (38,7,'A04','A04','OCCUPIED',7,4,42,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (39,8,'A05','A05','VACANT',NULL,5,43,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (40,8,'A06','A06','VACANT',NULL,6,44,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (41,9,'APT','APT','OCCUPIED',40,68,20,150.00,375.00,NULL); -INSERT INTO `pmgr_units` VALUES (42,7,'B01','B01','OCCUPIED',19,7,32,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (43,7,'B02','B02','VACANT',6,8,33,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (44,7,'B03','B03','VACANT',NULL,9,34,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (45,7,'B04','B04','VACANT',41,10,35,25.00,49.00,NULL); -INSERT INTO `pmgr_units` VALUES (46,8,'B05','B05','LOCKED',42,11,36,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (47,8,'B06','B06','OCCUPIED',16,12,37,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (48,8,'B07','B07','VACANT',NULL,13,38,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (49,10,'C01','C01','OCCUPIED',43,14,11,25.00,40.00,NULL); -INSERT INTO `pmgr_units` VALUES (50,10,'C02','C02','OCCUPIED',25,15,12,25.00,40.00,NULL); -INSERT INTO `pmgr_units` VALUES (51,10,'C03','C03','OCCUPIED',20,16,13,25.00,40.00,NULL); -INSERT INTO `pmgr_units` VALUES (52,10,'C04','C04','OCCUPIED',36,17,14,25.00,40.00,NULL); -INSERT INTO `pmgr_units` VALUES (53,10,'C05','C05','VACANT',12,18,15,25.00,40.00,NULL); -INSERT INTO `pmgr_units` VALUES (54,10,'C06','C06','OCCUPIED',NULL,19,16,25.00,40.00,NULL); -INSERT INTO `pmgr_units` VALUES (55,8,'C07','C07','VACANT',NULL,20,17,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (56,8,'C08','C08','VACANT',28,21,18,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (57,8,'C09','C09','OCCUPIED',NULL,22,19,25.00,63.00,NULL); -INSERT INTO `pmgr_units` VALUES (58,3,'D01','D01','OCCUPIED',1,57,61,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (59,3,'D02','D02','OCCUPIED',23,58,60,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (60,3,'D03','D03','OCCUPIED',30,59,59,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (61,3,'D04','D04','OCCUPIED',45,60,58,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (62,3,'D05','D05','OCCUPIED',24,61,57,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (63,3,'D06','D06','OCCUPIED',NULL,62,56,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (64,3,'D07','D07','OCCUPIED',39,63,55,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (65,3,'D08','D08','OCCUPIED',NULL,64,54,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (66,3,'D09','D09','OCCUPIED',32,65,53,25.00,70.00,NULL); -INSERT INTO `pmgr_units` VALUES (67,11,'D10','D10','VACANT',48,66,52,25.00,60.00,NULL); -INSERT INTO `pmgr_units` VALUES (68,11,'D11','D11','VACANT',NULL,67,51,25.00,60.00,NULL); -INSERT INTO `pmgr_units` VALUES (69,12,'Y01','Y01','OCCUPIED',34,69,69,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (70,12,'Y02','Y02','OCCUPIED',29,70,70,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (71,12,'Y03','Y03','OCCUPIED',52,71,71,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (72,12,'Y04','Y04','VACANT',NULL,72,72,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (73,12,'Y05','Y05','OCCUPIED',NULL,73,73,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (74,12,'Y06','Y06','VACANT',NULL,74,74,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (75,12,'Y07','Y07','UNAVAILABLE',NULL,75,75,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (76,12,'Y08','Y08','UNAVAILABLE',NULL,76,76,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (77,12,'Y09','Y09','UNAVAILABLE',NULL,77,77,0.00,35.00,NULL); -INSERT INTO `pmgr_units` VALUES (78,12,'Y10','Y10','UNAVAILABLE',NULL,78,78,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (1,1,'10','10','OCCUPIED',23,10,25.00,90.00,NULL); +INSERT INTO `pmgr_units` VALUES (2,1,'11','11','VACANT',24,9,25.00,90.00,NULL); +INSERT INTO `pmgr_units` VALUES (3,1,'12','12','VACANT',25,8,25.00,90.00,NULL); +INSERT INTO `pmgr_units` VALUES (4,1,'13','13','OCCUPIED',26,7,25.00,90.00,NULL); +INSERT INTO `pmgr_units` VALUES (5,2,'14','14','OCCUPIED',27,6,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (6,2,'15','15','VACANT',28,5,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (7,2,'16','16','OCCUPIED',29,4,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (8,2,'17','17','VACANT',30,3,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (9,2,'18','18','OCCUPIED',31,2,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (10,2,'19','19','VACANT',32,1,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (11,2,'22','22','DAMAGED',33,50,25.00,35.00,'Water leaks down the east wall'); +INSERT INTO `pmgr_units` VALUES (12,2,'23','23','VACANT',34,49,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (13,2,'24','24','OCCUPIED',35,48,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (14,2,'25','25','VACANT',36,47,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (15,2,'26','26','OCCUPIED',37,46,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (16,2,'27','27','OCCUPIED',38,45,25.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (17,1,'28','28','VACANT',39,31,25.00,90.00,NULL); +INSERT INTO `pmgr_units` VALUES (18,1,'29','29','OCCUPIED',40,30,25.00,90.00,NULL); +INSERT INTO `pmgr_units` VALUES (19,1,'30','30','OCCUPIED',41,29,25.00,90.00,NULL); +INSERT INTO `pmgr_units` VALUES (20,3,'31','31','OCCUPIED',42,28,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (21,3,'32','32','VACANT',43,27,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (22,3,'33','33','OCCUPIED',44,26,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (23,3,'34','34','OCCUPIED',45,25,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (24,3,'35','35','VACANT',46,24,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (25,3,'36','36','OCCUPIED',47,23,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (26,4,'37','37','OCCUPIED',48,22,25.00,50.00,NULL); +INSERT INTO `pmgr_units` VALUES (27,4,'38','38','COMPANY',49,21,25.00,50.00,'Contains lumber, tools, etc.'); +INSERT INTO `pmgr_units` VALUES (28,5,'39','39','OCCUPIED',50,68,25.00,80.00,NULL); +INSERT INTO `pmgr_units` VALUES (29,6,'40','40','LOCKED',51,67,25.00,55.00,NULL); +INSERT INTO `pmgr_units` VALUES (30,6,'41','41','LOCKED',52,66,25.00,55.00,NULL); +INSERT INTO `pmgr_units` VALUES (31,6,'42','42','OCCUPIED',53,65,25.00,55.00,NULL); +INSERT INTO `pmgr_units` VALUES (32,6,'43','43','VACANT',54,64,25.00,55.00,NULL); +INSERT INTO `pmgr_units` VALUES (33,6,'44','44','VACANT',55,63,25.00,55.00,NULL); +INSERT INTO `pmgr_units` VALUES (34,6,'45','45','OCCUPIED',56,62,25.00,55.00,NULL); +INSERT INTO `pmgr_units` VALUES (35,7,'A01','A01','VACANT',1,39,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (36,7,'A02','A02','VACANT',2,40,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (37,7,'A03','A03','OCCUPIED',3,41,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (38,7,'A04','A04','OCCUPIED',4,42,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (39,8,'A05','A05','VACANT',5,43,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (40,8,'A06','A06','VACANT',6,44,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (41,9,'APT','APT','OCCUPIED',68,20,150.00,375.00,NULL); +INSERT INTO `pmgr_units` VALUES (42,7,'B01','B01','OCCUPIED',7,32,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (43,7,'B02','B02','VACANT',8,33,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (44,7,'B03','B03','VACANT',9,34,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (45,7,'B04','B04','VACANT',10,35,25.00,49.00,NULL); +INSERT INTO `pmgr_units` VALUES (46,8,'B05','B05','LOCKED',11,36,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (47,8,'B06','B06','OCCUPIED',12,37,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (48,8,'B07','B07','VACANT',13,38,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (49,10,'C01','C01','OCCUPIED',14,11,25.00,40.00,NULL); +INSERT INTO `pmgr_units` VALUES (50,10,'C02','C02','OCCUPIED',15,12,25.00,40.00,NULL); +INSERT INTO `pmgr_units` VALUES (51,10,'C03','C03','OCCUPIED',16,13,25.00,40.00,NULL); +INSERT INTO `pmgr_units` VALUES (52,10,'C04','C04','OCCUPIED',17,14,25.00,40.00,NULL); +INSERT INTO `pmgr_units` VALUES (53,10,'C05','C05','VACANT',18,15,25.00,40.00,NULL); +INSERT INTO `pmgr_units` VALUES (54,10,'C06','C06','OCCUPIED',19,16,25.00,40.00,NULL); +INSERT INTO `pmgr_units` VALUES (55,8,'C07','C07','VACANT',20,17,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (56,8,'C08','C08','VACANT',21,18,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (57,8,'C09','C09','OCCUPIED',22,19,25.00,63.00,NULL); +INSERT INTO `pmgr_units` VALUES (58,3,'D01','D01','OCCUPIED',57,61,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (59,3,'D02','D02','OCCUPIED',58,60,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (60,3,'D03','D03','OCCUPIED',59,59,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (61,3,'D04','D04','OCCUPIED',60,58,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (62,3,'D05','D05','OCCUPIED',61,57,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (63,3,'D06','D06','OCCUPIED',62,56,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (64,3,'D07','D07','OCCUPIED',63,55,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (65,3,'D08','D08','OCCUPIED',64,54,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (66,3,'D09','D09','OCCUPIED',65,53,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (67,11,'D10','D10','VACANT',66,52,25.00,60.00,NULL); +INSERT INTO `pmgr_units` VALUES (68,11,'D11','D11','VACANT',67,51,25.00,60.00,NULL); +INSERT INTO `pmgr_units` VALUES (69,12,'Y01','Y01','OCCUPIED',69,69,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (70,12,'Y02','Y02','OCCUPIED',70,70,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (71,12,'Y03','Y03','OCCUPIED',71,71,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (72,12,'Y04','Y04','VACANT',72,72,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (73,12,'Y05','Y05','OCCUPIED',73,73,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (74,12,'Y06','Y06','VACANT',74,74,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (75,12,'Y07','Y07','VACANT',75,75,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (76,12,'Y08','Y08','VACANT',76,76,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (77,12,'Y09','Y09','VACANT',77,77,0.00,35.00,NULL); +INSERT INTO `pmgr_units` VALUES (78,12,'Y10','Y10','VACANT',78,78,0.00,35.00,NULL); /*!40000 ALTER TABLE `pmgr_units` ENABLE KEYS */; UNLOCK TABLES; @@ -5880,4 +5863,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2009-08-19 20:30:11 +-- Dump completed on 2009-08-26 20:06:39 diff --git a/db/schema.sql b/db/schema.sql index f7b7731..fbe02a9 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -475,8 +475,6 @@ CREATE TABLE `pmgr_units` ( 'LIENED') NOT NULL DEFAULT 'VACANT', - `current_lease_id` INT(10) UNSIGNED DEFAULT NULL, - `sort_order` MEDIUMINT UNSIGNED NOT NULL, `walk_order` MEDIUMINT UNSIGNED NOT NULL, diff --git a/site/.htaccess b/site/.htaccess index 0ed8662..f922a22 100644 --- a/site/.htaccess +++ b/site/.htaccess @@ -2,4 +2,24 @@ RewriteEngine on RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] - \ No newline at end of file + + +# Lets deny everyone -- its a clean slate! +order deny,allow +deny from all + +# Now allow local access +# Localhost +allow from 127.0.0 +# Local subnet +allow from 192.168.7 + +# Provide a mechanism for user authentication +AuthType Digest +AuthName "Property Manager" +AuthUserFile "D:/Website/auth/pmgr.htpasswd" +Require valid-user + +# Instead of satisfy all (too restrictive) +# This allows EITHER local domain OR authenticated user +satisfy any diff --git a/site/app_controller.php b/site/app_controller.php index 9a57e4b..ab29fee 100644 --- a/site/app_controller.php +++ b/site/app_controller.php @@ -38,7 +38,7 @@ class AppController extends Controller { var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time', 'Grid'); var $components = array('DebugKit.Toolbar'); - var $sidemenu_areas = array('SITE' => false, 'CONTROLLER' => false, 'ACTION' => false); + var $sidemenu = array('areas' => array('SITE' => false, 'CONTROLLER' => false, 'ACTION' => false)); var $std_area = 10; var $new_area = 20; var $op_area = 30; @@ -61,7 +61,7 @@ class AppController extends Controller { function sideMenuAreaVerify(&$area, $subarea, $priority = null) { $area = strtoupper($area); - if (!array_key_exists($area, $this->sidemenu_areas)) + if (!array_key_exists($area, $this->sidemenu['areas'])) $this->INTERNAL_ERROR("Sidemenu link '{$area}': Unknown"); if ($area == 'SITE') @@ -71,9 +71,9 @@ class AppController extends Controller { elseif ($area == 'ACTION') $name = Inflector::humanize(Inflector::singularize($this->params['controller'])); - if (empty($this->sidemenu_areas[$area])) - $this->sidemenu_areas[$area] - = array('enable' => true, 'name' => $name, 'subarea' => array()); + if (empty($this->sidemenu['areas'][$area])) + $this->sidemenu['areas'][$area] + = array('enable' => true, 'name' => $name, 'subareas' => array()); if (empty($subarea)) return; @@ -83,7 +83,7 @@ class AppController extends Controller { $subname .= ''; elseif ($subarea == $this->op_area) //$subname .= '-Ops'; - $subname = 'Operations'; + $subname = 'Actions'; elseif ($subarea == $this->new_area) //$subname .= '-New'; $subname = 'Creation'; @@ -94,15 +94,15 @@ class AppController extends Controller { else $subname .= '-' . $subarea; - if (empty($this->sidemenu_areas[$area]['subarea'][$subarea])) - $this->sidemenu_areas[$area]['subarea'][$subarea] + if (empty($this->sidemenu['areas'][$area]['subareas'][$subarea])) + $this->sidemenu['areas'][$area]['subareas'][$subarea] = array('enable' => true, 'name' => $subname, 'priorities' => array()); if (empty($priority)) return; - if (empty($this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority])) - $this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority] + if (empty($this->sidemenu['areas'][$area]['subareas'][$subarea]['priorities'][$priority])) + $this->sidemenu['areas'][$area]['subareas'][$subarea]['priorities'][$priority] = array(); } @@ -117,9 +117,22 @@ class AppController extends Controller { function sideMenuAreaName($name, $area, $subarea = null) { $this->sideMenuAreaVerify($area, $subarea); if (empty($subarea)) - $this->sidemenu_areas[$area]['name'] = $name; + $this->sidemenu['areas'][$area]['name'] = $name; else - $this->sidemenu_areas[$area]['subarea'][$subarea]['name'] = $name; + $this->sidemenu['areas'][$area]['subareas'][$subarea]['name'] = $name; + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: sideMenuAreaActivate + * - Sets the selected area/subarea to be active when the + * page is first loaded. + */ + + function sideMenuAreaActivate($area, $subarea = null) { + $this->sidemenu['active'] = compact('area', 'subarea'); } @@ -133,9 +146,9 @@ class AppController extends Controller { function sideMenuEnable($area, $subarea = null, $enable = true) { $this->sideMenuAreaVerify($area, $subarea); if (isset($subarea)) - $this->sidemenu_areas[$area]['subarea'][$subarea]['enable'] = $enable; + $this->sidemenu['areas'][$area]['subareas'][$subarea]['enable'] = $enable; else - $this->sidemenu_areas[$area]['enable'] = $enable; + $this->sidemenu['areas'][$area]['enable'] = $enable; } @@ -150,7 +163,7 @@ class AppController extends Controller { if (empty($subarea)) $subarea = $this->std_area; $this->sideMenuAreaVerify($area, $subarea); - $this->sidemenu_areas[$area]['subarea'][$subarea]['priorities'][$priority][] + $this->sidemenu['areas'][$area]['subareas'][$subarea]['priorities'][$priority][] = array('name' => $name, 'url' => $url) + (empty($extra) ? array() : $extra); } @@ -167,6 +180,9 @@ class AppController extends Controller { $this->addSideMenuLink('Site Map', array('controller' => 'maps', 'action' => 'view', 1), null, 'SITE'); + $this->addSideMenuLink('Unit Sizes', + array('controller' => 'unit_sizes', 'action' => 'index'), null, + 'SITE'); $this->addSideMenuLink('Units', array('controller' => 'units', 'action' => 'index'), null, 'SITE'); @@ -179,72 +195,83 @@ class AppController extends Controller { $this->addSideMenuLink('Deposits', array('controller' => 'transactions', 'action' => 'deposit'), null, 'SITE'); + + + $this->addSideMenuLink('Accounts', + array('controller' => 'accounts', 'action' => 'index'), null, + 'SITE', $this->admin_area); + $this->addSideMenuLink('Contacts', + array('controller' => 'contacts', 'action' => 'index'), null, + 'SITE', $this->admin_area); + $this->addSideMenuLink('Ledgers', + array('controller' => 'ledgers', 'action' => 'index'), null, + 'SITE', $this->admin_area); + $this->addSideMenuLink('Tenders', + array('controller' => 'tenders', 'action' => 'index'), null, + 'SITE', $this->admin_area); + $this->addSideMenuLink('Transactions', + array('controller' => 'transactions', 'action' => 'index'), null, + 'SITE', $this->admin_area); + $this->addSideMenuLink('Ldgr Entries', + array('controller' => 'ledger_entries', 'action' => 'index'), null, + 'SITE', $this->admin_area); + $this->addSideMenuLink('Stmt Entries', + array('controller' => 'statement_entries', 'action' => 'index'), null, + 'SITE', $this->admin_area); + $this->addSideMenuLink('Assess Charges', + array('controller' => 'leases', 'action' => 'assess_all'), null, + 'SITE', $this->admin_area); $this->addSideMenuLink('RESET DATA', array('controller' => 'accounts', 'action' => 'reset_data'), null, - 'SITE'); - -/* $this->addSideMenuLink('Move-In', */ -/* array('controller' => 'customers', 'action' => 'move_in'), null, */ -/* 'SITE', $this->op_area); */ - -/* $this->addSideMenuLink('Move-Out', */ -/* array('controller' => 'customers', 'action' => 'move_out'), null, */ -/* 'SITE', $this->op_area); */ - -/* $this->addSideMenuLink('New Receipt', */ -/* array('controller' => 'customers', 'action' => 'receipt'), null, */ -/* 'SITE', $this->op_area); */ - -/* $this->addSideMenuLink('New Customer', */ -/* array('controller' => 'customers', 'action' => 'add'), null, */ -/* 'SITE', $this->op_area); */ - -/* $this->addSideMenuLink('New Deposit', */ -/* array('controller' => 'tenders', 'action' => 'deposit'), null, */ -/* 'SITE', $this->op_area); */ - - if ($this->params['admin']) { - $this->addSideMenuLink('Accounts', - array('controller' => 'accounts', 'action' => 'index'), null, - 'SITE', $this->admin_area); - $this->addSideMenuLink('Contacts', - array('controller' => 'contacts', 'action' => 'index'), null, - 'SITE', $this->admin_area); - $this->addSideMenuLink('Ledgers', - array('controller' => 'ledgers', 'action' => 'index'), null, - 'SITE', $this->admin_area); - $this->addSideMenuLink('Tenders', - array('controller' => 'tenders', 'action' => 'index'), null, - 'SITE', $this->admin_area); - $this->addSideMenuLink('Transactions', - array('controller' => 'transactions', 'action' => 'index'), null, - 'SITE', $this->admin_area); - $this->addSideMenuLink('Ldgr Entries', - array('controller' => 'ledger_entries', 'action' => 'index'), null, - 'SITE', $this->admin_area); - $this->addSideMenuLink('Stmt Entries', - array('controller' => 'statement_entries', 'action' => 'index'), null, - 'SITE', $this->admin_area); - $this->addSideMenuLink('Assess Charges', - array('controller' => 'leases', 'action' => 'assess_all'), null, - 'SITE', $this->admin_area); - } - - if ($this->params['dev']) { - $this->addSideMenuLink('Un-Nuke', - '#', array('htmlAttributes' => - array('onclick' => '$(".pr-section").show(); return false;')), - 'SITE', $this->dev_area); - $this->addSideMenuLink('New Ledgers', - array('controller' => 'accounts', 'action' => 'newledger'), null, - 'SITE', $this->dev_area); - } + 'SITE', $this->admin_area); - $this->sideMenuAreaName('Operations', 'SITE', $this->op_area); + $this->addSideMenuLink('Un-Nuke', + '#', array('htmlAttributes' => + array('onclick' => '$(".pr-section").show(); return false;')), + 'SITE', $this->dev_area); + $this->addSideMenuLink('New Ledgers', + array('controller' => 'accounts', 'action' => 'newledger'), null, + 'SITE', $this->dev_area); + + + $this->addSideMenuLink('New Receipt', + array('controller' => 'customers', 'action' => 'receipt'), null, + 'SITE', $this->op_area); + + $this->addSideMenuLink('New Invoice', + array('controller' => 'leases', 'action' => 'invoice'), null, + 'SITE', $this->op_area); + + $this->addSideMenuLink('Move-In', + array('controller' => 'customers', 'action' => 'move_in'), null, + 'SITE', $this->op_area); + + $this->addSideMenuLink('Move-Out', + array('controller' => 'leases', 'action' => 'move_out'), null, + 'SITE', $this->op_area); + + $this->addSideMenuLink('New Deposit', + array('controller' => 'tenders', 'action' => 'deposit'), null, + 'SITE', $this->op_area); + + // REVISIT : 20090824 + // Depending on preference, we may put this into the gridView + // function, making the links available only when navigating. + $this->addGridViewSideMenuLinks(); } + /************************************************************************** + ************************************************************************** + ************************************************************************** + * virtual: addGridViewSideMenuLinks + * - Adds the grid view specific navigation links, if overridden. + */ + + function addGridViewSideMenuLinks() { + } + /************************************************************************** ************************************************************************** ************************************************************************** @@ -263,6 +290,13 @@ class AppController extends Controller { $this->addDefaultSideMenuLinks(); $this->sideMenuEnable('SITE', $this->op_area, false); + + foreach ($this->sidemenu['areas'] AS $area_name => $area) { + if (empty($this->params['dev'])) + $this->sideMenuEnable($area_name, $this->dev_area, false); + if (empty($this->params['admin'])) + $this->sideMenuEnable($area_name, $this->admin_area, false); + } } @@ -282,24 +316,48 @@ class AppController extends Controller { $this->params['admin'] = false; } - foreach ($this->sidemenu_areas AS &$area) { + foreach ($this->sidemenu['areas'] AS $aname => &$area) { if (empty($area['enable'])) $area = array(); - if (empty($area['subarea'])) + if (empty($area['subareas'])) continue; - ksort($area['subarea']); + ksort($area['subareas']); - foreach ($area['subarea'] AS &$subarea) { + foreach ($area['subareas'] AS $sname => &$subarea) { if (empty($subarea['enable'])) $subarea = array(); if (empty($subarea['priorities'])) continue; ksort($subarea['priorities']); + + foreach ($subarea['priorities'] AS $pname => &$priority) { + if (empty($priority)) + unset($subarea['priorities'][$pname]); } + unset($priority); + + if (empty($subarea['priorities'])) + unset($area['subareas'][$sname]); + } + unset($subarea); + + if (empty($area['subareas'])) + unset($this->sidemenu['areas'][$aname]); + } + unset($area); + + // Activate a default section (unless already specified) + foreach (array_reverse($this->sidemenu['areas']) AS $area_name => $area) { + if (empty($area)) + continue; + + if (empty($this->sidemenu['active']) || + empty($this->sidemenu['areas'][$this->sidemenu['active']['area']])) + $this->sideMenuAreaActivate($area_name); } - //pr($this->sidemenu_areas); - $this->set('sidemenu', $this->sidemenu_areas); + //pr($this->sidemenu); + $this->set('sidemenu', $this->sidemenu); } @@ -373,9 +431,14 @@ class AppController extends Controller { * helper: gridView * - called by derived controllers to create an index listing */ + function index() { + $names = Inflector::humanize(Inflector::pluralize($this->params['controller'])); + $this->gridView('All ' . $names, 'all'); + } function gridView($title, $action = null, $element = null) { $this->sideMenuEnable('SITE', $this->op_area); + $this->sideMenuAreaActivate('CONTROLLER'); $this->set('title', $title); // The resulting page will contain a grid, which will // use ajax to obtain the actual data for this action @@ -512,6 +575,7 @@ class AppController extends Controller { $xml = preg_replace("//", ">", $xml); echo ("\n
\n$xml\n
\n"); + $this->render_empty(); } } @@ -1020,10 +1084,9 @@ class AppController extends Controller { } function gridDataOutputHeader(&$params, &$model) { - if (!$params['debug']) { + if (!$params['debug']) header("Content-type: text/xml;charset=utf-8"); } - } function gridDataOutputXMLHeader(&$params, &$model) { echo "\n"; diff --git a/site/config/core.php b/site/config/core.php index 3add95a..e626837 100644 --- a/site/config/core.php +++ b/site/config/core.php @@ -117,7 +117,7 @@ /** * The name of CakePHP's session cookie. */ - Configure::write('Session.cookie', 'CAKEPHP'); + Configure::write('Session.cookie', 'PMGR'); /** * Session time out time (in seconds). * Actual value depends on 'Security.level' setting. diff --git a/site/config/database.php b/site/config/database.php index 04f6532..f62efc2 100644 --- a/site/config/database.php +++ b/site/config/database.php @@ -10,5 +10,10 @@ class DATABASE_CONFIG { 'database' => 'pmgr_sand', 'prefix' => 'pmgr_', ); + + function __construct() { + if (preg_match("%^/[^/]*sand/%", $_SERVER['REQUEST_URI'])) + $this->default['database'] = 'pmgr_sand'; + } } ?> \ No newline at end of file diff --git a/site/controllers/accounts_controller.php b/site/controllers/accounts_controller.php index ab4f792..b8b7eff 100644 --- a/site/controllers/accounts_controller.php +++ b/site/controllers/accounts_controller.php @@ -8,12 +8,31 @@ class AccountsController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * override: addDefaultSideMenuLinks - * - Adds controller specific default side menu links + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function addDefaultSideMenuLinks() { - parent::addDefaultSideMenuLinks(); + function addGridViewSideMenuLinks() { + parent::addGridViewSideMenuLinks(); + + $this->addSideMenuLink('Asset', + array('controller' => 'accounts', 'action' => 'asset'), null, + 'CONTROLLER', $this->admin_area); + $this->addSideMenuLink('Liability', + array('controller' => 'accounts', 'action' => 'liability'), null, + 'CONTROLLER', $this->admin_area); + $this->addSideMenuLink('Equity', + array('controller' => 'accounts', 'action' => 'equity'), null, + 'CONTROLLER', $this->admin_area); + $this->addSideMenuLink('Income', + array('controller' => 'accounts', 'action' => 'income'), null, + 'CONTROLLER', $this->admin_area); + $this->addSideMenuLink('Expense', + array('controller' => 'accounts', 'action' => 'expense'), null, + 'CONTROLLER', $this->admin_area); + $this->addSideMenuLink('All', + array('controller' => 'accounts', 'action' => 'all'), null, + 'CONTROLLER', $this->admin_area); } @@ -30,29 +49,7 @@ class AccountsController extends AppController { function equity() { $this->gridView('Equity Accounts'); } function income() { $this->gridView('Income Accounts'); } function expense() { $this->gridView('Expense Accounts'); } - function all() { $this->gridView('All Accounts', 'all'); } - - function gridView($title, $action = null, $element = null) { - $this->addSideMenuLink('Asset', - array('controller' => 'accounts', 'action' => 'asset'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Liability', - array('controller' => 'accounts', 'action' => 'liability'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Equity', - array('controller' => 'accounts', 'action' => 'equity'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Income', - array('controller' => 'accounts', 'action' => 'income'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Expense', - array('controller' => 'accounts', 'action' => 'expense'), null, - 'CONTROLLER'); - $this->addSideMenuLink('All', - array('controller' => 'accounts', 'action' => 'all'), null, - 'CONTROLLER'); - parent::gridView($title, $action, $element); - } + function all() { $this->gridView('All Accounts', 'all'); } /************************************************************************** @@ -204,10 +201,10 @@ class AccountsController extends AppController { $this->addSideMenuLink('New Ledger', array('action' => 'newledger', $id), null, - 'ACTION'); + 'ACTION', $this->admin_area); $this->addSideMenuLink('Collected', array('action' => 'collected', $id), null, - 'ACTION'); + 'ACTION', $this->admin_area); // Prepare to render $title = 'Account: ' . $account['Account']['name']; diff --git a/site/controllers/contacts_controller.php b/site/controllers/contacts_controller.php index 8d24e38..29b740c 100644 --- a/site/controllers/contacts_controller.php +++ b/site/controllers/contacts_controller.php @@ -23,6 +23,19 @@ class ContactsController extends AppController { * to jqGrid. */ + function gridDataFilterTablesConfig(&$params, &$model, $table) { + $config = parent::gridDataFilterTablesConfig($params, $model, $table); + + // Special case for Customer; We need the Contact/Customer relationship + if ($table == 'Customer') + $config = array('fields' => array('ContactsCustomer.type', + 'ContactsCustomer.active'), + 'conditions' => array('ContactsCustomer.active' => true), + ); + + return $config; + } + function gridDataOrder(&$params, &$model, $index, $direction) { $order = parent::gridDataOrder($params, $model, $index, $direction); @@ -37,7 +50,7 @@ class ContactsController extends AppController { } function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { - $links['Contact'] = array('last_name', 'first_name'); + $links['Contact'] = array('display_name'); return parent::gridDataPostProcessLinks($params, $model, $records, $links); } diff --git a/site/controllers/customers_controller.php b/site/controllers/customers_controller.php index b5d423c..be4ec30 100644 --- a/site/controllers/customers_controller.php +++ b/site/controllers/customers_controller.php @@ -6,12 +6,26 @@ class CustomersController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * override: addDefaultSideMenuLinks - * - Adds controller specific default side menu links + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function addDefaultSideMenuLinks() { - parent::addDefaultSideMenuLinks(); + function addGridViewSideMenuLinks() { + parent::addGridViewSideMenuLinks(); + + $this->addSideMenuLink('Current', + array('controller' => 'customers', 'action' => 'current'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Past', + array('controller' => 'customers', 'action' => 'past'), null, + 'CONTROLLER'); + $this->addSideMenuLink('All', + array('controller' => 'customers', 'action' => 'all'), null, + 'CONTROLLER'); + + $this->addSideMenuLink('New Customer', + array('controller' => 'customers', 'action' => 'add'), null, + 'ACTION', $this->new_area); } @@ -27,25 +41,6 @@ class CustomersController extends AppController { function past() { $this->gridView('Past Tenants'); } function all() { $this->gridView('All Customers'); } - function gridView($title, $action = null, $element = null) { - $this->addSideMenuLink('Current', - array('controller' => 'customers', 'action' => 'current'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Past', - array('controller' => 'customers', 'action' => 'past'), null, - 'CONTROLLER'); - $this->addSideMenuLink('All', - array('controller' => 'customers', 'action' => 'all'), null, - 'CONTROLLER'); - - $this->sideMenuAreaName('Creation', 'ACTION', $this->new_area); - $this->addSideMenuLink('New Customer', - array('controller' => 'customers', 'action' => 'add'), null, - 'ACTION', $this->new_area); - - parent::gridView($title, $action, $element); - } - /************************************************************************** ************************************************************************** @@ -92,19 +87,29 @@ class CustomersController extends AppController { return $conditions; } - function gridDataOrder(&$params, &$model, $index, $direction) { - $order = array(); - $order[] = parent::gridDataOrder($params, $model, $index, $direction); + function gridDataFilterTablesConfig(&$params, &$model, $table) { + $config = parent::gridDataFilterTablesConfig($params, $model, $table); - if ($index !== 'PrimaryContact.last_name') - $order[] = parent::gridDataOrder($params, $model, - 'PrimaryContact.last_name', $direction); - if ($index !== 'PrimaryContact.first_name') - $order[] = parent::gridDataOrder($params, $model, - 'PrimaryContact.first_name', $direction); - if ($index !== 'Customer.id') - $order[] = parent::gridDataOrder($params, $model, - 'Customer.id', $direction); + // Special case for Contact; We need the Contact/Customer relationship + if ($table == 'Contact') + $config = array('fields' => array('ContactsCustomer.type', + 'ContactsCustomer.active'), + 'conditions' => array('ContactsCustomer.active' => true), + ); + + return $config; + } + + function gridDataOrder(&$params, &$model, $index, $direction) { + $order = parent::gridDataOrder($params, $model, $index, $direction); + + // After sorting by whatever the user wants, add these + // defaults into the sort mechanism. If we're already + // sorting by one of them, it will only be redundant, + // and should cause no harm (possible a longer query?) + $order[] = 'PrimaryContact.last_name ' . $direction; + $order[] = 'PrimaryContact.first_name ' . $direction; + $order[] = 'Customer.id ' . $direction; return $order; } @@ -122,14 +127,18 @@ class CustomersController extends AppController { * - Sets up the move-in page for the given customer. */ - function move_in($id = null) { + function move_in($id = null, $unit_id = null) { $customer = array(); $unit = array(); - if (isset($id)) { + if (!empty($id)) { $this->Customer->recursive = -1; $customer = current($this->Customer->read(null, $id)); } + if (!empty($unit_id)) { + $this->Customer->Lease->Unit->recursive = -1; + $unit = current($this->Customer->Lease->Unit->read(null, $unit_id)); + } $this->set(compact('customer', 'unit')); $title = 'Customer Move-In'; @@ -230,36 +239,58 @@ class CustomersController extends AppController { $outstanding_deposit = $this->Customer->securityDepositBalance($id); // Figure out if this customer has any non-closed leases - $show_moveout = false; - $show_payment = false; + $show_moveout = false; $moveout_lease_id = null; + $show_payment = false; $payment_lease_id = null; foreach ($customer['Lease'] AS $lease) { - if (!isset($lease['close_date'])) + if (!isset($lease['close_date'])) { + if ($show_payment) + $payment_lease_id = null; + else + $payment_lease_id = $lease['id']; $show_payment = true; - if (!isset($lease['moveout_date'])) + } + if (!isset($lease['moveout_date'])) { + if ($show_moveout) + $moveout_lease_id = null; + else + $moveout_lease_id = $lease['id']; $show_moveout = true; + } } // Set up dynamic menu items - $this->addSideMenuLink('Edit', - array('action' => 'edit', $id), null, - 'ACTION'); - - $this->addSideMenuLink('Move-In', - array('action' => 'move_in', $id), null, - 'ACTION'); - -/* if ($show_moveout) { */ -/* $this->addSideMenuLink('Move-Out', */ -/* array('action' => 'move_out', $id), null, */ -/* 'ACTION'); */ -/* } */ - if ($show_payment || $outstanding_balance > 0) $this->addSideMenuLink('New Receipt', array('action' => 'receipt', $id), null, 'ACTION'); + if ($show_payment) { +/* $ids = $this->Customer->leaseIds($id, true); */ +/* if (count($ids) == 1) */ +/* $lease_id = $ids[0]; */ +/* else */ +/* $lease_id = null; */ + + $this->addSideMenuLink('New Invoice', + array('controller' => 'leases', + 'action' => 'invoice', + $payment_lease_id), null, + 'ACTION'); + } + + $this->addSideMenuLink('Move-In', + array('action' => 'move_in', $id), null, + 'ACTION'); + + if ($show_moveout) { + $this->addSideMenuLink('Move-Out', + array('controller' => 'leases', + 'action' => 'move_out', + $moveout_lease_id), null, + 'ACTION'); + } + if (!$show_moveout && $outstanding_balance > 0) $this->addSideMenuLink('Write-Off', array('action' => 'bad_debt', $id), null, @@ -270,6 +301,10 @@ class CustomersController extends AppController { array('action' => 'refund', $id), null, 'ACTION'); + $this->addSideMenuLink('Edit', + array('action' => 'edit', $id), null, + 'ACTION'); + // Prepare to render. $title = 'Customer: ' . $customer['Customer']['name']; $this->set(compact('customer', 'title', @@ -326,7 +361,17 @@ class CustomersController extends AppController { $this->redirect(array('action'=>'view', $this->Customer->id)); // Since this is a new customer, go to the move in screen. - $this->redirect(array('action'=>'move_in', $this->Customer->id)); + // First set the move-in unit id, if there is one, ... + if (empty($this->data['movein']['Unit']['id'])) + $unit_id = null; + else + $unit_id = $this->data['movein']['Unit']['id']; + + // ... then redirect + $this->redirect(array('action'=>'move_in', + $this->Customer->id, + $unit_id, + )); } if ($id) { @@ -389,7 +434,8 @@ class CustomersController extends AppController { * - Add a new customer */ - function add() { + function add($unit_id = null) { + $this->set('movein', array('Unit' => array('id' => $unit_id))); $this->edit(); } diff --git a/site/controllers/leases_controller.php b/site/controllers/leases_controller.php index 9891624..902c5d6 100644 --- a/site/controllers/leases_controller.php +++ b/site/controllers/leases_controller.php @@ -6,29 +6,13 @@ class LeasesController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * override: addDefaultSideMenuLinks - * - Adds controller specific default side menu links + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function addDefaultSideMenuLinks() { - parent::addDefaultSideMenuLinks(); - } + function addGridViewSideMenuLinks() { + parent::addGridViewSideMenuLinks(); - - /************************************************************************** - ************************************************************************** - ************************************************************************** - * action: index / active / closed / all - * - Generate a listing of leases - */ - - function index() { $this->all(); } - function active() { $this->gridView('Active Leases'); } - function delinquent() { $this->gridView('Delinquent Leases'); } - function closed() { $this->gridView('Closed Leases'); } - function all() { $this->gridView('All Leases', 'all'); } - - function gridView($title, $action = null, $element = null) { $this->addSideMenuLink('Active', array('controller' => 'leases', 'action' => 'active'), null, 'CONTROLLER'); @@ -41,10 +25,23 @@ class LeasesController extends AppController { $this->addSideMenuLink('All', array('controller' => 'leases', 'action' => 'all'), null, 'CONTROLLER'); - parent::gridView($title, $action, $element); } + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: index / active / closed / all + * - Generate a listing of leases + */ + + function index() { $this->active(); } + function active() { $this->gridView('Active Leases', 'active'); } + function delinquent() { $this->gridView('Delinquent Leases'); } + function closed() { $this->gridView('Closed Leases'); } + function all() { $this->gridView('All Leases'); } + + /************************************************************************** ************************************************************************** ************************************************************************** @@ -186,42 +183,43 @@ class LeasesController extends AppController { $this->data['Lease']['moveout_date'] ); - $this->redirect($this->data['redirect']); + $this->redirect(array('controller' => 'leases', + 'action' => 'view', + $this->data['Lease']['id'])); } - if (!isset($id)) - die("Oh Nooooo!!"); + if (isset($id)) { + $lease = $this->Lease->find + ('first', array + ('contain' => array + (// Models + 'Unit' => + array('order' => array('sort_order'), + 'fields' => array('id', 'name'), + ), - $lease = $this->Lease->find - ('first', array - ('contain' => array - (// Models - 'Unit' => - array('order' => array('sort_order'), - 'fields' => array('id', 'name'), - ), + 'Customer' => + array('fields' => array('id', 'name'), + ), + ), - 'Customer' => - array('fields' => array('id', 'name'), - ), - ), + 'conditions' => array(array('Lease.id' => $id), + array('Lease.close_date' => null), + ), + )); + $this->set('customer', $lease['Customer']); + $this->set('unit', $lease['Unit']); + $this->set('lease', $lease['Lease']); - 'conditions' => array(array('Lease.id' => $id), - array('Lease.close_date' => null), - ), - )); - $this->set('customer', $lease['Customer']); - $this->set('unit', $lease['Unit']); - $this->set('lease', $lease['Lease']); + $title = ('Lease #' . $lease['Lease']['number'] . ': ' . + $lease['Unit']['name'] . ': ' . + $lease['Customer']['name'] . ': Move-Out'); + } + else { + $title = 'Move-Out'; + } - $redirect = array('controller' => 'leases', - 'action' => 'view', - $id); - - $title = ('Lease #' . $lease['Lease']['number'] . ': ' . - $lease['Unit']['name'] . ': ' . - $lease['Customer']['name'] . ': Prepare Move-Out'); - $this->set(compact('title', 'redirect')); + $this->set(compact('title')); $this->render('/leases/move'); } diff --git a/site/controllers/ledgers_controller.php b/site/controllers/ledgers_controller.php index 7ab3e6a..60211a3 100644 --- a/site/controllers/ledgers_controller.php +++ b/site/controllers/ledgers_controller.php @@ -6,12 +6,22 @@ class LedgersController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * override: addDefaultSideMenuLinks - * - Adds controller specific default side menu links + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function addDefaultSideMenuLinks() { - parent::addDefaultSideMenuLinks(); + function addGridViewSideMenuLinks() { + parent::addGridViewSideMenuLinks(); + + $this->addSideMenuLink('Current', + array('controller' => 'ledgers', 'action' => 'current'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Closed', + array('controller' => 'ledgers', 'action' => 'closed'), null, + 'CONTROLLER'); + $this->addSideMenuLink('All', + array('controller' => 'ledgers', 'action' => 'all'), null, + 'CONTROLLER'); } @@ -27,19 +37,6 @@ class LedgersController extends AppController { function closed() { $this->gridView('Closed Ledgers'); } function all() { $this->gridView('All Ledgers', 'all'); } - function gridView($title, $action = null, $element = null) { - $this->addSideMenuLink('Current', - array('controller' => 'ledgers', 'action' => 'current'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Closed', - array('controller' => 'ledgers', 'action' => 'closed'), null, - 'CONTROLLER'); - $this->addSideMenuLink('All', - array('controller' => 'ledgers', 'action' => 'all'), null, - 'CONTROLLER'); - parent::gridView($title, $action, $element); - } - /************************************************************************** ************************************************************************** diff --git a/site/controllers/maps_controller.php b/site/controllers/maps_controller.php index 4a073ad..d992182 100644 --- a/site/controllers/maps_controller.php +++ b/site/controllers/maps_controller.php @@ -52,6 +52,7 @@ class MapsController extends AppController { $this->Session->setFlash(__('Invalid Item.', true)); $this->redirect(array('action'=>'index')); } + $this->sideMenuEnable('SITE', $this->op_area); $this->set('info', $this->mapInfo($id, $requested_width)); $this->set('title', "Site Map"); } diff --git a/site/controllers/tenders_controller.php b/site/controllers/tenders_controller.php index c44925a..de3b909 100644 --- a/site/controllers/tenders_controller.php +++ b/site/controllers/tenders_controller.php @@ -150,12 +150,6 @@ class TendersController extends AppController { )); - // Watch out for the special "Closing" entries - if (!empty($tender['TenderType']['id'])) - $this->addSideMenuLink('Edit', - array('action' => 'edit', $id), null, - 'ACTION'); - if (!empty($tender['Tender']['deposit_transaction_id']) && empty($tender['Tender']['nsf_transaction_id']) // Hard to tell what types of items can come back as NSF. @@ -168,6 +162,13 @@ class TendersController extends AppController { 'ACTION'); } + // Watch out for the special "Closing" entries, which have + // tender_type_id set to NULL. Otherwise, allow editing. + if (!empty($tender['TenderType']['id'])) + $this->addSideMenuLink('Edit', + array('action' => 'edit', $id), null, + 'ACTION'); + // Prepare to render. $title = "Tender #{$tender['Tender']['id']} : {$tender['Tender']['name']}"; $this->set(compact('tender', 'title')); diff --git a/site/controllers/transactions_controller.php b/site/controllers/transactions_controller.php index e80085c..4b666da 100644 --- a/site/controllers/transactions_controller.php +++ b/site/controllers/transactions_controller.php @@ -8,12 +8,31 @@ class TransactionsController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * override: addDefaultSideMenuLinks - * - Adds controller specific default side menu links + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function addDefaultSideMenuLinks() { - parent::addDefaultSideMenuLinks(); + function addGridViewSideMenuLinks() { + parent::addGridViewSideMenuLinks(); + + $this->addSideMenuLink('Invoices', + array('controller' => 'transactions', 'action' => 'invoice'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Receipts', + array('controller' => 'transactions', 'action' => 'receipt'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Deposits', + array('controller' => 'transactions', 'action' => 'deposit'), null, + 'CONTROLLER'); + $this->addSideMenuLink('All', + array('controller' => 'transactions', 'action' => 'all'), null, + 'CONTROLLER'); + + // REVISIT : 20090824 + // Right now, we wish to keep things simple. Don't make these + // links available to non-admin users. + if (empty($this->params['admin'])) + $this->sideMenuEnable('CONTROLLER', $this->std_area, false); } @@ -29,29 +48,12 @@ class TransactionsController extends AppController { function invoice() { $this->gridView('Invoices'); } function receipt() { $this->gridView('Receipts'); } function deposit() { - if (empty($this->params['admin'])) - $this->sideMenuEnable('CONTROLLER', $this->std_area, false); $this->addSideMenuLink('New Deposit', array('controller' => 'tenders', 'action' => 'deposit'), null, - 'ACTION'); + 'ACTION', $this->new_area); $this->gridView('Deposits'); } - function gridView($title, $action = null, $element = null) { - $this->addSideMenuLink('Invoices', - array('controller' => 'transactions', 'action' => 'invoice'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Receipts', - array('controller' => 'transactions', 'action' => 'receipt'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Deposits', - array('controller' => 'transactions', 'action' => 'deposit'), null, - 'CONTROLLER'); - $this->addSideMenuLink('All', - array('controller' => 'transactions', 'action' => 'all'), null, - 'CONTROLLER'); - parent::gridView($title, $action, $element); - } /************************************************************************** ************************************************************************** @@ -424,14 +426,13 @@ class TransactionsController extends AppController { array('action' => 'deposit_slip', $id), null, 'ACTION'); - if ($this->params['dev']) - $this->addSideMenuLink('Destroy', - array('action' => 'destroy', $id), - array('confirmMessage' => - "This may leave the database in an unstable state." . - " Do NOT do this unless you know what you're doing." . - " Proceed anyway?"), - 'ACTION', $this->dev_area); + $this->addSideMenuLink('Destroy', + array('action' => 'destroy', $id), + array('confirmMessage' => + "This may leave the database in an unstable state." . + " Do NOT do this unless you know what you're doing." . + " Proceed anyway?"), + 'ACTION', $this->dev_area); // OK, prepare to render. $title = 'Transaction #' . $transaction['Transaction']['id']; diff --git a/site/controllers/unit_sizes_controller.php b/site/controllers/unit_sizes_controller.php new file mode 100644 index 0000000..a6f3633 --- /dev/null +++ b/site/controllers/unit_sizes_controller.php @@ -0,0 +1,238 @@ +addSideMenuLink('1 Bedroom', + array('controller' => 'unit_sizes', 'action' => 'bd1'), null, + 'CONTROLLER'); + $this->addSideMenuLink('2 Bedroom', + array('controller' => 'unit_sizes', 'action' => 'bd2'), null, + 'CONTROLLER'); + $this->addSideMenuLink('3 Bedroom', + array('controller' => 'unit_sizes', 'action' => 'bd3'), null, + 'CONTROLLER'); + $this->addSideMenuLink('4+ Bedroom', + array('controller' => 'unit_sizes', 'action' => 'bd4'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Auto', + array('controller' => 'unit_sizes', 'action' => 'auto'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Boat', + array('controller' => 'unit_sizes', 'action' => 'boat'), null, + 'CONTROLLER'); + $this->addSideMenuLink('RV', + array('controller' => 'unit_sizes', 'action' => 'rv'), null, + 'CONTROLLER'); + $this->addSideMenuLink('All', + array('controller' => 'unit_sizes', 'action' => 'all'), null, + 'CONTROLLER'); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: index / unavailable / vacant / occupied / all + * - Generate a listing of units + */ + + function index() { $this->all(); } + function bd1() { $this->gridView('Sizes for 1 Bedroom'); } + function bd2() { $this->gridView('Sizes for 2 Bedrooms'); } + function bd3() { $this->gridView('Sizes for 3 Bedroom'); } + function bd4() { $this->gridView('Sizes for 4+ Bedroom'); } + function auto() { $this->gridView('Sizes for an Automobile'); } + function boat() { $this->gridView('Sizes for a Boat'); } + function rv() { $this->gridView('Sizes for an RV'); } + function all() { $this->gridView('All Unit Sizes', 'all'); } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * virtuals: gridData + * - With the application controller handling the gridData action, + * these virtual functions ensure that the correct data is passed + * to jqGrid. + */ + + function gridDataCountTables(&$params, &$model) { + return array('link' => array('UnitType')); + } + + function gridDataTables(&$params, &$model) { + $tables = $this->gridDataCountTables($params, $model); + $tables['link']['Unit'] = array(); + return $tables; + } + + function gridDataFields(&$params, &$model) { + $fields = parent::gridDataFields($params, $model); + $fields[] = 'ROUND(UnitSize.width/12, 1) AS width'; + $fields[] = 'ROUND(UnitSize.depth/12, 1) AS depth'; + $fields[] = 'ROUND(UnitSize.height/12, 1) AS height'; + $fields[] = 'ROUND(UnitSize.width/12 * UnitSize.depth/12, 0) AS sqft'; + $fields[] = 'ROUND(UnitSize.width/12 * UnitSize.depth/12 * UnitSize.height/12, 0) AS cuft'; + $fields[] = 'ROUND(UnitSize.rent / (UnitSize.width/12 * UnitSize.depth/12), 2) AS sqcost'; + $fields[] = 'ROUND(UnitSize.rent / (UnitSize.width/12 * UnitSize.depth/12 * UnitSize.height/12), 2) AS cucost'; + + $fields[] = 'COUNT(Unit.id) AS units'; + $fields[] = 'SUM(IF(' . $this->UnitSize->Unit->conditionUnavailable() . ', 1, 0)) AS unavailable'; + $fields[] = 'SUM(IF(' . $this->UnitSize->Unit->conditionAvailable() . ', 1, 0)) AS available'; + $fields[] = 'SUM(IF(' . $this->UnitSize->Unit->conditionOccupied() . ', 1, 0)) AS occupied'; + $fields[] = 'SUM(IF(' . $this->UnitSize->Unit->conditionOccupied() . ', 0, 1)) / COUNT(unit.id) AS vacancy'; + $fields[] = 'SUM(IF(' . $this->UnitSize->Unit->conditionOccupied() . ', 1, 0)) / COUNT(unit.id) AS occupancy'; + + return $fields; + } + + function gridDataConditions(&$params, &$model) { + $conditions = parent::gridDataConditions($params, $model); + + // REVISIT : 20090825 + // Sizes should come from the database. + // For now, I took an assumed average need, then bracketed + // with +/- 50 sqft. This gives a 100sqft range for each. + if ($params['action'] === 'bd1') { // 75 sqft + $conditions[] = array('UnitType.id' => array_keys($this->UnitSize->UnitType->enclosedTypes())); + $conditions[] = '(UnitSize.width/12 * UnitSize.depth/12) <= 125'; + } + elseif ($params['action'] === 'bd2') { // 125 sqft + $conditions[] = array('UnitType.id' => array_keys($this->UnitSize->UnitType->enclosedTypes())); + $conditions[] = '(UnitSize.width/12 * UnitSize.depth/12) >= 75'; + $conditions[] = '(UnitSize.width/12 * UnitSize.depth/12) <= 175'; + } + elseif ($params['action'] === 'bd3') { // 175 sqft + $conditions[] = array('UnitType.id' => array_keys($this->UnitSize->UnitType->enclosedTypes())); + $conditions[] = '(UnitSize.width/12 * UnitSize.depth/12) >= 125'; + $conditions[] = '(UnitSize.width/12 * UnitSize.depth/12) <= 225'; + } + elseif ($params['action'] === 'bd4') { // 225 sqft + $conditions[] = array('UnitType.id' => array_keys($this->UnitSize->UnitType->enclosedTypes())); + $conditions[] = '(UnitSize.width/12 * UnitSize.depth/12) >= 175'; + } + elseif (in_array($params['action'], array('auto', 'boat', 'rv'))) { + $conditions[] = array('UnitType.id' => + array_merge(array_keys($this->UnitSize->UnitType->enclosedTypes()), + array_keys($this->UnitSize->UnitType->outdoorTypes()))); + list($width, $depth, $height) = array(8, 15, null); + if ($params['action'] === 'auto') + $depth = 15; + elseif ($params['action'] === 'boat') + $depth = 15; + elseif ($params['action'] === 'rv') + list($width, $depth, $height) = array(10, 25, 12); + + $conditions[] = "(UnitSize.width/12) >= $width"; + $conditions[] = "(UnitSize.depth/12) >= $depth"; + if (isset($height)) + $conditions[] = array('OR' => + array("(UnitSize.height/12) >= $height", + //"UnitSize.height IS NULL", + array('UnitType.id' => + array_keys($this->UnitSize->UnitType->outdoorTypes())), + )); + } + + return $conditions; + } + + function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { + $links['UnitSize'] = array('name'); + return parent::gridDataPostProcessLinks($params, $model, $records, $links); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: view + * - Displays information about a specific entry + */ + + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid Item.', true)); + $this->redirect(array('controller' => 'accounts', 'action'=>'index')); + } + + // Get the UnitSize and related fields + $this->UnitSize->id = $id; + $size = $this->UnitSize->find + ('first', array + ('contain' => array('UnitType'), + 'fields' => array('UnitSize.*', 'UnitType.*', + 'ROUND(UnitSize.width/12, 1) AS width', + 'ROUND(UnitSize.depth/12, 1) AS depth', + 'ROUND(UnitSize.height/12, 1) AS height', + 'ROUND(UnitSize.width/12 * UnitSize.depth/12, 0) AS sqft', + 'ROUND(UnitSize.width/12 * UnitSize.depth/12 * UnitSize.height/12, 0) AS cuft'), + )); + $size['UnitSize'] = $size[0] + $size['UnitSize']; + unset($size[0]); + + $this->set(compact('size')); + $this->set('stats', $this->UnitSize->stats($id)); + + // Prepare to render. + $title = "Unit Size : {$size['UnitSize']['name']}"; + $this->set(compact('title')); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: edit + * - Edit unit_size information + */ + + function edit($id = null) { + $this->INTERNAL_ERROR('NOT READY'); + if (isset($this->data)) { + // Check to see if the operation was cancelled. + if (isset($this->params['form']['cancel'])) { + if (empty($this->data['UnitSize']['id'])) + $this->redirect(array('action'=>'index')); + + $this->redirect(array('action'=>'view', $this->data['UnitSize']['id'])); + } + + // Make sure we have unit_size data + if (empty($this->data['UnitSize']) || empty($this->data['UnitSize']['id'])) + $this->redirect(array('action'=>'index')); + + // Save the unit_size and all associated data + $this->UnitSize->create(); + $this->UnitSize->id = $this->data['UnitSize']['id']; + if (!$this->UnitSize->save($this->data, false)) { + $this->Session->setFlash("UNIT_SIZE SAVE FAILED", true); + pr("UNIT_SIZE SAVE FAILED"); + } + + $this->redirect(array('action'=>'view', $this->UnitSize->id)); + } + + if ($id) { + $this->data = $this->UnitSize->findById($id); + } else { + $this->redirect(array('action'=>'index')); + } + + // Prepare to render. + $title = ('UnitSize ' . $this->data['UnitSize']['name'] . + " : Edit"); + $this->set(compact('title')); + } +} diff --git a/site/controllers/units_controller.php b/site/controllers/units_controller.php index 9fc9a03..1cc50f2 100644 --- a/site/controllers/units_controller.php +++ b/site/controllers/units_controller.php @@ -6,15 +6,34 @@ class UnitsController extends AppController { /************************************************************************** ************************************************************************** ************************************************************************** - * override: addDefaultSideMenuLinks - * - Adds controller specific default side menu links + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function addDefaultSideMenuLinks() { - parent::addDefaultSideMenuLinks(); + function addGridViewSideMenuLinks() { + parent::addGridViewSideMenuLinks(); + + $this->addSideMenuLink('Unavailable', + array('controller' => 'units', 'action' => 'unavailable'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Vacant', + array('controller' => 'units', 'action' => 'vacant'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Occupied', + array('controller' => 'units', 'action' => 'occupied'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Overlocked', + array('controller' => 'units', 'action' => 'locked'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Liened', + array('controller' => 'units', 'action' => 'liened'), null, + 'CONTROLLER'); + $this->addSideMenuLink('All', + array('controller' => 'units', 'action' => 'all'), null, + 'CONTROLLER'); } - + /************************************************************************** ************************************************************************** ************************************************************************** @@ -26,23 +45,10 @@ class UnitsController extends AppController { function unavailable() { $this->gridView('Unavailable Units'); } function vacant() { $this->gridView('Vacant Units'); } function occupied() { $this->gridView('Occupied Units'); } + function locked() { $this->gridView('Overlocked Units'); } + function liened() { $this->gridView('Liened Units'); } function all() { $this->gridView('All Units', 'all'); } - function gridView($title, $action = null, $element = null) { - $this->addSideMenuLink('Occupied', - array('controller' => 'units', 'action' => 'occupied'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Vacant', - array('controller' => 'units', 'action' => 'vacant'), null, - 'CONTROLLER'); - $this->addSideMenuLink('Unavailable', - array('controller' => 'units', 'action' => 'unavailable'), null, - 'CONTROLLER'); - $this->addSideMenuLink('All', - array('controller' => 'units', 'action' => 'all'), null, - 'CONTROLLER'); - parent::gridView($title, $action, $element); - } /************************************************************************** ************************************************************************** @@ -89,6 +95,7 @@ class UnitsController extends AppController { function gridDataFields(&$params, &$model) { $fields = parent::gridDataFields($params, $model); + $fields[] = 'ROUND(UnitSize.width/12 * UnitSize.depth/12, 0) AS sqft'; return array_merge($fields, $this->Unit->Lease->StatementEntry->chargeDisbursementFields(true)); } @@ -108,6 +115,12 @@ class UnitsController extends AppController { elseif ($params['action'] === 'unoccupied') { $conditions[] = array('NOT' => array($this->Unit->conditionOccupied())); } + elseif ($params['action'] === 'locked') { + $conditions[] = $this->Unit->conditionLocked(); + } + elseif ($params['action'] === 'liened') { + $conditions[] = $this->Unit->conditionLiened(); + } return $conditions; } @@ -147,7 +160,7 @@ class UnitsController extends AppController { $customer = array(); $unit = array(); - if (isset($id)) { + if (!empty($id)) { $this->Unit->recursive = -1; $unit = current($this->Unit->read(null, $id)); } @@ -197,6 +210,21 @@ class UnitsController extends AppController { } + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: lock/unlock + * - Transitions the unit into / out of the LOCKED state + */ + + function status($id, $status) { + $this->Unit->updateStatus($id, $status, true); + $this->redirect(array('action' => 'view', $id)); + } + function lock($id) { $this->status($id, 'LOCKED'); } + function unlock($id) { $this->status($id, 'OCCUPIED'); } + + /************************************************************************** ************************************************************************** ************************************************************************** @@ -240,13 +268,35 @@ class UnitsController extends AppController { $outstanding_deposit = $this->Unit->Lease->securityDepositBalance($unit['CurrentLease']['id']); } - // Set up dynamic menu items - $this->addSideMenuLink('Edit', - array('action' => 'edit', $id), null, - 'ACTION'); + // If the unit is occupied, but not locked, provide a + // mechanism to do so. This doesn't have to be restricted + // to past due customers. There are times we need to + // overlock customers in good standing, such as if their + // lock breaks, is cut, or missing for any reason. + if ($this->Unit->occupied($unit['Unit']['status']) && + !$this->Unit->locked($unit['Unit']['status'])) + $this->addSideMenuLink('Lock', + array('action' => 'Lock', $id), null, + 'ACTION'); - if (isset($unit['CurrentLease']['id']) && - !isset($unit['CurrentLease']['moveout_date'])) { + // If the unit is locked, provide an option to unlock it, + // unless it's locked due to lien, which is not so simple. + if ($this->Unit->locked($unit['Unit']['status']) && + !$this->Unit->liened($unit['Unit']['status'])) + $this->addSideMenuLink('Unlock', + array('action' => 'unlock', $id), null, + 'ACTION'); + + // If there is a current lease on this unit, then provide + // a link to move the tenant out. Current lease for a unit + // has a bit different definition than a current lease for + // a customer, since a lease stays with a customer until it + // is finally closed. A lease, however, only stays with a + // unit while occupied (since a unit is not responsible for + // any lingering financial obligations, like a customer is). + // Of course, if there is no current lease, provide a link + // to move a new tenant in (if the unit is available). + if (isset($unit['CurrentLease']['id'])) { $this->addSideMenuLink('Move-Out', array('action' => 'move_out', $id), null, 'ACTION'); @@ -258,8 +308,9 @@ class UnitsController extends AppController { // Unit is unavailable (dirty, damaged, reserved, business-use, etc) } - if (isset($unit['CurrentLease']['id']) && - !isset($unit['CurrentLease']['close_date'])) { + // If there is a current lease, allow new charges to + // be added, and payments to be made. + if (isset($unit['CurrentLease']['id'])) { $this->addSideMenuLink('New Invoice', array('controller' => 'leases', 'action' => 'invoice', @@ -272,6 +323,11 @@ class UnitsController extends AppController { 'ACTION'); } + // Always allow the unit to be edited. + $this->addSideMenuLink('Edit', + array('action' => 'edit', $id), null, + 'ACTION'); + // Prepare to render. $title = 'Unit ' . $unit['Unit']['name']; $this->set(compact('unit', 'title', @@ -335,7 +391,6 @@ class UnitsController extends AppController { $this->set(compact('unit_sizes')); // Prepare to render. - pr($this->data); $this->set(compact('title')); } diff --git a/site/models/account.php b/site/models/account.php index 36a9d2b..1033fbd 100644 --- a/site/models/account.php +++ b/site/models/account.php @@ -188,8 +188,7 @@ class Account extends AppModel { function relatedAccounts($attribute, $extra = null) { $this->cacheQueries = true; $accounts = $this->find('all', array - ('contain' => array('CurrentLedger'), - 'fields' => array('Account.id', 'Account.type', 'Account.name', 'CurrentLedger.id'), + ('fields' => array('Account.id', 'Account.name'), 'conditions' => array('Account.'.$attribute => true), 'order' => array('Account.name'), ) + (isset($extra) ? $extra : array()) @@ -213,21 +212,10 @@ class Account extends AppModel { * - Returns an array of accounts suitable for activity xxx */ - function invoiceAccounts() { - return $this->relatedAccounts('invoices', array('order' => 'name')); - } - - function receiptAccounts() { - return $this->relatedAccounts('receipts', array('order' => 'name')); - } - - function depositAccounts() { - return $this->relatedAccounts('deposits', array('order' => 'name')); - } - - function refundAccounts() { - return $this->relatedAccounts('refunds', array('order' => 'name')); - } + function invoiceAccounts() { return $this->relatedAccounts('invoices'); } + function receiptAccounts() { return $this->relatedAccounts('receipts'); } + function depositAccounts() { return $this->relatedAccounts('deposits'); } + function refundAccounts() { return $this->relatedAccounts('refunds'); } /************************************************************************** diff --git a/site/models/contact.php b/site/models/contact.php index b691823..43ad9e0 100644 --- a/site/models/contact.php +++ b/site/models/contact.php @@ -41,14 +41,15 @@ class Contact extends AppModel { function saveContact($id, $data) { // Establish a display name if not already given - if (!$data['Contact']['display_name']) + if (!$data['Contact']['display_name'] && + $data['Contact']['first_name'] && $data['Contact']['last_name']) $data['Contact']['display_name'] = - (($data['Contact']['first_name'] && - $data['Contact']['last_name']) - ? $data['Contact']['last_name'] . ', ' . $data['Contact']['first_name'] - : ($data['Contact']['first_name'] - ? $data['Contact']['first_name'] - : $data['Contact']['last_name'])); + $data['Contact']['last_name'] . ', ' . $data['Contact']['first_name']; + + foreach (array('last_name', 'first_name', 'company_name') AS $fld) { + if (!$data['Contact']['display_name'] && $data['Contact'][$fld]) + $data['Contact']['display_name'] = $data['Contact'][$fld]; + } // Save the contact data $this->create(); diff --git a/site/models/customer.php b/site/models/customer.php index 3df1ebb..22a1055 100644 --- a/site/models/customer.php +++ b/site/models/customer.php @@ -54,17 +54,19 @@ class Customer extends AppModel { * function: leaseIds * - Returns the lease IDs for the given customer */ - function leaseIds($id) { + function leaseIds($id, $current = false) { + $Lease = $current ? 'CurrentLease' : 'Lease'; + $this->cacheQueries = true; $customer = $this->find('first', array('contain' => - array('Lease' => array('fields' => array('id'))), + array($Lease => array('fields' => array('id'))), 'fields' => array(), 'conditions' => array(array('Customer.id' => $id)))); $this->cacheQueries = false; $ids = array(); - foreach ($customer['Lease'] AS $lease) + foreach ($customer[$Lease] AS $lease) $ids[] = $lease['id']; return $ids; diff --git a/site/models/unit.php b/site/models/unit.php index 602460a..53c9f85 100644 --- a/site/models/unit.php +++ b/site/models/unit.php @@ -87,6 +87,23 @@ class Unit extends AppModel { return $this->prReturn(true); } + function locked($enum) { + return $this->statusCheck($enum, 'LOCKED', false, null, false); + } + + function conditionLocked() { + //return array('Unit.status' => 'LOCKED'); + return ('Unit.status >= ' . $this->statusValue('LOCKED')); + } + + function liened($enum) { + return $this->statusCheck($enum, 'LIENED', false, null, false); + } + + function conditionLiened() { + return ('Unit.status >= ' . $this->statusValue('LIENED')); + } + function occupied($enum) { return $this->statusCheck($enum, 'OCCUPIED', false, null, false); } @@ -115,6 +132,7 @@ class Unit extends AppModel { } function available($enum) { return $this->vacant($enum); } + function conditionAvailable() { return $this->conditionVacant($enum); } /************************************************************************** diff --git a/site/models/unit_size.php b/site/models/unit_size.php index ca06b60..ccc57af 100644 --- a/site/models/unit_size.php +++ b/site/models/unit_size.php @@ -1,25 +1,64 @@ array('numeric'), - 'unit_type_id' => array('numeric'), - 'code' => array('notempty'), - 'name' => array('notempty'), - 'width' => array('numeric'), - 'depth' => array('numeric'), - 'deposit' => array('money'), - 'amount' => array('money') - ); + var $belongsTo = + array( + 'UnitType', + ); - var $belongsTo = array( - 'UnitType', - ); + var $hasMany = + array( + 'Unit', + ); - var $hasMany = array( - 'Unit', - ); + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: stats + * - Returns summary data from the requested unit size. + */ + + function stats($id = null) { + $this->prEnter(compact('id')); + + // Right now, we only work with id not null + if (!$id) + return null; + + $stats = array(); + + // Get the total number of units this size + $stats['all'] = + $this->find('count', + array('link' => array('Unit'), + 'conditions' => array(array('UnitSize.id' => $id)), + )); + + // Get numbers for units in the various states + foreach (array('unavailable', 'vacant', 'occupied', 'locked', 'liened') AS $status) { + $statusfunc = 'condition' . ucfirst($status); + $stats[$status] = + $this->find('count', + array('link' => array('Unit'), + 'conditions' => array(array('UnitSize.id' => $id), + $this->Unit->{$statusfunc}()), + )); + } + + // Count up each unit by physical status + foreach + ($this->find('all', + array('link' => array('Unit' => array('fields' => array())), + 'fields' => array('Unit.status', 'COUNT(Unit.id) AS total'), + 'conditions' => array(array('UnitSize.id' => $id)), + 'group' => 'Unit.status', + )) AS $status) { + $stats['status'][$status['Unit']['status']] = $status[0]['total']; + } + + // Return the collection + return $this->prReturn($stats); + } } -?> \ No newline at end of file diff --git a/site/models/unit_type.php b/site/models/unit_type.php index d2bd90d..50d27b3 100644 --- a/site/models/unit_type.php +++ b/site/models/unit_type.php @@ -1,16 +1,50 @@ array('numeric'), - 'code' => array('notempty'), - 'name' => array('notempty') - ); + var $hasMany = + array( + 'UnitSize', + ); - var $hasMany = array( - 'UnitSize', - ); + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: relatedTypes + * - Returns an array of types related by similar attributes + */ + + function relatedTypes($attribute, $extra = null) { + $this->cacheQueries = true; + $types = $this->find('all', array + ('fields' => array('UnitType.id', 'UnitType.name'), + 'conditions' => array('UnitType.'.$attribute => true), + 'order' => array('UnitType.name'), + ) + (isset($extra) ? $extra : array()) + ); + $this->cacheQueries = false; + + // Rearrange to be of the form (id => name) + $rel_types = array(); + foreach ($types AS $type) { + $rel_types[$type['UnitType']['id']] = $type['UnitType']['name']; + } + + return $rel_types; + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: xxxTypes + * - Returns an array of types suitable for activity xxx + */ + + function residentialTypes() { return $this->relatedTypes('residential'); } + function enclosedTypes() { return $this->relatedTypes('enclosed'); } + function climateTypes() { return $this->relatedTypes('climate'); } + function outdoorTypes() { return $this->relatedTypes('outdoor'); } + function coveredTypes() { return $this->relatedTypes('covered'); } } -?> \ No newline at end of file diff --git a/site/views/accounts/view.ctp b/site/views/accounts/view.ctp index 6ced628..ddf1e61 100644 --- a/site/views/accounts/view.ctp +++ b/site/views/accounts/view.ctp @@ -82,6 +82,7 @@ echo $this->element('ledger_entries', array 'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance', empty($account['receipts']) ? 'Tender' : null), 'include' => array('Debit', 'Credit', 'Sub-Total'), + 'limit' => 50, ))); @@ -100,6 +101,7 @@ echo $this->element('ledger_entries', array 'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance', empty($account['receipts']) ? 'Tender' : null), 'include' => array('Debit', 'Credit', 'Sub-Total'), + 'limit' => 50, ))); diff --git a/site/views/contacts/edit.ctp b/site/views/contacts/edit.ctp index 163af2f..8ba1941 100644 --- a/site/views/contacts/edit.ctp +++ b/site/views/contacts/edit.ctp @@ -45,6 +45,7 @@ function contactMethodDiv($obj, $type, $legend, $values = null) { ' CLASS="'.$type.'-method-%{id}-source" ' . "\n" . ' ID="'.$type.'-method-%{id}-source-'.$stype.'"' . "\n" . ' VALUE="'.$stype.'"' . "\n" . + ($stype == 'new' ? ' CHECKED' . "\n" : '') . ' />' . "\n" . ' ' . "\n" . ' '; @@ -76,21 +77,30 @@ function contactMethodDiv($obj, $type, $legend, $values = null) { 'fields' => array ( 'preference' => array - ('opts' => array + ('label_attributes' => array('class' => 'required'), + 'opts' => array ('options' => $obj->varstore['methodPreferences'], 'selected' => (isset($values) ? $values['ContactsMethod']['preference'] : null), - )), + ), + 'after' => "Intended purpose for this method of communication.", + ), 'type' => array - ('opts' => array + ('label_attributes' => array('class' => 'required'), + 'opts' => array ('options' => $obj->varstore['methodTypes'], 'selected' => (isset($values) ? $values['ContactsMethod']['type'] : null), - )), + ), + 'after' => "How / Where this communication reaches the contact.", + ), 'comment' => array - ('opts' => array + ('label_attributes' => array('class' => 'optional empty'), + 'opts' => array ('value' => (isset($values) ? $values['ContactsMethod']['comment'] : null), - )), + ), + 'after' => "Optional: Comments on how this form of communication relates to the contact.", + ), ))) . "\n" . @@ -113,16 +123,23 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) { if ($type === 'phone') { if ($stype === 'existing') { $fields = array - ('id' => array('name' => 'Phone/Ext', + ('id' => array('label_attributes' => array('class' => 'required empty'), + 'name' => 'Phone/Ext', 'opts' => array('options' => $obj->varstore['contactPhones'])), ); } elseif ($stype === 'new') { $fields = array - ('type' => array('opts' => array('options' => $obj->varstore['phoneTypes'])), - 'phone' => true, - 'ext' => array('name' => "Extension"), - 'comment' => true, + ('type' => array('label_attributes' => array('class' => 'required'), + 'opts' => array('options' => $obj->varstore['phoneTypes']), + 'after' => "Physical type of the phone."), + 'phone' => array('label_attributes' => array('class' => 'required empty'), + 'after' => "Required: Phone number."), + 'ext' => array('name' => "Extension", + 'label_attributes' => array('class' => 'optional empty'), + 'after' => "Optional: Extension number."), + 'comment' => array('label_attributes' => array('class' => 'optional empty'), + 'after' => "Optional: Comments about this phone number."), ); } elseif ($stype === 'show') { @@ -149,12 +166,19 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) { } elseif ($stype === 'new') { $fields = array - ('address' => true, - 'city' => true, - 'state' => true, - 'postcode' => array('name' => 'Zip Code'), - 'country' => true, - 'comment' => true, + ('address' => array('label_attributes' => array('class' => 'required empty'), + 'after' => "Required: First line of mailing address."), + 'city' => array('label_attributes' => array('class' => 'required empty'), + 'after' => "Required."), + 'state' => array('label_attributes' => array('class' => 'required empty'), + 'after' => "Required."), + 'postcode' => array('name' => 'Zip Code', + 'label_attributes' => array('class' => 'required empty'), + 'after' => "Required."), + 'country' => array('label_attributes' => array('class' => 'optional empty'), + 'after' => "Optional: USA is presumed."), + 'comment' => array('label_attributes' => array('class' => 'optional empty'), + 'after' => "Optional: Comments about this mailing address."), ); } elseif ($stype === 'show') { @@ -177,13 +201,16 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) { if ($stype === 'existing') { $fields = array ('id' => array('name' => 'Email', + 'label_attributes' => array('class' => 'required'), 'opts' => array('options' => $obj->varstore['contactEmails'])), ); } elseif ($stype === 'new') { $fields = array - ('email' => true, - 'comment' => true, + ('email' => array('label_attributes' => array('class' => 'required empty'), + 'after' => "Required: E-mail address."), + 'comment' => array('label_attributes' => array('class' => 'optional empty'), + 'after' => "Optional: Comments about this email address."), ); } elseif ($stype === 'show') { @@ -204,7 +231,7 @@ function contactMethodTypeDiv($obj, $type, $stype, $values = null) { '