diff --git a/build.cmd b/build.cmd index 8967c4e..5e84573 100644 --- a/build.cmd +++ b/build.cmd @@ -1,3 +1,3 @@ @echo off -%~dp0\scripts\sitelink2pmgr.pl %~dp0\db\schema.sql %~dp0db\vss.mdb %* +mysql --user=pmgr --password=pmgruser < %~dp0\db\property_manager.sql echo Done! diff --git a/db/property_manager.sql b/db/property_manager.sql index 4292874..dd04d7d 100644 --- a/db/property_manager.sql +++ b/db/property_manager.sql @@ -230,7 +230,7 @@ CREATE TABLE `pmgr_contact_addresses` ( `country` varchar(128) DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=46 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=47 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -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); @@ -284,6 +282,7 @@ INSERT INTO `pmgr_contact_addresses` VALUES (42,'2272 Shoshone','Boise','ID','83 INSERT INTO `pmgr_contact_addresses` VALUES (43,'PO Box 626','Chewelah','WA','99109','USA',NULL); INSERT INTO `pmgr_contact_addresses` VALUES (44,'4565 Hwy 231','Springdale','WA','99173','USA',NULL); INSERT INTO `pmgr_contact_addresses` VALUES (45,'3463 B Hwy 395 South','Loon Lake','WA','99148','USA',NULL); +INSERT INTO `pmgr_contact_addresses` VALUES (46,'PO Box 51','Valley','WA','99181',NULL,NULL); /*!40000 ALTER TABLE `pmgr_contact_addresses` ENABLE KEYS */; UNLOCK TABLES; @@ -309,9 +308,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 +335,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,14 +412,14 @@ 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, `id_local_exp` date DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=79 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=82 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -437,7 +428,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 +442,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 +480,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); @@ -515,6 +505,9 @@ INSERT INTO `pmgr_contacts` VALUES (75,'Sharilyn',NULL,'Small-Trott',NULL,'Small INSERT INTO `pmgr_contacts` VALUES (76,'Tasha',NULL,'Gulack',NULL,'Gulack, Tasha',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (77,'Angela',NULL,'Selle-Jackson',NULL,'Selle-Jackson, Angela',NULL,NULL,NULL,NULL,NULL); INSERT INTO `pmgr_contacts` VALUES (78,'Mark',NULL,'Selle',NULL,'Selle, Mark',NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_contacts` VALUES (79,'Eric',NULL,'Price',NULL,'Price, Eric',NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_contacts` VALUES (80,'Kim',NULL,'Gleisner',NULL,'Gleisner, Kim',NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_contacts` VALUES (81,'Mike',NULL,'Judd',NULL,'Judd, Mike',NULL,NULL,NULL,NULL,NULL); /*!40000 ALTER TABLE `pmgr_contacts` ENABLE KEYS */; UNLOCK TABLES; @@ -618,6 +611,9 @@ INSERT INTO `pmgr_contacts_customers` VALUES (75,59,'TENANT',1,NULL); INSERT INTO `pmgr_contacts_customers` VALUES (76,60,'TENANT',1,NULL); INSERT INTO `pmgr_contacts_customers` VALUES (77,61,'TENANT',1,NULL); INSERT INTO `pmgr_contacts_customers` VALUES (78,61,'TENANT',1,'Husband'); +INSERT INTO `pmgr_contacts_customers` VALUES (79,62,'TENANT',1,NULL); +INSERT INTO `pmgr_contacts_customers` VALUES (80,63,'TENANT',1,NULL); +INSERT INTO `pmgr_contacts_customers` VALUES (81,64,'TENANT',1,NULL); /*!40000 ALTER TABLE `pmgr_contacts_customers` ENABLE KEYS */; UNLOCK TABLES; @@ -633,7 +629,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 +641,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); @@ -759,6 +745,7 @@ INSERT INTO `pmgr_contacts_methods` VALUES (65,'PHONE',63,'MAIN','PRIMARY',NULL) INSERT INTO `pmgr_contacts_methods` VALUES (66,'PHONE',64,'MAIN','PRIMARY',NULL); INSERT INTO `pmgr_contacts_methods` VALUES (77,'PHONE',65,'MAIN','PRIMARY',NULL); INSERT INTO `pmgr_contacts_methods` VALUES (76,'PHONE',66,'MAIN','PRIMARY',NULL); +INSERT INTO `pmgr_contacts_methods` VALUES (60,'ADDRESS',46,'MAIN','PRIMARY',NULL); /*!40000 ALTER TABLE `pmgr_contacts_methods` ENABLE KEYS */; UNLOCK TABLES; @@ -778,7 +765,7 @@ CREATE TABLE `pmgr_customers` ( `past_lease_count` smallint(5) unsigned NOT NULL DEFAULT '0', `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=62 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=65 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -823,14 +810,14 @@ INSERT INTO `pmgr_customers` VALUES (33,'Laird, Heather',45,1,1,0,NULL); INSERT INTO `pmgr_customers` VALUES (34,'Harris, Monte',47,1,1,0,NULL); INSERT INTO `pmgr_customers` VALUES (35,'De Lauri, Jane',49,2,2,0,NULL); INSERT INTO `pmgr_customers` VALUES (36,'McMahon, Vivian',50,1,1,0,NULL); -INSERT INTO `pmgr_customers` VALUES (37,'Linhoff, Ron',52,4,3,1,NULL); -INSERT INTO `pmgr_customers` VALUES (38,'Hatcher, Ed',53,1,1,0,NULL); +INSERT INTO `pmgr_customers` VALUES (37,'Linhoff, Ron',52,4,2,2,NULL); +INSERT INTO `pmgr_customers` VALUES (38,'Hatcher, Ed',53,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (39,'Valley Bible Church',54,3,0,3,NULL); -INSERT INTO `pmgr_customers` VALUES (40,'Hovland, Pamela',55,1,1,0,NULL); +INSERT INTO `pmgr_customers` VALUES (40,'Hovland, Pamela',55,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (41,'Hooke, R.R.',57,1,1,0,NULL); INSERT INTO `pmgr_customers` VALUES (42,'Clark, Bill',58,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (43,'Jackson, Shirley',59,1,0,1,NULL); -INSERT INTO `pmgr_customers` VALUES (44,'Conway, Cathy',60,1,1,0,NULL); +INSERT INTO `pmgr_customers` VALUES (44,'Conway, Cathy',60,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (45,'Walch, John',61,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (46,'Johnson, Joni',62,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (47,'Mancini, Krystan',63,1,1,0,NULL); @@ -848,9 +835,63 @@ INSERT INTO `pmgr_customers` VALUES (58,'Goble, Matt',74,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (59,'Small-Trott, Sharilyn',75,1,0,1,NULL); INSERT INTO `pmgr_customers` VALUES (60,'Gulack, Tasha',76,1,1,0,NULL); INSERT INTO `pmgr_customers` VALUES (61,'Selle-Jackson, Angela',77,1,1,0,NULL); +INSERT INTO `pmgr_customers` VALUES (62,'Price, Eric',79,1,1,0,NULL); +INSERT INTO `pmgr_customers` VALUES (63,'Gleisner, Kim',80,1,1,0,NULL); +INSERT INTO `pmgr_customers` VALUES (64,'Judd, Mike',81,1,1,0,NULL); /*!40000 ALTER TABLE `pmgr_customers` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `pmgr_default_options` +-- + +DROP TABLE IF EXISTS `pmgr_default_options`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_default_options` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `option_value_id` int(10) unsigned NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_default_options` +-- + +LOCK TABLES `pmgr_default_options` WRITE; +/*!40000 ALTER TABLE `pmgr_default_options` DISABLE KEYS */; +INSERT INTO `pmgr_default_options` VALUES (1,1,NULL); +INSERT INTO `pmgr_default_options` VALUES (2,3,NULL); +/*!40000 ALTER TABLE `pmgr_default_options` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pmgr_default_permissions` +-- + +DROP TABLE IF EXISTS `pmgr_default_permissions`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_default_permissions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `permission_value_id` int(10) unsigned NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_default_permissions` +-- + +LOCK TABLES `pmgr_default_permissions` WRITE; +/*!40000 ALTER TABLE `pmgr_default_permissions` DISABLE KEYS */; +INSERT INTO `pmgr_default_permissions` VALUES (1,1,NULL); +/*!40000 ALTER TABLE `pmgr_default_permissions` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `pmgr_deposits` -- @@ -892,7 +933,7 @@ CREATE TABLE `pmgr_double_entries` ( `credit_entry_id` int(10) unsigned NOT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=761 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=877 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -1605,7 +1646,7 @@ INSERT INTO `pmgr_double_entries` VALUES (731,1462,1461,NULL); INSERT INTO `pmgr_double_entries` VALUES (732,1463,1464,NULL); INSERT INTO `pmgr_double_entries` VALUES (733,1465,1466,NULL); INSERT INTO `pmgr_double_entries` VALUES (734,1468,1467,NULL); -INSERT INTO `pmgr_double_entries` VALUES (736,1471,1472,NULL); +INSERT INTO `pmgr_double_entries` VALUES (765,1529,1530,NULL); INSERT INTO `pmgr_double_entries` VALUES (737,1473,1474,NULL); INSERT INTO `pmgr_double_entries` VALUES (738,1476,1475,NULL); INSERT INTO `pmgr_double_entries` VALUES (739,1478,1477,NULL); @@ -1629,6 +1670,118 @@ INSERT INTO `pmgr_double_entries` VALUES (756,1511,1512,NULL); INSERT INTO `pmgr_double_entries` VALUES (757,1514,1513,NULL); INSERT INTO `pmgr_double_entries` VALUES (758,1515,1516,NULL); INSERT INTO `pmgr_double_entries` VALUES (759,1518,1517,NULL); +INSERT INTO `pmgr_double_entries` VALUES (761,1521,1522,NULL); +INSERT INTO `pmgr_double_entries` VALUES (762,1524,1523,NULL); +INSERT INTO `pmgr_double_entries` VALUES (763,1526,1525,NULL); +INSERT INTO `pmgr_double_entries` VALUES (764,1527,1528,NULL); +INSERT INTO `pmgr_double_entries` VALUES (766,1532,1531,NULL); +INSERT INTO `pmgr_double_entries` VALUES (767,1533,1534,NULL); +INSERT INTO `pmgr_double_entries` VALUES (768,1535,1536,NULL); +INSERT INTO `pmgr_double_entries` VALUES (769,1538,1537,NULL); +INSERT INTO `pmgr_double_entries` VALUES (770,1539,1540,NULL); +INSERT INTO `pmgr_double_entries` VALUES (771,1542,1541,NULL); +INSERT INTO `pmgr_double_entries` VALUES (772,1543,1544,NULL); +INSERT INTO `pmgr_double_entries` VALUES (773,1546,1545,NULL); +INSERT INTO `pmgr_double_entries` VALUES (774,1547,1548,NULL); +INSERT INTO `pmgr_double_entries` VALUES (775,1550,1549,NULL); +INSERT INTO `pmgr_double_entries` VALUES (776,1552,1551,NULL); +INSERT INTO `pmgr_double_entries` VALUES (777,1554,1553,NULL); +INSERT INTO `pmgr_double_entries` VALUES (778,1555,1556,NULL); +INSERT INTO `pmgr_double_entries` VALUES (779,1557,1558,NULL); +INSERT INTO `pmgr_double_entries` VALUES (780,1560,1559,NULL); +INSERT INTO `pmgr_double_entries` VALUES (781,1562,1561,NULL); +INSERT INTO `pmgr_double_entries` VALUES (782,1563,1564,NULL); +INSERT INTO `pmgr_double_entries` VALUES (783,1566,1565,NULL); +INSERT INTO `pmgr_double_entries` VALUES (784,1568,1567,NULL); +INSERT INTO `pmgr_double_entries` VALUES (785,1570,1569,NULL); +INSERT INTO `pmgr_double_entries` VALUES (786,1572,1571,NULL); +INSERT INTO `pmgr_double_entries` VALUES (787,1574,1573,NULL); +INSERT INTO `pmgr_double_entries` VALUES (788,1575,1576,NULL); +INSERT INTO `pmgr_double_entries` VALUES (789,1578,1577,NULL); +INSERT INTO `pmgr_double_entries` VALUES (790,1579,1580,NULL); +INSERT INTO `pmgr_double_entries` VALUES (791,1582,1581,NULL); +INSERT INTO `pmgr_double_entries` VALUES (792,1584,1583,NULL); +INSERT INTO `pmgr_double_entries` VALUES (793,1586,1585,NULL); +INSERT INTO `pmgr_double_entries` VALUES (794,1588,1587,NULL); +INSERT INTO `pmgr_double_entries` VALUES (795,1590,1589,NULL); +INSERT INTO `pmgr_double_entries` VALUES (796,1592,1591,NULL); +INSERT INTO `pmgr_double_entries` VALUES (797,1594,1593,NULL); +INSERT INTO `pmgr_double_entries` VALUES (798,1596,1595,NULL); +INSERT INTO `pmgr_double_entries` VALUES (799,1598,1597,NULL); +INSERT INTO `pmgr_double_entries` VALUES (800,1600,1599,NULL); +INSERT INTO `pmgr_double_entries` VALUES (801,1602,1601,NULL); +INSERT INTO `pmgr_double_entries` VALUES (802,1604,1603,NULL); +INSERT INTO `pmgr_double_entries` VALUES (803,1606,1605,NULL); +INSERT INTO `pmgr_double_entries` VALUES (804,1608,1607,NULL); +INSERT INTO `pmgr_double_entries` VALUES (805,1610,1609,NULL); +INSERT INTO `pmgr_double_entries` VALUES (806,1612,1611,NULL); +INSERT INTO `pmgr_double_entries` VALUES (807,1614,1613,NULL); +INSERT INTO `pmgr_double_entries` VALUES (808,1616,1615,NULL); +INSERT INTO `pmgr_double_entries` VALUES (809,1617,1618,NULL); +INSERT INTO `pmgr_double_entries` VALUES (810,1620,1619,NULL); +INSERT INTO `pmgr_double_entries` VALUES (811,1622,1621,NULL); +INSERT INTO `pmgr_double_entries` VALUES (812,1624,1623,NULL); +INSERT INTO `pmgr_double_entries` VALUES (813,1626,1625,NULL); +INSERT INTO `pmgr_double_entries` VALUES (814,1628,1627,NULL); +INSERT INTO `pmgr_double_entries` VALUES (815,1630,1629,NULL); +INSERT INTO `pmgr_double_entries` VALUES (816,1632,1631,NULL); +INSERT INTO `pmgr_double_entries` VALUES (817,1634,1633,NULL); +INSERT INTO `pmgr_double_entries` VALUES (856,1711,1712,NULL); +INSERT INTO `pmgr_double_entries` VALUES (819,1638,1637,NULL); +INSERT INTO `pmgr_double_entries` VALUES (820,1639,1640,NULL); +INSERT INTO `pmgr_double_entries` VALUES (821,1642,1641,NULL); +INSERT INTO `pmgr_double_entries` VALUES (822,1644,1643,NULL); +INSERT INTO `pmgr_double_entries` VALUES (823,1645,1646,NULL); +INSERT INTO `pmgr_double_entries` VALUES (824,1648,1647,NULL); +INSERT INTO `pmgr_double_entries` VALUES (825,1649,1650,NULL); +INSERT INTO `pmgr_double_entries` VALUES (826,1652,1651,NULL); +INSERT INTO `pmgr_double_entries` VALUES (827,1654,1653,NULL); +INSERT INTO `pmgr_double_entries` VALUES (828,1656,1655,NULL); +INSERT INTO `pmgr_double_entries` VALUES (829,1658,1657,NULL); +INSERT INTO `pmgr_double_entries` VALUES (830,1660,1659,NULL); +INSERT INTO `pmgr_double_entries` VALUES (831,1662,1661,NULL); +INSERT INTO `pmgr_double_entries` VALUES (832,1664,1663,NULL); +INSERT INTO `pmgr_double_entries` VALUES (833,1665,1666,NULL); +INSERT INTO `pmgr_double_entries` VALUES (834,1667,1668,NULL); +INSERT INTO `pmgr_double_entries` VALUES (835,1669,1670,NULL); +INSERT INTO `pmgr_double_entries` VALUES (836,1671,1672,NULL); +INSERT INTO `pmgr_double_entries` VALUES (837,1674,1673,NULL); +INSERT INTO `pmgr_double_entries` VALUES (838,1676,1675,NULL); +INSERT INTO `pmgr_double_entries` VALUES (839,1677,1678,NULL); +INSERT INTO `pmgr_double_entries` VALUES (840,1679,1680,NULL); +INSERT INTO `pmgr_double_entries` VALUES (841,1681,1682,NULL); +INSERT INTO `pmgr_double_entries` VALUES (842,1683,1684,NULL); +INSERT INTO `pmgr_double_entries` VALUES (843,1685,1686,NULL); +INSERT INTO `pmgr_double_entries` VALUES (844,1687,1688,NULL); +INSERT INTO `pmgr_double_entries` VALUES (845,1689,1690,NULL); +INSERT INTO `pmgr_double_entries` VALUES (846,1691,1692,NULL); +INSERT INTO `pmgr_double_entries` VALUES (847,1693,1694,NULL); +INSERT INTO `pmgr_double_entries` VALUES (848,1695,1696,NULL); +INSERT INTO `pmgr_double_entries` VALUES (849,1697,1698,NULL); +INSERT INTO `pmgr_double_entries` VALUES (850,1699,1700,NULL); +INSERT INTO `pmgr_double_entries` VALUES (851,1701,1702,NULL); +INSERT INTO `pmgr_double_entries` VALUES (852,1703,1704,NULL); +INSERT INTO `pmgr_double_entries` VALUES (853,1705,1706,NULL); +INSERT INTO `pmgr_double_entries` VALUES (854,1707,1708,NULL); +INSERT INTO `pmgr_double_entries` VALUES (855,1709,1710,NULL); +INSERT INTO `pmgr_double_entries` VALUES (857,1713,1714,NULL); +INSERT INTO `pmgr_double_entries` VALUES (858,1716,1715,NULL); +INSERT INTO `pmgr_double_entries` VALUES (859,1717,1718,NULL); +INSERT INTO `pmgr_double_entries` VALUES (860,1720,1719,NULL); +INSERT INTO `pmgr_double_entries` VALUES (861,1721,1722,NULL); +INSERT INTO `pmgr_double_entries` VALUES (862,1724,1723,NULL); +INSERT INTO `pmgr_double_entries` VALUES (863,1726,1725,NULL); +INSERT INTO `pmgr_double_entries` VALUES (864,1728,1727,NULL); +INSERT INTO `pmgr_double_entries` VALUES (876,1751,1752,NULL); +INSERT INTO `pmgr_double_entries` VALUES (866,1732,1731,NULL); +INSERT INTO `pmgr_double_entries` VALUES (867,1734,1733,NULL); +INSERT INTO `pmgr_double_entries` VALUES (869,1738,1737,NULL); +INSERT INTO `pmgr_double_entries` VALUES (870,1740,1739,NULL); +INSERT INTO `pmgr_double_entries` VALUES (871,1742,1741,NULL); +INSERT INTO `pmgr_double_entries` VALUES (872,1744,1743,NULL); +INSERT INTO `pmgr_double_entries` VALUES (873,1746,1745,NULL); +INSERT INTO `pmgr_double_entries` VALUES (874,1747,1748,NULL); +INSERT INTO `pmgr_double_entries` VALUES (875,1749,1750,NULL); /*!40000 ALTER TABLE `pmgr_double_entries` ENABLE KEYS */; UNLOCK TABLES; @@ -1640,12 +1793,13 @@ DROP TABLE IF EXISTS `pmgr_group_options`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `pmgr_group_options` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `group_id` int(10) unsigned NOT NULL, - `name` varchar(50) NOT NULL, - `value` varchar(255) NOT NULL, + `option_value_id` int(10) unsigned NOT NULL, `comment` varchar(255) DEFAULT NULL, - PRIMARY KEY (`group_id`,`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; + PRIMARY KEY (`id`), + KEY `group_key` (`group_id`) +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -1654,6 +1808,8 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_group_options` WRITE; /*!40000 ALTER TABLE `pmgr_group_options` DISABLE KEYS */; +INSERT INTO `pmgr_group_options` VALUES (1,1,2,NULL); +INSERT INTO `pmgr_group_options` VALUES (2,2,4,NULL); /*!40000 ALTER TABLE `pmgr_group_options` ENABLE KEYS */; UNLOCK TABLES; @@ -1665,12 +1821,13 @@ DROP TABLE IF EXISTS `pmgr_group_permissions`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `pmgr_group_permissions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `group_id` int(10) unsigned NOT NULL, - `name` char(30) NOT NULL, - `access` enum('ALLOWED','DENIED','FORCED') NOT NULL DEFAULT 'ALLOWED', + `permission_value_id` int(10) unsigned NOT NULL, `comment` varchar(255) DEFAULT NULL, - PRIMARY KEY (`group_id`,`name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; + PRIMARY KEY (`id`), + KEY `group_key` (`group_id`) +) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -1679,7 +1836,9 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_group_permissions` WRITE; /*!40000 ALTER TABLE `pmgr_group_permissions` DISABLE KEYS */; -INSERT INTO `pmgr_group_permissions` VALUES (1,'EVERYTHING','FORCED',NULL); +INSERT INTO `pmgr_group_permissions` VALUES (1,1,4,NULL); +INSERT INTO `pmgr_group_permissions` VALUES (2,2,4,NULL); +INSERT INTO `pmgr_group_permissions` VALUES (3,3,3,NULL); /*!40000 ALTER TABLE `pmgr_group_permissions` ENABLE KEYS */; UNLOCK TABLES; @@ -1694,9 +1853,10 @@ CREATE TABLE `pmgr_groups` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(12) NOT NULL, `name` varchar(80) NOT NULL, + `rank` smallint(5) unsigned NOT NULL DEFAULT '100', `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -1705,7 +1865,11 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_groups` WRITE; /*!40000 ALTER TABLE `pmgr_groups` DISABLE KEYS */; -INSERT INTO `pmgr_groups` VALUES (1,'Owner','Owner Group',NULL); +INSERT INTO `pmgr_groups` VALUES (1,'Developer','Software Development Group',1,NULL); +INSERT INTO `pmgr_groups` VALUES (2,'Owner','Owner Group',25,NULL); +INSERT INTO `pmgr_groups` VALUES (3,'Admin','Administrator Group',50,NULL); +INSERT INTO `pmgr_groups` VALUES (4,'Manager','Manager Group',75,NULL); +INSERT INTO `pmgr_groups` VALUES (5,'Temp','Temporary Manager',100,NULL); /*!40000 ALTER TABLE `pmgr_groups` ENABLE KEYS */; UNLOCK TABLES; @@ -1790,7 +1954,7 @@ CREATE TABLE `pmgr_leases` ( `next_rent_date` date DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=73 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=76 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -1799,78 +1963,81 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_leases` WRITE; /*!40000 ALTER TABLE `pmgr_leases` DISABLE KEYS */; -INSERT INTO `pmgr_leases` VALUES (1,'1',1,58,34,NULL,'1997-04-04',NULL,'1997-04-04',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-07-31',NULL,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (2,'2',1,18,28,NULL,'1999-10-21',NULL,'1999-10-21',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',NULL,90.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (3,'3',1,5,18,NULL,'2001-06-06',NULL,'2001-06-06',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',NULL,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (4,'4',1,34,33,NULL,'2002-08-05',NULL,'2002-08-05',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-07-31',NULL,55.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (5,'5',1,16,26,NULL,'2002-08-13',NULL,'2002-08-13',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',15.00,35.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (1,'1',1,58,34,NULL,'1997-04-04',NULL,'1997-04-04',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-07-31',NULL,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (2,'2',1,18,28,NULL,'1999-10-21',NULL,'1999-10-21',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-08-31',NULL,90.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (3,'3',1,5,18,NULL,'2001-06-06',NULL,'2001-06-06',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',NULL,35.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (4,'4',1,34,33,NULL,'2002-08-05',NULL,'2002-08-05',NULL,NULL,NULL,NULL,NULL,'2009-10-31','2009-10-31',NULL,55.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (5,'5',1,16,26,NULL,'2002-08-13',NULL,'2002-08-13',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',15.00,35.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (6,'6',1,43,5,NULL,'2003-05-19',NULL,'2003-05-19','2009-05-23',NULL,NULL,NULL,'2009-05-23','2009-05-31','2009-05-31',NULL,45.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (7,'7',1,38,3,NULL,'2004-04-01',NULL,'2004-04-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',NULL,45.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (7,'7',1,38,3,NULL,'2004-04-01',NULL,'2004-04-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',NULL,45.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (8,'8',1,8,21,NULL,'2004-04-03',NULL,'2004-04-03','2009-05-29',NULL,NULL,NULL,'2009-05-29','2009-05-31','2009-05-31',25.00,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (9,'9',1,37,2,NULL,'2004-07-02',NULL,'2004-07-02',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-07-31',NULL,49.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (9,'9',1,37,2,NULL,'2004-07-02',NULL,'2004-07-02',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',NULL,49.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (10,'10',1,10,23,NULL,'2005-06-18',NULL,'2005-06-18','2009-06-24',NULL,NULL,NULL,'2009-06-24','2009-06-30','2009-06-30',25.00,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (11,'11',1,1,15,NULL,'2005-08-24',NULL,'2005-08-24',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,90.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (11,'11',1,1,15,NULL,'2005-08-24',NULL,'2005-08-24',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,90.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (12,'12',1,53,13,NULL,'2005-11-21',NULL,'2005-11-21','2009-05-31',NULL,NULL,NULL,'2009-05-31','2009-05-31','2009-05-31',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (13,'13',1,2,16,NULL,'2006-02-27',NULL,'2006-02-27','2009-04-18',NULL,NULL,NULL,'2009-04-18','2009-04-30','2009-04-30',25.00,90.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (14,'14',1,28,32,NULL,'2006-04-15',NULL,'2006-04-15',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,80.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (15,'15',1,19,29,NULL,'2006-04-17',NULL,'2006-04-17',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,90.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (16,'16',1,47,8,NULL,'2006-04-29',NULL,'2006-04-29',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,63.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (14,'14',1,28,32,NULL,'2006-04-15',NULL,'2006-04-15',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,80.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (15,'15',1,19,29,NULL,'2006-04-17',NULL,'2006-04-17',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,90.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (16,'16',1,47,8,NULL,'2006-04-29',NULL,'2006-04-29',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,63.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (17,'17',1,17,27,NULL,'2006-10-20',NULL,'2006-10-20','2009-06-02',NULL,NULL,NULL,'2009-06-02','2009-05-31','2009-05-31',25.00,90.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (18,'18',1,4,17,NULL,'2007-03-09',NULL,'2007-03-09',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,90.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (19,'19',1,42,4,NULL,'2007-06-01',NULL,'2007-06-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,49.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (20,'20',1,51,11,NULL,'2007-11-15',NULL,'2007-11-15',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',NULL,40.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (18,'18',1,4,17,NULL,'2007-03-09',NULL,'2007-03-09',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-08-31',25.00,90.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (19,'19',1,42,4,NULL,'2007-06-01',NULL,'2007-06-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,49.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (20,'20',1,51,11,NULL,'2007-11-15',NULL,'2007-11-15',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',NULL,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (21,'21',1,7,20,NULL,'2008-01-05',NULL,'2008-01-05',NULL,NULL,NULL,NULL,NULL,'2009-12-31','2009-12-31',NULL,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (22,'22',1,15,25,NULL,'2008-03-01',NULL,'2008-03-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (23,'23',1,59,35,NULL,'2008-03-20',NULL,'2008-03-20',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (24,'24',1,62,38,NULL,'2008-04-09',NULL,'2008-04-09',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-07-31',25.00,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (25,'25',1,50,10,NULL,'2008-05-27',NULL,'2008-05-27',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-07-31',25.00,40.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (22,'22',1,15,25,NULL,'2008-03-01',NULL,'2008-03-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-08-31',25.00,35.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (23,'23',1,59,35,NULL,'2008-03-20',NULL,'2008-03-20',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (24,'24',1,62,38,NULL,'2008-04-09',NULL,'2008-04-09','2009-08-30',NULL,NULL,NULL,'2009-08-30','2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (25,'25',1,50,10,NULL,'2008-05-27',NULL,'2008-05-27',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (26,'26',1,24,30,NULL,'2008-06-18',NULL,'2008-06-18','2009-05-31',NULL,NULL,NULL,'2009-05-31','2009-05-31','2009-05-31',25.00,70.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (27,'27',1,9,22,NULL,'2008-07-07',NULL,'2008-07-07','2009-04-29',NULL,NULL,NULL,'2009-04-29','2009-04-30','2009-04-30',25.00,35.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (28,'28',1,56,14,NULL,'2008-07-26',NULL,'2008-07-26','2009-04-28',NULL,NULL,NULL,'2009-04-28','2009-04-30','2009-04-30',25.00,60.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (29,'29',1,70,40,NULL,'2008-08-04',NULL,'2008-08-04',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',NULL,35.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (29,'29',1,70,40,NULL,'2008-08-04',NULL,'2008-08-04','2009-08-30',NULL,NULL,NULL,'2009-08-30','2009-08-31','2009-08-31',NULL,35.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (30,'30',1,60,36,NULL,'2008-08-30',NULL,'2008-08-30',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (31,'31',1,26,31,NULL,'2008-09-01',NULL,'2008-09-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,50.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (32,'32',1,66,35,NULL,'2008-09-10',NULL,'2008-09-10',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',NULL,65.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (33,'33',1,13,24,NULL,'2008-09-20',NULL,'2008-09-20',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,35.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (31,'31',1,26,31,NULL,'2008-09-01',NULL,'2008-09-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,50.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (32,'32',1,66,35,NULL,'2008-09-10',NULL,'2008-09-10',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',NULL,65.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (33,'33',1,13,24,NULL,'2008-09-20',NULL,'2008-09-20',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,35.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (34,'34',1,69,41,NULL,'2008-11-14',NULL,'2008-11-14',NULL,NULL,NULL,NULL,NULL,'2009-10-31','2009-10-31',NULL,25.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (35,'35',1,35,1,NULL,'2009-01-01',NULL,'2009-01-01','2009-05-31',NULL,NULL,NULL,'2009-05-31','2009-05-31','2009-05-31',NULL,45.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (36,'36',1,52,43,NULL,'2009-01-01',NULL,'2009-01-01','2009-03-28',NULL,NULL,NULL,'2009-03-28','2009-03-31','2009-03-31',25.00,30.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (37,'37',1,21,46,NULL,'2009-02-01',NULL,'2009-02-01','2009-03-31',NULL,NULL,NULL,'2009-03-31','2009-03-31','2009-03-31',NULL,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (38,'38',1,25,44,NULL,'2009-02-01',NULL,'2009-02-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (38,'38',1,25,44,NULL,'2009-02-01',NULL,'2009-02-01','2009-08-26',NULL,NULL,NULL,'2009-08-26','2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (39,'39',1,64,45,NULL,'2009-02-01',NULL,'2009-02-01','2009-03-10',NULL,NULL,NULL,'2009-03-10','2009-03-31','2009-03-31',NULL,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (40,'40',1,41,8,NULL,'2009-02-01',NULL,'2009-02-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',150.00,375.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (40,'40',1,41,8,NULL,'2009-02-01',NULL,'2009-02-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',150.00,375.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (41,'41',1,45,42,NULL,'2009-02-01',NULL,'2009-02-01','2009-03-31',NULL,NULL,NULL,'2009-03-31','2009-03-31','2009-03-31',NULL,49.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (42,'42',1,46,7,NULL,'2009-02-01',NULL,'2009-02-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-06-30',25.00,63.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (42,'42',1,46,7,NULL,'2009-02-01',NULL,'2009-02-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-06-30',25.00,63.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (43,'43',1,49,9,NULL,'2009-02-21',NULL,'2009-02-21','2009-05-31',NULL,NULL,NULL,'2009-05-31','2009-05-31','2009-05-31',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (44,'44',1,45,6,NULL,'2009-03-21',NULL,'2009-03-21','2009-07-08',NULL,NULL,NULL,'2009-07-08','2009-07-31','2009-07-31',25.00,49.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (45,'45',1,61,37,NULL,'2009-03-27',NULL,'2009-03-27',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (45,'45',1,61,37,NULL,'2009-03-27',NULL,'2009-03-27',NULL,NULL,NULL,NULL,NULL,'2009-10-31','2009-10-31',25.00,70.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (46,'46',1,52,12,NULL,'2009-04-06',NULL,'2009-04-06','2009-05-31',NULL,NULL,NULL,'2009-05-31','2009-05-31','2009-05-31',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (47,'47',1,6,19,NULL,'2009-04-08',NULL,'2009-04-08','2009-07-25',NULL,NULL,NULL,'2009-07-25','2009-07-31','2009-07-31',25.00,35.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (48,'48',1,67,39,NULL,'2009-04-09',NULL,'2009-04-09','2009-06-11',NULL,NULL,NULL,'2009-06-11','2009-06-08','2009-06-08',NULL,60.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (49,'49',1,22,47,NULL,'2009-04-24',NULL,'2009-04-24',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (49,'49',1,22,47,NULL,'2009-04-24',NULL,'2009-04-24',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,70.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (50,'50',1,12,48,NULL,'2009-04-27',NULL,'2009-04-27','2009-06-24',NULL,NULL,NULL,'2009-06-24','2009-06-30','2009-06-30',25.00,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (51,'51',1,23,49,NULL,'2009-04-30',NULL,'2009-04-30',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-07-31',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (51,'51',1,23,49,NULL,'2009-04-30',NULL,'2009-04-30',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,70.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (52,'52',1,71,50,NULL,'2009-04-30',NULL,'2009-04-30',NULL,NULL,NULL,NULL,NULL,'2009-10-31','2009-10-31',NULL,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (53,'53',1,65,51,NULL,'2009-05-28',NULL,'2009-05-28',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (54,'54',1,57,9,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,63.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (55,'55',1,52,30,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-07-31',25.00,40.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (53,'53',1,65,51,NULL,'2009-05-28',NULL,'2009-05-28',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (54,'54',1,57,9,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,63.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (55,'55',1,52,30,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-08-31',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (56,'56',1,68,39,NULL,'2009-06-01',NULL,'2009-06-01','2009-06-15',NULL,NULL,NULL,'2009-06-15','2009-06-15','2009-06-15',0.00,60.00,NULL,NULL,'Lease for only 2 weeks'); INSERT INTO `pmgr_leases` VALUES (57,'57',1,72,39,NULL,'2009-06-01',NULL,'2009-06-01','2009-07-26',NULL,NULL,NULL,'2009-07-26','2009-07-31','2009-07-31',0.00,35.00,NULL,NULL,'Lumber stored in the yard'); -INSERT INTO `pmgr_leases` VALUES (58,'58',1,20,52,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,70.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (59,'59',1,29,53,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-06-30',25.00,55.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (58,'58',1,20,52,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (59,'59',1,29,53,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-06-30',25.00,55.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (60,'60',1,64,54,NULL,'2009-06-01',NULL,'2009-06-01',NULL,NULL,NULL,NULL,NULL,'2009-10-31','2009-10-31',25.00,70.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (61,'61',1,49,55,NULL,'2009-07-01',NULL,'2009-07-01','2009-07-24',NULL,NULL,NULL,'2009-07-24','2009-07-31','2009-07-31',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (62,'62',1,8,56,NULL,'2009-06-14',NULL,'2009-06-14','2009-06-24',NULL,NULL,NULL,'2009-06-24','2009-06-24','2009-06-24',0.00,35.00,NULL,NULL,'Lease for 10 days while waiting for his house'); -INSERT INTO `pmgr_leases` VALUES (63,'63',1,31,25,NULL,'2009-07-01',NULL,'2009-07-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',0.00,55.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (64,'64',1,30,53,NULL,'2009-07-01',NULL,'2009-07-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-06-30',0.00,55.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (65,'65',1,73,37,NULL,'2009-07-01',NULL,'2009-07-01',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',0.00,25.00,NULL,NULL,'Boat Trailer'); +INSERT INTO `pmgr_leases` VALUES (63,'63',1,31,25,NULL,'2009-07-01',NULL,'2009-07-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-08-31',0.00,55.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (64,'64',1,30,53,NULL,'2009-07-01',NULL,'2009-07-01','2009-09-02',NULL,NULL,NULL,NULL,'2009-09-30','2009-07-31',0.00,55.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (65,'65',1,73,37,NULL,'2009-07-01',NULL,'2009-07-01',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',0.00,25.00,NULL,NULL,'Boat Trailer'); INSERT INTO `pmgr_leases` VALUES (66,'66',1,49,57,NULL,'2009-07-25',NULL,'2009-07-25',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (67,'67',1,10,58,NULL,'2009-07-15',NULL,'2009-07-15','2009-08-05',NULL,NULL,NULL,'2009-08-05','2009-08-31','2009-08-31',25.00,35.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (68,'68',1,8,59,NULL,'2009-07-21',NULL,'2009-07-21','2009-08-05',NULL,NULL,NULL,'2009-08-05','2009-08-31','2009-08-31',25.00,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (69,'69',1,63,37,NULL,'2009-07-15',NULL,'2009-07-15',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',NULL,70.00,NULL,NULL,'Move-in date uncertain'); +INSERT INTO `pmgr_leases` VALUES (69,'69',1,63,37,NULL,'2009-07-15',NULL,'2009-07-15','2009-08-30',NULL,NULL,NULL,'2009-08-30','2009-08-31','2009-08-31',NULL,70.00,NULL,NULL,'Move-in date uncertain'); INSERT INTO `pmgr_leases` VALUES (70,'70',1,9,60,NULL,'2009-08-01',NULL,'2009-08-01',NULL,NULL,NULL,NULL,NULL,'2010-01-31','2010-01-31',25.00,35.00,NULL,NULL,NULL); -INSERT INTO `pmgr_leases` VALUES (71,'71',1,54,61,NULL,'2009-08-11',NULL,'2009-08-11',NULL,NULL,NULL,NULL,NULL,'2009-08-31','2009-08-31',25.00,40.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (71,'71',1,54,61,NULL,'2009-08-11',NULL,'2009-08-11',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,40.00,NULL,NULL,NULL); INSERT INTO `pmgr_leases` VALUES (72,'72',1,74,37,NULL,'2009-06-27',NULL,'2009-06-27','2009-07-11',NULL,NULL,NULL,'2009-07-11','2009-07-11','2009-07-11',0.00,35.00,NULL,NULL,'Boat Trailer; Very Temporary'); +INSERT INTO `pmgr_leases` VALUES (73,'73',1,17,62,NULL,'2009-08-21',NULL,'2009-08-21',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,90.00,NULL,NULL,'Move-in date estimated'); +INSERT INTO `pmgr_leases` VALUES (74,'74',1,24,63,NULL,'2009-09-01',NULL,'2009-09-01',NULL,NULL,NULL,NULL,NULL,'2010-02-28','2010-02-28',25.00,70.00,NULL,NULL,NULL); +INSERT INTO `pmgr_leases` VALUES (75,'75',1,6,64,NULL,'2009-09-07',NULL,'2009-09-07',NULL,NULL,NULL,NULL,NULL,'2009-09-30','2009-09-30',25.00,35.00,NULL,NULL,'Move-in date estimated'); /*!40000 ALTER TABLE `pmgr_leases` ENABLE KEYS */; UNLOCK TABLES; @@ -1890,7 +2057,7 @@ CREATE TABLE `pmgr_ledger_entries` ( `amount` float(12,2) NOT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=1521 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=1753 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -3307,8 +3474,8 @@ INSERT INTO `pmgr_ledger_entries` VALUES (1465,668,1,27,'DEBIT',70.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1466,668,8,34,'CREDIT',70.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1467,669,15,41,'CREDIT',5.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1468,669,1,27,'DEBIT',5.00,NULL); -INSERT INTO `pmgr_ledger_entries` VALUES (1471,671,4,59,'DEBIT',35.00,NULL); -INSERT INTO `pmgr_ledger_entries` VALUES (1472,671,1,27,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1530,695,1,27,'CREDIT',165.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1529,695,4,59,'DEBIT',165.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1473,672,4,59,'DEBIT',49.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1474,672,1,27,'CREDIT',49.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1475,673,14,40,'CREDIT',10.00,NULL); @@ -3355,6 +3522,230 @@ INSERT INTO `pmgr_ledger_entries` VALUES (1515,645,24,55,'DEBIT',25.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1516,645,1,27,'CREDIT',25.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1517,692,13,39,'CREDIT',10.00,NULL); INSERT INTO `pmgr_ledger_entries` VALUES (1518,692,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1521,693,12,38,'DEBIT',25.00,'Released Security Deposit'); +INSERT INTO `pmgr_ledger_entries` VALUES (1522,693,1,27,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1523,693,24,55,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1524,693,1,27,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1525,694,20,46,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1526,694,1,27,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1527,693,24,55,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1528,693,1,27,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1531,695,24,55,'CREDIT',165.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1532,695,1,27,'DEBIT',165.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1533,696,4,59,'DEBIT',65.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1534,696,1,27,'CREDIT',65.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1535,697,4,59,'DEBIT',65.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1536,697,1,27,'CREDIT',65.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1537,697,24,55,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1538,697,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1539,698,4,59,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1540,698,1,27,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1541,698,24,55,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1542,698,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1543,699,4,59,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1544,699,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1545,699,24,55,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1546,699,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1547,700,3,58,'DEBIT',50.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1548,700,1,27,'CREDIT',50.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1549,701,12,38,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1550,701,1,27,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1551,701,13,39,'CREDIT',31.94,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1552,701,1,27,'DEBIT',31.94,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1553,701,13,39,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1554,701,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1555,702,7,33,'DEBIT',31.94,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1556,702,1,27,'CREDIT',31.94,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1557,703,3,58,'DEBIT',115.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1558,703,1,27,'CREDIT',115.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1559,704,4,59,'CREDIT',554.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1560,704,20,46,'DEBIT',554.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1561,704,5,31,'CREDIT',75.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1562,704,20,46,'DEBIT',75.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1563,706,12,38,'DEBIT',25.00,'Released Security Deposit'); +INSERT INTO `pmgr_ledger_entries` VALUES (1564,706,1,27,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1565,706,24,55,'CREDIT',20.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1566,706,1,27,'DEBIT',20.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1567,707,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1568,707,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1569,708,13,39,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1570,708,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1571,709,13,39,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1572,709,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1573,710,13,39,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1574,710,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1575,697,24,55,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1576,697,1,27,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1577,711,13,39,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1578,711,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1579,699,24,55,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1580,699,1,27,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1581,712,13,39,'CREDIT',45.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1582,712,1,27,'DEBIT',45.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1583,713,13,39,'CREDIT',49.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1584,713,1,27,'DEBIT',49.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1585,714,13,39,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1586,714,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1587,715,13,39,'CREDIT',80.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1588,715,1,27,'DEBIT',80.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1589,716,13,39,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1590,716,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1591,717,13,39,'CREDIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1592,717,1,27,'DEBIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1593,718,13,39,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1594,718,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1595,719,13,39,'CREDIT',49.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1596,719,1,27,'DEBIT',49.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1597,720,13,39,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1598,720,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1599,721,13,39,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1600,721,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1601,722,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1602,722,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1603,723,13,39,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1604,723,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1605,724,13,39,'CREDIT',50.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1606,724,1,27,'DEBIT',50.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1607,725,13,39,'CREDIT',65.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1608,725,1,27,'DEBIT',65.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1609,726,13,39,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1610,726,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1611,727,13,39,'CREDIT',375.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1612,727,1,27,'DEBIT',375.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1613,728,13,39,'CREDIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1614,728,1,27,'DEBIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1615,729,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1616,729,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1617,695,24,55,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1618,695,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1619,730,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1620,730,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1621,731,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1622,731,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1623,732,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1624,732,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1625,733,13,39,'CREDIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1626,733,1,27,'DEBIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1627,734,13,39,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1628,734,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1629,735,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1630,735,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1631,736,13,39,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1632,736,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1633,737,13,39,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1634,737,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1712,766,1,27,'CREDIT',100.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1711,766,3,58,'DEBIT',100.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1637,739,13,39,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1638,739,1,27,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1639,695,24,55,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1640,695,1,27,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1641,740,13,39,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1642,740,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1643,741,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1644,741,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1645,695,24,55,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1646,695,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1647,742,13,39,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1648,742,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1649,698,24,55,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1650,698,1,27,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1651,743,12,38,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1652,743,1,27,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1653,743,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1654,743,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1655,743,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1656,743,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1657,743,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1658,743,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1659,743,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1660,743,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1661,743,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1662,743,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1663,743,13,39,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1664,743,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1665,744,7,33,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1666,744,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1667,745,4,61,'DEBIT',375.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1668,745,1,27,'CREDIT',375.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1669,746,4,61,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1670,746,1,27,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1671,747,4,61,'DEBIT',80.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1672,747,1,27,'CREDIT',80.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1673,748,12,38,'CREDIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1674,748,1,27,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1675,748,13,39,'CREDIT',27.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1676,748,1,27,'DEBIT',27.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1677,749,4,61,'DEBIT',52.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1678,749,1,27,'CREDIT',52.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1679,750,4,61,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1680,750,1,27,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1681,751,4,61,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1682,751,1,27,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1683,752,4,61,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1684,752,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1685,753,4,61,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1686,753,1,27,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1687,754,4,61,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1688,754,1,27,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1689,755,9,35,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1690,755,1,27,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1691,756,4,61,'DEBIT',60.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1692,756,1,27,'CREDIT',60.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1693,757,4,61,'DEBIT',100.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1694,757,1,27,'CREDIT',100.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1695,758,4,61,'DEBIT',438.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1696,758,1,27,'CREDIT',438.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1697,759,4,61,'DEBIT',45.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1698,759,1,27,'CREDIT',45.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1699,760,4,61,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1700,760,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1701,761,4,61,'DEBIT',49.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1702,761,1,27,'CREDIT',49.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1703,762,4,61,'DEBIT',135.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1704,762,1,27,'CREDIT',135.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1705,763,4,61,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1706,763,1,27,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1707,764,3,58,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1708,764,1,27,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1709,765,3,58,'DEBIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1710,765,1,27,'CREDIT',63.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1713,767,6,32,'DEBIT',75.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1714,767,1,27,'CREDIT',75.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1715,767,6,32,'CREDIT',75.00,'Auto Deposit'); +INSERT INTO `pmgr_ledger_entries` VALUES (1716,767,20,46,'DEBIT',75.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1717,768,6,32,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1718,768,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1719,768,6,32,'CREDIT',70.00,'Auto Deposit'); +INSERT INTO `pmgr_ledger_entries` VALUES (1720,768,20,46,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1721,769,6,32,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1722,769,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1723,769,6,32,'CREDIT',70.00,'Auto Deposit'); +INSERT INTO `pmgr_ledger_entries` VALUES (1724,769,20,46,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1725,770,3,58,'CREDIT',418.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1726,770,20,46,'DEBIT',418.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1727,770,4,61,'CREDIT',1804.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1728,770,20,46,'DEBIT',1804.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1752,783,1,27,'CREDIT',6.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1751,783,9,35,'DEBIT',6.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1731,773,14,40,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1732,773,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1733,774,14,40,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1734,774,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1737,776,14,40,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1738,776,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1739,777,14,40,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1740,777,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1741,778,14,40,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1742,778,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1743,779,14,40,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1744,779,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1745,780,14,40,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1746,780,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1747,781,9,35,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1748,781,1,27,'CREDIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1749,782,9,35,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_ledger_entries` VALUES (1750,782,1,27,'CREDIT',10.00,NULL); /*!40000 ALTER TABLE `pmgr_ledger_entries` ENABLE KEYS */; UNLOCK TABLES; @@ -3374,7 +3765,7 @@ CREATE TABLE `pmgr_ledgers` ( `close_transaction_id` int(10) unsigned DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=61 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=65 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -3413,7 +3804,7 @@ INSERT INTO `pmgr_ledgers` VALUES (27,'1-2',1,2,1,NULL,NULL); INSERT INTO `pmgr_ledgers` VALUES (28,'2-2',2,2,2,NULL,NULL); INSERT INTO `pmgr_ledgers` VALUES (29,'3-3',3,3,24,457,NULL); INSERT INTO `pmgr_ledgers` VALUES (30,'4-4',4,4,26,457,NULL); -INSERT INTO `pmgr_ledgers` VALUES (31,'5-2',5,2,5,NULL,NULL); +INSERT INTO `pmgr_ledgers` VALUES (31,'5-2',5,2,5,705,NULL); INSERT INTO `pmgr_ledgers` VALUES (32,'6-2',6,2,6,NULL,NULL); INSERT INTO `pmgr_ledgers` VALUES (33,'7-2',7,2,7,NULL,NULL); INSERT INTO `pmgr_ledgers` VALUES (34,'8-2',8,2,8,NULL,NULL); @@ -3440,9 +3831,13 @@ INSERT INTO `pmgr_ledgers` VALUES (54,'4-7',4,7,52,635,NULL); INSERT INTO `pmgr_ledgers` VALUES (55,'24-1',24,1,NULL,NULL,NULL); INSERT INTO `pmgr_ledgers` VALUES (56,'3-6',3,6,53,664,NULL); INSERT INTO `pmgr_ledgers` VALUES (57,'4-8',4,8,54,664,NULL); -INSERT INTO `pmgr_ledgers` VALUES (58,'3-7',3,7,56,NULL,NULL); -INSERT INTO `pmgr_ledgers` VALUES (59,'4-9',4,9,57,NULL,NULL); +INSERT INTO `pmgr_ledgers` VALUES (58,'3-7',3,7,56,771,NULL); +INSERT INTO `pmgr_ledgers` VALUES (59,'4-9',4,9,57,705,NULL); INSERT INTO `pmgr_ledgers` VALUES (60,'25-1',25,1,NULL,NULL,NULL); +INSERT INTO `pmgr_ledgers` VALUES (61,'4-10',4,10,59,771,NULL); +INSERT INTO `pmgr_ledgers` VALUES (62,'5-3',5,3,31,NULL,NULL); +INSERT INTO `pmgr_ledgers` VALUES (63,'3-8',3,8,58,NULL,NULL); +INSERT INTO `pmgr_ledgers` VALUES (64,'4-11',4,11,61,NULL,NULL); /*!40000 ALTER TABLE `pmgr_ledgers` ENABLE KEYS */; UNLOCK TABLES; @@ -3579,6 +3974,44 @@ INSERT INTO `pmgr_maps_units` VALUES (78,1,78,372,2214,1); /*!40000 ALTER TABLE `pmgr_maps_units` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `pmgr_memberships` +-- + +DROP TABLE IF EXISTS `pmgr_memberships`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_memberships` ( + `site_id` int(10) unsigned NOT NULL, + `user_id` int(10) unsigned NOT NULL, + `group_id` int(10) unsigned NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`site_id`,`user_id`,`group_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_memberships` +-- + +LOCK TABLES `pmgr_memberships` WRITE; +/*!40000 ALTER TABLE `pmgr_memberships` DISABLE KEYS */; +INSERT INTO `pmgr_memberships` VALUES (1,1,1,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,1,2,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,1,3,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,1,4,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,2,2,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,2,3,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,2,4,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,3,2,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,3,3,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,3,4,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,4,4,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,5,4,NULL); +INSERT INTO `pmgr_memberships` VALUES (1,6,5,NULL); +/*!40000 ALTER TABLE `pmgr_memberships` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `pmgr_notes` -- @@ -3607,6 +4040,118 @@ LOCK TABLES `pmgr_notes` WRITE; /*!40000 ALTER TABLE `pmgr_notes` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `pmgr_option_values` +-- + +DROP TABLE IF EXISTS `pmgr_option_values`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_option_values` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `option_id` int(10) unsigned NOT NULL, + `value` varchar(255) NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_option_values` +-- + +LOCK TABLES `pmgr_option_values` WRITE; +/*!40000 ALTER TABLE `pmgr_option_values` DISABLE KEYS */; +INSERT INTO `pmgr_option_values` VALUES (1,1,'0',NULL); +INSERT INTO `pmgr_option_values` VALUES (2,1,'1',NULL); +INSERT INTO `pmgr_option_values` VALUES (3,2,'0',NULL); +INSERT INTO `pmgr_option_values` VALUES (4,2,'1',NULL); +/*!40000 ALTER TABLE `pmgr_option_values` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pmgr_options` +-- + +DROP TABLE IF EXISTS `pmgr_options`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_options` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_key` (`name`) +) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_options` +-- + +LOCK TABLES `pmgr_options` WRITE; +/*!40000 ALTER TABLE `pmgr_options` DISABLE KEYS */; +INSERT INTO `pmgr_options` VALUES (1,'dev','Developer Flag'); +INSERT INTO `pmgr_options` VALUES (2,'admin','Administrator Flag'); +/*!40000 ALTER TABLE `pmgr_options` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pmgr_permission_values` +-- + +DROP TABLE IF EXISTS `pmgr_permission_values`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_permission_values` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `permission_id` int(10) unsigned NOT NULL, + `access` enum('ALLOW','DENY') NOT NULL DEFAULT 'DENY', + `level` smallint(5) unsigned DEFAULT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_permission_values` +-- + +LOCK TABLES `pmgr_permission_values` WRITE; +/*!40000 ALTER TABLE `pmgr_permission_values` DISABLE KEYS */; +INSERT INTO `pmgr_permission_values` VALUES (1,1,'DENY',NULL,NULL); +INSERT INTO `pmgr_permission_values` VALUES (2,1,'ALLOW',10,NULL); +INSERT INTO `pmgr_permission_values` VALUES (3,1,'ALLOW',5,NULL); +INSERT INTO `pmgr_permission_values` VALUES (4,1,'ALLOW',1,NULL); +/*!40000 ALTER TABLE `pmgr_permission_values` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `pmgr_permissions` +-- + +DROP TABLE IF EXISTS `pmgr_permissions`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_permissions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_key` (`name`) +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_permissions` +-- + +LOCK TABLES `pmgr_permissions` WRITE; +/*!40000 ALTER TABLE `pmgr_permissions` DISABLE KEYS */; +INSERT INTO `pmgr_permissions` VALUES (1,'controller.accounts',NULL); +/*!40000 ALTER TABLE `pmgr_permissions` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `pmgr_reservations` -- @@ -3689,32 +4234,6 @@ INSERT INTO `pmgr_site_areas` VALUES (1,1,'Main','Main Facility Area',NULL); /*!40000 ALTER TABLE `pmgr_site_areas` ENABLE KEYS */; UNLOCK TABLES; --- --- Table structure for table `pmgr_site_memberships` --- - -DROP TABLE IF EXISTS `pmgr_site_memberships`; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -CREATE TABLE `pmgr_site_memberships` ( - `site_id` int(10) unsigned NOT NULL, - `user_id` int(10) unsigned NOT NULL, - `group_id` int(10) unsigned NOT NULL, - `comment` varchar(255) DEFAULT NULL, - PRIMARY KEY (`site_id`,`user_id`,`group_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; -SET character_set_client = @saved_cs_client; - --- --- Dumping data for table `pmgr_site_memberships` --- - -LOCK TABLES `pmgr_site_memberships` WRITE; -/*!40000 ALTER TABLE `pmgr_site_memberships` DISABLE KEYS */; -INSERT INTO `pmgr_site_memberships` VALUES (1,1,1,NULL); -/*!40000 ALTER TABLE `pmgr_site_memberships` ENABLE KEYS */; -UNLOCK TABLES; - -- -- Table structure for table `pmgr_site_options` -- @@ -3723,11 +4242,12 @@ DROP TABLE IF EXISTS `pmgr_site_options`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `pmgr_site_options` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `site_id` int(10) unsigned NOT NULL, - `name` varchar(50) NOT NULL, - `value` varchar(255) NOT NULL, + `option_value_id` int(10) unsigned NOT NULL, `comment` varchar(255) DEFAULT NULL, - PRIMARY KEY (`site_id`,`name`) + PRIMARY KEY (`id`), + KEY `site_key` (`site_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; @@ -3740,6 +4260,32 @@ LOCK TABLES `pmgr_site_options` WRITE; /*!40000 ALTER TABLE `pmgr_site_options` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `pmgr_site_permissions` +-- + +DROP TABLE IF EXISTS `pmgr_site_permissions`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_site_permissions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `site_id` int(10) unsigned NOT NULL, + `permission_value_id` int(10) unsigned NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `site_key` (`site_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_site_permissions` +-- + +LOCK TABLES `pmgr_site_permissions` WRITE; +/*!40000 ALTER TABLE `pmgr_site_permissions` DISABLE KEYS */; +/*!40000 ALTER TABLE `pmgr_site_permissions` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `pmgr_sites` -- @@ -3789,7 +4335,7 @@ CREATE TABLE `pmgr_statement_entries` ( `reverse_transaction_id` int(10) unsigned DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=897 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=1021 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -4609,7 +5155,7 @@ INSERT INTO `pmgr_statement_entries` VALUES (865,'DISBURSEMENT',665,'2009-08-05' INSERT INTO `pmgr_statement_entries` VALUES (866,'DISBURSEMENT',666,'2009-08-05',NULL,NULL,47,49,70.00,6,791,NULL,NULL); INSERT INTO `pmgr_statement_entries` VALUES (867,'DISBURSEMENT',668,'2009-08-07',NULL,NULL,49,51,-70.00,8,792,NULL,NULL); INSERT INTO `pmgr_statement_entries` VALUES (868,'CHARGE',669,'2009-08-07',NULL,NULL,49,NULL,5.00,15,NULL,NULL,'NSF: ACH #123171955144437'); -INSERT INTO `pmgr_statement_entries` VALUES (870,'DISBURSEMENT',671,'2009-08-14',NULL,NULL,26,5,35.00,4,769,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (958,'CHARGE',742,'2009-10-01','2009-10-31',NULL,33,4,55.00,13,NULL,NULL,NULL); INSERT INTO `pmgr_statement_entries` VALUES (871,'DISBURSEMENT',672,'2009-08-14',NULL,NULL,4,19,49.00,4,778,NULL,NULL); INSERT INTO `pmgr_statement_entries` VALUES (877,'CHARGE',678,'2009-08-11',NULL,NULL,38,24,10.00,14,NULL,NULL,NULL); INSERT INTO `pmgr_statement_entries` VALUES (878,'CHARGE',679,'2009-08-11',NULL,NULL,10,25,10.00,14,NULL,NULL,NULL); @@ -4629,6 +5175,121 @@ INSERT INTO `pmgr_statement_entries` VALUES (891,'REFUND',690,'2009-08-05',NULL, INSERT INTO `pmgr_statement_entries` VALUES (892,'DISBURSEMENT',646,'2009-08-05',NULL,NULL,58,NULL,25.00,24,891,NULL,NULL); INSERT INTO `pmgr_statement_entries` VALUES (894,'DISBURSEMENT',645,'2009-08-05',NULL,NULL,59,NULL,25.00,24,893,NULL,NULL); INSERT INTO `pmgr_statement_entries` VALUES (895,'CHARGE',692,'2009-06-27','2009-07-11',NULL,37,72,10.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (898,'REFUND',694,'2009-09-03',NULL,NULL,44,NULL,25.00,20,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (899,'DISBURSEMENT',693,'2009-09-03',NULL,NULL,44,NULL,25.00,24,898,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (901,'DISBURSEMENT',696,'2009-08-28',NULL,NULL,33,4,10.00,4,586,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (902,'DISBURSEMENT',696,'2009-08-28',NULL,NULL,33,4,55.00,4,768,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (903,'DISBURSEMENT',697,'2009-08-28',NULL,NULL,33,4,10.00,4,874,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (923,'CHARGE',711,'2009-09-01','2009-09-30',NULL,26,5,35.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (960,'CHARGE',743,'2009-09-01',NULL,NULL,63,74,25.00,12,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (906,'DISBURSEMENT',699,'2009-08-14',NULL,NULL,26,5,35.00,4,769,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (925,'CHARGE',712,'2009-09-01','2009-09-30',NULL,3,7,45.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (908,'DISBURSEMENT',700,'2009-08-28',NULL,NULL,30,55,40.00,3,795,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (909,'DISBURSEMENT',700,'2009-08-28',NULL,NULL,30,55,10.00,3,881,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (910,'CHARGE',701,'2009-08-21',NULL,NULL,62,73,25.00,12,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (911,'CHARGE',701,'2009-08-21','2009-08-31',NULL,62,73,31.94,13,NULL,NULL,'Move-In Rent (Prorated)'); +INSERT INTO `pmgr_statement_entries` VALUES (912,'CHARGE',701,'2009-09-01','2009-09-30',NULL,62,73,90.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (913,'DISBURSEMENT',702,'2009-08-21',NULL,NULL,62,73,31.94,7,911,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (914,'DISBURSEMENT',703,'2009-08-21',NULL,NULL,62,73,25.00,3,910,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (915,'DISBURSEMENT',703,'2009-09-01',NULL,NULL,62,73,90.00,3,912,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (916,'DISBURSEMENT',706,'2009-08-30',NULL,NULL,38,24,5.00,12,782,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (917,'SURPLUS',706,'2009-08-30',NULL,NULL,38,NULL,20.00,24,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (918,'CHARGE',707,'2009-09-01','2009-09-30',NULL,34,1,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (919,'CHARGE',708,'2009-09-01','2009-09-30',NULL,28,2,90.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (920,'CHARGE',709,'2009-09-01','2009-09-30',NULL,18,3,35.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (921,'CHARGE',710,'2009-09-01','2009-09-30',NULL,33,4,55.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (922,'DISBURSEMENT',697,'2009-09-01',NULL,NULL,33,4,55.00,24,921,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (924,'DISBURSEMENT',699,'2009-09-01',NULL,NULL,26,5,35.00,24,923,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (926,'CHARGE',713,'2009-09-01','2009-09-30',NULL,2,9,49.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (927,'CHARGE',714,'2009-09-01','2009-09-30',NULL,15,11,90.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (928,'CHARGE',715,'2009-09-01','2009-09-30',NULL,32,14,80.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (929,'CHARGE',716,'2009-09-01','2009-09-30',NULL,29,15,90.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (930,'CHARGE',717,'2009-09-01','2009-09-30',NULL,8,16,63.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (931,'CHARGE',718,'2009-09-01','2009-09-30',NULL,17,18,90.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (932,'CHARGE',719,'2009-09-01','2009-09-30',NULL,4,19,49.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (933,'CHARGE',720,'2009-09-01','2009-09-30',NULL,11,20,40.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (934,'CHARGE',721,'2009-09-01','2009-09-30',NULL,25,22,35.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (935,'CHARGE',722,'2009-09-01','2009-09-30',NULL,35,23,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (936,'CHARGE',723,'2009-09-01','2009-09-30',NULL,10,25,40.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (937,'CHARGE',724,'2009-09-01','2009-09-30',NULL,31,31,50.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (938,'CHARGE',725,'2009-09-01','2009-09-30',NULL,35,32,65.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (939,'CHARGE',726,'2009-09-01','2009-09-30',NULL,24,33,35.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (940,'CHARGE',727,'2009-09-01','2009-09-30',NULL,8,40,375.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (941,'CHARGE',728,'2009-09-01','2009-09-30',NULL,7,42,63.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (942,'CHARGE',729,'2009-09-01','2009-09-30',NULL,37,45,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (943,'DISBURSEMENT',695,'2009-09-01',NULL,NULL,37,45,70.00,24,942,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (944,'CHARGE',730,'2009-09-01','2009-09-30',NULL,47,49,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (945,'CHARGE',731,'2009-09-01','2009-09-30',NULL,49,51,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (946,'CHARGE',732,'2009-09-01','2009-09-30',NULL,51,53,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (947,'CHARGE',733,'2009-09-01','2009-09-30',NULL,9,54,63.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (948,'CHARGE',734,'2009-09-01','2009-09-30',NULL,30,55,40.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (949,'CHARGE',735,'2009-09-01','2009-09-30',NULL,52,58,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (950,'CHARGE',736,'2009-09-01','2009-09-30',NULL,53,59,55.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (951,'CHARGE',737,'2009-09-01','2009-09-30',NULL,25,63,55.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1003,'DISBURSEMENT',766,'2009-09-02',NULL,NULL,53,64,55.00,3,605,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (953,'CHARGE',739,'2009-09-01','2009-09-30',NULL,37,65,25.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (954,'DISBURSEMENT',695,'2009-09-01',NULL,NULL,37,65,25.00,24,953,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (955,'CHARGE',740,'2009-09-01','2009-09-30',NULL,61,71,40.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (956,'CHARGE',741,'2009-10-01','2009-10-31',NULL,37,45,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (957,'DISBURSEMENT',695,'2009-10-01',NULL,NULL,37,45,70.00,24,956,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (959,'DISBURSEMENT',698,'2009-10-01',NULL,NULL,33,4,55.00,24,958,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (961,'CHARGE',743,'2009-09-01','2009-09-30',NULL,63,74,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (962,'CHARGE',743,'2009-10-01','2009-10-31',NULL,63,74,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (963,'CHARGE',743,'2009-11-01','2009-11-30',NULL,63,74,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (964,'CHARGE',743,'2009-12-01','2009-12-31',NULL,63,74,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (965,'CHARGE',743,'2010-01-01','2010-01-31',NULL,63,74,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (966,'CHARGE',743,'2010-02-01','2010-02-28',NULL,63,74,70.00,13,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (967,'DISBURSEMENT',744,'2009-09-01',NULL,NULL,63,74,70.00,7,961,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (968,'DISBURSEMENT',745,'2009-09-01',NULL,NULL,63,74,25.00,4,960,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (969,'DISBURSEMENT',745,'2009-10-01',NULL,NULL,63,74,70.00,4,962,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (970,'DISBURSEMENT',745,'2009-11-01',NULL,NULL,63,74,70.00,4,963,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (971,'DISBURSEMENT',745,'2009-12-01',NULL,NULL,63,74,70.00,4,964,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (972,'DISBURSEMENT',745,'2010-01-01',NULL,NULL,63,74,70.00,4,965,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (973,'DISBURSEMENT',745,'2010-02-01',NULL,NULL,63,74,70.00,4,966,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (974,'DISBURSEMENT',746,'2009-09-09',NULL,NULL,24,33,35.00,4,939,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (975,'DISBURSEMENT',747,'2009-09-09',NULL,NULL,32,14,80.00,4,928,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (976,'CHARGE',748,'2009-09-07',NULL,NULL,64,75,25.00,12,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (977,'CHARGE',748,'2009-09-07','2009-09-30',NULL,64,75,27.00,13,NULL,NULL,'Move-In Rent (Prorated)'); +INSERT INTO `pmgr_statement_entries` VALUES (978,'DISBURSEMENT',749,'2009-09-07',NULL,NULL,64,75,25.00,4,976,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (979,'DISBURSEMENT',749,'2009-09-07',NULL,NULL,64,75,27.00,4,977,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (980,'DISBURSEMENT',750,'2009-09-09',NULL,NULL,18,3,35.00,4,920,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (981,'DISBURSEMENT',751,'2009-09-09',NULL,NULL,15,11,90.00,4,927,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (982,'DISBURSEMENT',752,'2009-09-09',NULL,NULL,51,53,70.00,4,946,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (983,'DISBURSEMENT',753,'2009-09-09',NULL,NULL,11,20,40.00,4,933,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (984,'DISBURSEMENT',754,'2009-09-09',NULL,NULL,61,71,40.00,4,955,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (985,'WAIVER',755,'2009-09-14',NULL,NULL,31,31,10.00,9,717,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (986,'DISBURSEMENT',756,'2009-09-09',NULL,NULL,31,31,10.00,4,589,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (987,'DISBURSEMENT',756,'2009-09-09',NULL,NULL,31,31,50.00,4,937,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (988,'DISBURSEMENT',757,'2009-09-09',NULL,NULL,2,9,47.00,4,771,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (989,'DISBURSEMENT',757,'2009-09-09',NULL,NULL,2,9,4.00,4,875,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (990,'DISBURSEMENT',757,'2009-09-09',NULL,NULL,2,9,49.00,4,926,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (991,'DISBURSEMENT',758,'2009-09-09',NULL,NULL,8,16,63.00,4,930,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (992,'DISBURSEMENT',758,'2009-09-09',NULL,NULL,8,40,375.00,4,940,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (993,'DISBURSEMENT',759,'2009-09-09',NULL,NULL,3,7,45.00,4,925,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (994,'DISBURSEMENT',760,'2009-09-09',NULL,NULL,52,58,70.00,4,949,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (995,'DISBURSEMENT',761,'2009-09-09',NULL,NULL,4,19,49.00,4,932,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (996,'DISBURSEMENT',762,'2009-09-09',NULL,NULL,35,32,65.00,4,938,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (997,'DISBURSEMENT',762,'2009-09-09',NULL,NULL,35,23,70.00,4,935,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (998,'DISBURSEMENT',763,'2009-09-09',NULL,NULL,29,15,90.00,4,929,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (999,'DISBURSEMENT',764,'2009-09-09',NULL,NULL,10,25,40.00,3,783,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1000,'DISBURSEMENT',764,'2009-09-09',NULL,NULL,10,25,10.00,3,878,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1001,'DISBURSEMENT',764,'2009-09-09',NULL,NULL,10,25,40.00,3,936,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1002,'DISBURSEMENT',765,'2009-09-09',NULL,NULL,9,54,63.00,3,947,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1004,'DISBURSEMENT',766,'2009-09-02',NULL,NULL,53,59,45.00,3,644,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1005,'DISBURSEMENT',767,'2009-09-01',NULL,NULL,49,51,70.00,6,792,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1006,'DISBURSEMENT',767,'2009-09-01',NULL,NULL,49,NULL,5.00,6,868,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1007,'DISBURSEMENT',768,'2009-09-10',NULL,NULL,49,51,70.00,6,945,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1008,'DISBURSEMENT',769,'2009-09-10',NULL,NULL,47,49,70.00,6,944,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1020,'WAIVER',783,'2009-09-14',NULL,NULL,2,9,6.00,9,875,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1010,'CHARGE',773,'2009-09-11',NULL,NULL,34,1,10.00,14,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1011,'CHARGE',774,'2009-09-11',NULL,NULL,28,2,10.00,14,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1013,'CHARGE',776,'2009-09-11',NULL,NULL,25,22,10.00,14,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1014,'CHARGE',777,'2009-09-11',NULL,NULL,7,42,10.00,14,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1015,'CHARGE',778,'2009-09-11',NULL,NULL,30,55,10.00,14,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1016,'CHARGE',779,'2009-09-11',NULL,NULL,53,59,10.00,14,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1017,'CHARGE',780,'2009-09-11',NULL,NULL,25,63,10.00,14,NULL,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1018,'WAIVER',781,'2009-09-14',NULL,NULL,25,22,10.00,9,1013,NULL,NULL); +INSERT INTO `pmgr_statement_entries` VALUES (1019,'WAIVER',782,'2009-09-14',NULL,NULL,25,63,10.00,9,1017,NULL,NULL); /*!40000 ALTER TABLE `pmgr_statement_entries` ENABLE KEYS */; UNLOCK TABLES; @@ -4694,7 +5355,7 @@ CREATE TABLE `pmgr_tenders` ( `nsf_transaction_id` int(10) unsigned DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=232 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=264 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -4926,12 +5587,43 @@ INSERT INTO `pmgr_tenders` VALUES (222,'Cash #222',1,40,NULL,NULL,NULL,NULL,1433 INSERT INTO `pmgr_tenders` VALUES (223,'Check #',2,57,NULL,NULL,NULL,NULL,1441,NULL,1444,663,NULL,NULL); INSERT INTO `pmgr_tenders` VALUES (224,'ACH #123171955144437',4,49,'125000024','37837895','123171955144437',NULL,1449,1466,1460,665,667,'NSF: Retry to occur on 8/28/09'); INSERT INTO `pmgr_tenders` VALUES (225,'ACH #123171955144437',4,47,'125000105','153552733096','123171955144437',NULL,1451,NULL,1462,666,NULL,NULL); -INSERT INTO `pmgr_tenders` VALUES (226,'Check #',2,24,NULL,NULL,NULL,NULL,1469,NULL,NULL,NULL,NULL,NULL); -INSERT INTO `pmgr_tenders` VALUES (227,'Check #',2,26,NULL,NULL,NULL,NULL,1471,NULL,NULL,NULL,NULL,NULL); -INSERT INTO `pmgr_tenders` VALUES (228,'Check #',2,4,NULL,NULL,NULL,NULL,1473,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (226,'Check #',2,24,NULL,NULL,NULL,NULL,1469,NULL,1560,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (232,'Check #',2,37,NULL,NULL,NULL,NULL,1529,NULL,1560,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (228,'Check #',2,4,NULL,NULL,NULL,NULL,1473,NULL,1560,704,NULL,NULL); INSERT INTO `pmgr_tenders` VALUES (229,'Voucher #1',6,28,'1',NULL,NULL,NULL,1499,NULL,NULL,NULL,NULL,NULL); -INSERT INTO `pmgr_tenders` VALUES (230,'Money Order #',3,28,NULL,NULL,NULL,NULL,1501,NULL,NULL,NULL,NULL,NULL); -INSERT INTO `pmgr_tenders` VALUES (231,'Check #',2,11,NULL,NULL,NULL,NULL,1503,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (230,'Money Order #',3,28,NULL,NULL,NULL,NULL,1501,NULL,1562,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (231,'Check #',2,11,NULL,NULL,NULL,NULL,1503,NULL,1560,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (233,'Check #',2,33,NULL,NULL,NULL,NULL,1533,NULL,1560,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (234,'Check #',2,33,NULL,NULL,NULL,NULL,1535,NULL,1560,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (235,'Check #',2,33,NULL,NULL,NULL,NULL,1539,NULL,1560,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (236,'Check #',2,26,NULL,NULL,NULL,NULL,1543,NULL,1560,704,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (237,'Cash #237',1,30,NULL,NULL,NULL,NULL,1547,NULL,1726,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (238,'Concession #238',5,62,NULL,NULL,NULL,NULL,1555,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (239,'Cash #239',1,62,NULL,NULL,NULL,NULL,1557,NULL,1726,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (240,'Concession #240',5,63,NULL,NULL,NULL,NULL,1665,NULL,NULL,NULL,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (241,'Check #',2,63,NULL,NULL,NULL,NULL,1667,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (242,'Check #',2,24,NULL,NULL,NULL,NULL,1669,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (243,'Check #',2,32,NULL,NULL,NULL,NULL,1671,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (244,'Check #',2,64,NULL,NULL,NULL,NULL,1677,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (245,'Check #',2,18,NULL,NULL,NULL,NULL,1679,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (246,'Check #',2,15,NULL,NULL,NULL,NULL,1681,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (247,'Check #',2,51,NULL,NULL,NULL,NULL,1683,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (248,'Check #',2,11,NULL,NULL,NULL,NULL,1685,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (249,'Check #',2,61,NULL,NULL,NULL,NULL,1687,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (250,'Check #',2,31,NULL,NULL,NULL,NULL,1691,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (251,'Check #',2,2,NULL,NULL,NULL,NULL,1693,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (252,'Check #',2,8,NULL,NULL,NULL,NULL,1695,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (253,'Check #',2,3,NULL,NULL,NULL,NULL,1697,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (254,'Check #',2,52,NULL,NULL,NULL,NULL,1699,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (255,'Check #',2,4,NULL,NULL,NULL,NULL,1701,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (256,'Check #',2,35,NULL,NULL,NULL,NULL,1703,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (257,'Check #',2,29,NULL,NULL,NULL,NULL,1705,NULL,1728,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (258,'Cash #258',1,10,NULL,NULL,NULL,NULL,1707,NULL,1726,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (259,'Cash #259',1,9,NULL,NULL,NULL,NULL,1709,NULL,1726,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (260,'Cash #260',1,53,NULL,NULL,NULL,NULL,1711,NULL,1726,770,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (261,'ACH #123171955094243',4,49,'125000024','37837895','123171955094243',NULL,1713,NULL,1716,767,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (262,'ACH #123171955094243',4,49,'125000024','37837895','123171955094243',NULL,1717,NULL,1720,768,NULL,NULL); +INSERT INTO `pmgr_tenders` VALUES (263,'ACH #000000000014323',4,47,'123171955','56040003340','000000000014323',NULL,1721,NULL,1724,769,NULL,NULL); /*!40000 ALTER TABLE `pmgr_tenders` ENABLE KEYS */; UNLOCK TABLES; @@ -4953,7 +5645,7 @@ CREATE TABLE `pmgr_transactions` ( `amount` float(12,2) DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=693 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=784 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -5607,7 +6299,7 @@ INSERT INTO `pmgr_transactions` VALUES (666,'RECEIPT','2009-08-05 07:00:00',47,1 INSERT INTO `pmgr_transactions` VALUES (667,'WITHDRAWAL','2009-08-07 07:00:00',NULL,20,46,'CREDIT',70.00,NULL); INSERT INTO `pmgr_transactions` VALUES (668,'RECEIPT','2009-08-07 07:00:00',49,8,34,'CREDIT',-70.00,NULL); INSERT INTO `pmgr_transactions` VALUES (669,'INVOICE','2009-08-07 07:00:00',49,1,27,'DEBIT',5.00,'Reduced NSF Charge due to Automatic Payment Plan'); -INSERT INTO `pmgr_transactions` VALUES (671,'RECEIPT','2009-08-14 07:00:00',26,1,27,'CREDIT',35.00,'Sent check on time, but forgot to sign it.'); +INSERT INTO `pmgr_transactions` VALUES (695,'RECEIPT','2009-08-28 07:00:00',37,1,27,'CREDIT',165.00,NULL); INSERT INTO `pmgr_transactions` VALUES (672,'RECEIPT','2009-08-14 07:00:00',4,1,27,'CREDIT',49.00,NULL); INSERT INTO `pmgr_transactions` VALUES (673,'INVOICE','2009-08-11 07:00:00',34,1,27,'DEBIT',10.00,NULL); INSERT INTO `pmgr_transactions` VALUES (674,'INVOICE','2009-08-11 07:00:00',28,1,27,'DEBIT',10.00,NULL); @@ -5629,6 +6321,93 @@ INSERT INTO `pmgr_transactions` VALUES (689,'RECEIPT','2009-08-18 04:19:02',38,1 INSERT INTO `pmgr_transactions` VALUES (690,'PAYMENT','2009-08-05 07:00:00',58,1,27,'DEBIT',25.00,NULL); INSERT INTO `pmgr_transactions` VALUES (691,'PAYMENT','2009-08-05 07:00:00',59,1,27,'DEBIT',25.00,NULL); INSERT INTO `pmgr_transactions` VALUES (692,'INVOICE','2009-06-27 07:00:00',37,1,27,'DEBIT',10.00,'In consideration with other leases, $10 for temporary boat trailer storage'); +INSERT INTO `pmgr_transactions` VALUES (693,'RECEIPT','2009-08-26 07:00:00',44,1,27,'CREDIT',25.00,'Security Deposit Release'); +INSERT INTO `pmgr_transactions` VALUES (694,'PAYMENT','2009-09-03 18:16:00',44,1,27,'DEBIT',25.00,'Paid online. Confirmation #0909040056'); +INSERT INTO `pmgr_transactions` VALUES (696,'RECEIPT','2009-08-28 07:00:00',33,1,27,'CREDIT',65.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (697,'RECEIPT','2009-08-28 07:00:00',33,1,27,'CREDIT',65.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (698,'RECEIPT','2009-08-28 07:00:00',33,1,27,'CREDIT',55.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (699,'RECEIPT','2009-08-14 07:00:00',26,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (700,'RECEIPT','2009-08-28 07:00:00',30,1,27,'CREDIT',50.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (701,'INVOICE','2009-08-21 07:00:00',62,1,27,'DEBIT',146.94,'Move-In Charges'); +INSERT INTO `pmgr_transactions` VALUES (702,'RECEIPT','2009-08-21 07:00:00',62,1,27,'CREDIT',31.94,NULL); +INSERT INTO `pmgr_transactions` VALUES (703,'RECEIPT','2009-08-21 07:00:00',62,1,27,'CREDIT',115.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (704,'DEPOSIT','2009-08-31 01:30:00',NULL,20,46,'DEBIT',629.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (705,'CLOSE','2009-08-31 01:30:00',NULL,NULL,NULL,NULL,0.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (706,'RECEIPT','2009-08-30 07:00:00',38,1,27,'CREDIT',25.00,'Security Deposit Release'); +INSERT INTO `pmgr_transactions` VALUES (707,'INVOICE','2009-09-01 07:00:00',34,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (708,'INVOICE','2009-09-01 07:00:00',28,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (709,'INVOICE','2009-09-01 07:00:00',18,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (710,'INVOICE','2009-09-01 07:00:00',33,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (711,'INVOICE','2009-09-01 07:00:00',26,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (712,'INVOICE','2009-09-01 07:00:00',3,1,27,'DEBIT',45.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (713,'INVOICE','2009-09-01 07:00:00',2,1,27,'DEBIT',49.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (714,'INVOICE','2009-09-01 07:00:00',15,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (715,'INVOICE','2009-09-01 07:00:00',32,1,27,'DEBIT',80.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (716,'INVOICE','2009-09-01 07:00:00',29,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (717,'INVOICE','2009-09-01 07:00:00',8,1,27,'DEBIT',63.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (718,'INVOICE','2009-09-01 07:00:00',17,1,27,'DEBIT',90.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (719,'INVOICE','2009-09-01 07:00:00',4,1,27,'DEBIT',49.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (720,'INVOICE','2009-09-01 07:00:00',11,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (721,'INVOICE','2009-09-01 07:00:00',25,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (722,'INVOICE','2009-09-01 07:00:00',35,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (723,'INVOICE','2009-09-01 07:00:00',10,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (724,'INVOICE','2009-09-01 07:00:00',31,1,27,'DEBIT',50.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (725,'INVOICE','2009-09-01 07:00:00',35,1,27,'DEBIT',65.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (726,'INVOICE','2009-09-01 07:00:00',24,1,27,'DEBIT',35.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (727,'INVOICE','2009-09-01 07:00:00',8,1,27,'DEBIT',375.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (728,'INVOICE','2009-09-01 07:00:00',7,1,27,'DEBIT',63.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (729,'INVOICE','2009-09-01 07:00:00',37,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (730,'INVOICE','2009-09-01 07:00:00',47,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (731,'INVOICE','2009-09-01 07:00:00',49,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (732,'INVOICE','2009-09-01 07:00:00',51,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (733,'INVOICE','2009-09-01 07:00:00',9,1,27,'DEBIT',63.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (734,'INVOICE','2009-09-01 07:00:00',30,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (735,'INVOICE','2009-09-01 07:00:00',52,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (736,'INVOICE','2009-09-01 07:00:00',53,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (737,'INVOICE','2009-09-01 07:00:00',25,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (766,'RECEIPT','2009-09-02 07:00:00',53,1,27,'CREDIT',100.00,'Agreement of $100 pays units 40 and 41 through 8/31/09, along with move-out of 41.'); +INSERT INTO `pmgr_transactions` VALUES (739,'INVOICE','2009-09-01 07:00:00',37,1,27,'DEBIT',25.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (740,'INVOICE','2009-09-01 07:00:00',61,1,27,'DEBIT',40.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (741,'INVOICE','2009-08-28 07:00:00',37,1,27,'DEBIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (742,'INVOICE','2009-09-01 07:00:00',33,1,27,'DEBIT',55.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (743,'INVOICE','2009-09-01 07:00:00',63,1,27,'DEBIT',445.00,'Move-In Charges'); +INSERT INTO `pmgr_transactions` VALUES (744,'RECEIPT','2009-09-01 07:00:00',63,1,27,'CREDIT',70.00,'One month free with with 5 months paid in advance'); +INSERT INTO `pmgr_transactions` VALUES (745,'RECEIPT','2009-09-01 07:00:00',63,1,27,'CREDIT',375.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (746,'RECEIPT','2009-09-09 07:00:00',24,1,27,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (747,'RECEIPT','2009-09-09 07:00:00',32,1,27,'CREDIT',80.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (748,'INVOICE','2009-09-07 07:00:00',64,1,27,'DEBIT',52.00,'Move-In Charges'); +INSERT INTO `pmgr_transactions` VALUES (749,'RECEIPT','2009-09-07 07:00:00',64,1,27,'CREDIT',52.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (750,'RECEIPT','2009-09-09 07:00:00',18,1,27,'CREDIT',35.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (751,'RECEIPT','2009-09-09 07:00:00',15,1,27,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (752,'RECEIPT','2009-09-09 07:00:00',51,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (753,'RECEIPT','2009-09-09 07:00:00',11,1,27,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (754,'RECEIPT','2009-09-09 07:00:00',61,1,27,'CREDIT',40.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (755,'RECEIPT','2009-09-14 16:37:29',31,1,27,'CREDIT',10.00,'Charge Waiver'); +INSERT INTO `pmgr_transactions` VALUES (756,'RECEIPT','2009-09-09 07:00:00',31,1,27,'CREDIT',60.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (757,'RECEIPT','2009-09-09 07:00:00',2,1,27,'CREDIT',100.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (758,'RECEIPT','2009-09-09 07:00:00',8,1,27,'CREDIT',438.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (759,'RECEIPT','2009-09-09 07:00:00',3,1,27,'CREDIT',45.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (760,'RECEIPT','2009-09-09 07:00:00',52,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (761,'RECEIPT','2009-09-09 07:00:00',4,1,27,'CREDIT',49.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (762,'RECEIPT','2009-09-09 07:00:00',35,1,27,'CREDIT',135.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (763,'RECEIPT','2009-09-09 07:00:00',29,1,27,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (764,'RECEIPT','2009-09-09 07:00:00',10,1,27,'CREDIT',90.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (765,'RECEIPT','2009-09-09 07:00:00',9,1,27,'CREDIT',63.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (767,'RECEIPT','2009-09-01 07:00:00',49,1,27,'CREDIT',75.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (768,'RECEIPT','2009-09-10 07:00:00',49,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (769,'RECEIPT','2009-09-10 07:00:00',47,1,27,'CREDIT',70.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (770,'DEPOSIT','2009-09-12 02:20:00',NULL,20,46,'DEBIT',2222.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (771,'CLOSE','2009-09-12 02:20:00',NULL,NULL,NULL,NULL,0.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (783,'RECEIPT','2009-09-15 02:23:46',2,1,27,'CREDIT',6.00,'Charge Waiver'); +INSERT INTO `pmgr_transactions` VALUES (773,'INVOICE','2009-09-11 07:00:00',34,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (774,'INVOICE','2009-09-11 07:00:00',28,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (776,'INVOICE','2009-09-11 07:00:00',25,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (777,'INVOICE','2009-09-11 07:00:00',7,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (778,'INVOICE','2009-09-11 07:00:00',30,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (779,'INVOICE','2009-09-11 07:00:00',53,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (780,'INVOICE','2009-09-11 07:00:00',25,1,27,'DEBIT',10.00,NULL); +INSERT INTO `pmgr_transactions` VALUES (781,'RECEIPT','2009-09-15 02:01:11',25,1,27,'CREDIT',10.00,'Charge Waiver'); +INSERT INTO `pmgr_transactions` VALUES (782,'RECEIPT','2009-09-15 02:01:13',25,1,27,'CREDIT',10.00,'Charge Waiver'); /*!40000 ALTER TABLE `pmgr_transactions` ENABLE KEYS */; UNLOCK TABLES; @@ -5685,6 +6464,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 +6481,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 +6500,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 +6515,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','OCCUPIED',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','OCCUPIED',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','OCCUPIED',46,24,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (25,3,'36','36','VACANT',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','VACANT',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','VACANT',61,57,25.00,70.00,NULL); +INSERT INTO `pmgr_units` VALUES (63,3,'D06','D06','VACANT',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','VACANT',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; @@ -5821,11 +6604,12 @@ DROP TABLE IF EXISTS `pmgr_user_options`; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE `pmgr_user_options` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(10) unsigned NOT NULL, - `name` varchar(50) NOT NULL, - `value` varchar(255) NOT NULL, + `option_value_id` int(10) unsigned NOT NULL, `comment` varchar(255) DEFAULT NULL, - PRIMARY KEY (`user_id`,`name`) + PRIMARY KEY (`id`), + KEY `user_key` (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; @@ -5838,6 +6622,32 @@ LOCK TABLES `pmgr_user_options` WRITE; /*!40000 ALTER TABLE `pmgr_user_options` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Table structure for table `pmgr_user_permissions` +-- + +DROP TABLE IF EXISTS `pmgr_user_permissions`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `pmgr_user_permissions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `permission_value_id` int(10) unsigned NOT NULL, + `comment` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `user_key` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +-- +-- Dumping data for table `pmgr_user_permissions` +-- + +LOCK TABLES `pmgr_user_permissions` WRITE; +/*!40000 ALTER TABLE `pmgr_user_permissions` DISABLE KEYS */; +/*!40000 ALTER TABLE `pmgr_user_permissions` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Table structure for table `pmgr_users` -- @@ -5849,12 +6659,10 @@ CREATE TABLE `pmgr_users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `code` varchar(12) NOT NULL, `login` varchar(30) NOT NULL, - `salt` char(12) DEFAULT NULL, - `passhash` varchar(255) DEFAULT NULL, - `contact_id` int(10) unsigned NOT NULL, + `contact_id` int(10) unsigned DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; +) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -- @@ -5863,7 +6671,12 @@ SET character_set_client = @saved_cs_client; LOCK TABLES `pmgr_users` WRITE; /*!40000 ALTER TABLE `pmgr_users` DISABLE KEYS */; -INSERT INTO `pmgr_users` VALUES (1,'AP','abijah',NULL,NULL,1,NULL); +INSERT INTO `pmgr_users` VALUES (1,'AP','abijah',NULL,NULL); +INSERT INTO `pmgr_users` VALUES (2,'KD','kevin',NULL,NULL); +INSERT INTO `pmgr_users` VALUES (3,'AB','adam',NULL,NULL); +INSERT INTO `pmgr_users` VALUES (4,'SK','shirley',NULL,NULL); +INSERT INTO `pmgr_users` VALUES (5,'MK','mike',NULL,NULL); +INSERT INTO `pmgr_users` VALUES (6,'DE','dan',NULL,NULL); /*!40000 ALTER TABLE `pmgr_users` ENABLE KEYS */; UNLOCK TABLES; @@ -5880,4 +6693,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-09-15 2:25:01 diff --git a/db/schema.sql b/db/schema.sql index f7b7731..be99fc1 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -25,9 +25,9 @@ -- REVISIT : 20090511 -- By not specifying the database, the script can -- make the determination of which one to use. --- DROP DATABASE IF EXISTS `property_manager`; --- CREATE DATABASE `property_manager`; --- USE `property_manager`; +DROP DATABASE IF EXISTS `property_manager`; +CREATE DATABASE `property_manager`; +USE `property_manager`; -- ###################################################################### @@ -241,7 +241,7 @@ CREATE TABLE `pmgr_contacts_methods` ( -- ###################################################################### -- ###################################################################### -- ## --- ## GROUPS +-- ## GROUPS / USERS -- ## @@ -256,59 +256,15 @@ CREATE TABLE `pmgr_groups` ( -- code may not be userful `code` VARCHAR(12) NOT NULL, -- User style "id" `name` VARCHAR(80) NOT NULL, + + -- Lower ranks are given higher priority + `rank` SMALLINT UNSIGNED NOT NULL DEFAULT 100, `comment` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------- --- TABLE pmgr_group_options - -DROP TABLE IF EXISTS `pmgr_group_options`; -CREATE TABLE `pmgr_group_options` ( - `group_id` INT(10) UNSIGNED NOT NULL, - `name` VARCHAR(50) NOT NULL, - `value` VARCHAR(255) NOT NULL, - `comment` VARCHAR(255) DEFAULT NULL, - - PRIMARY KEY (`group_id`, `name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - - --- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------- --- TABLE pmgr_group_permissions - -DROP TABLE IF EXISTS `pmgr_group_permissions`; -CREATE TABLE `pmgr_group_permissions` ( - `group_id` INT(10) UNSIGNED NOT NULL, - `name` CHAR(30) NOT NULL, - `access` ENUM('ALLOWED', - 'DENIED', - 'FORCED') - NOT NULL DEFAULT 'ALLOWED', - `comment` VARCHAR(255) DEFAULT NULL, - - PRIMARY KEY (`group_id`, `name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - - - --- ###################################################################### --- ###################################################################### --- ###################################################################### --- ###################################################################### --- ###################################################################### --- ###################################################################### --- ###################################################################### --- ###################################################################### --- ###################################################################### --- ## --- ## USERS --- ## - -- ---------------------------------------------------------------------- -- ---------------------------------------------------------------------- @@ -318,14 +274,10 @@ DROP TABLE IF EXISTS `pmgr_users`; CREATE TABLE `pmgr_users` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `code` VARCHAR(12) NOT NULL, -- User style "id" - - -- Login details. Passwords are not yet used (and so NULL). - `login` VARCHAR(30) NOT NULL, - `salt` CHAR(12) DEFAULT NULL, - `passhash` VARCHAR(255) DEFAULT NULL, + `login` VARCHAR(30) NOT NULL, -- Contact information for this user - `contact_id` INT(10) UNSIGNED NOT NULL, + `contact_id` INT(10) UNSIGNED DEFAULT NULL, -- Specific comments `comment` VARCHAR(255) DEFAULT NULL, @@ -334,18 +286,208 @@ CREATE TABLE `pmgr_users` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ## +-- ## OPTIONS +-- ## + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_options + +DROP TABLE IF EXISTS `pmgr_options`; +CREATE TABLE `pmgr_options` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(50) NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + UNIQUE KEY `name_key` (`name`), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_option_values + +DROP TABLE IF EXISTS `pmgr_option_values`; +CREATE TABLE `pmgr_option_values` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `option_id` INT(10) UNSIGNED NOT NULL, + `value` VARCHAR(255) NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_default_options + +DROP TABLE IF EXISTS `pmgr_default_options`; +CREATE TABLE `pmgr_default_options` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `option_value_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_group_options + +DROP TABLE IF EXISTS `pmgr_group_options`; +CREATE TABLE `pmgr_group_options` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `group_id` INT(10) UNSIGNED NOT NULL, + `option_value_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + KEY `group_key` (`group_id`), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + -- ---------------------------------------------------------------------- -- ---------------------------------------------------------------------- -- TABLE pmgr_user_options DROP TABLE IF EXISTS `pmgr_user_options`; CREATE TABLE `pmgr_user_options` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` INT(10) UNSIGNED NOT NULL, - `name` VARCHAR(50) NOT NULL, - `value` VARCHAR(255) NOT NULL, + `option_value_id` INT(10) UNSIGNED NOT NULL, `comment` VARCHAR(255) DEFAULT NULL, + KEY `user_key` (`user_id`), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; - PRIMARY KEY (`user_id`, `name`) + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_site_options + +DROP TABLE IF EXISTS `pmgr_site_options`; +CREATE TABLE `pmgr_site_options` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `site_id` INT(10) UNSIGNED NOT NULL, + `option_value_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + KEY `site_key` (`site_id`), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + + + +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ## +-- ## PERMISSIONS +-- ## + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_permissions + +DROP TABLE IF EXISTS `pmgr_permissions`; +CREATE TABLE `pmgr_permissions` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` VARCHAR(50) NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + UNIQUE KEY `name_key` (`name`), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_permission_values + +DROP TABLE IF EXISTS `pmgr_permission_values`; +CREATE TABLE `pmgr_permission_values` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `permission_id` INT(10) UNSIGNED NOT NULL, + `access` ENUM('ALLOW', + 'DENY') + NOT NULL DEFAULT 'DENY', + `level` SMALLINT UNSIGNED DEFAULT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_default_permissions + +DROP TABLE IF EXISTS `pmgr_default_permissions`; +CREATE TABLE `pmgr_default_permissions` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `permission_value_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_group_permissions + +DROP TABLE IF EXISTS `pmgr_group_permissions`; +CREATE TABLE `pmgr_group_permissions` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `group_id` INT(10) UNSIGNED NOT NULL, + `permission_value_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + KEY `group_key` (`group_id`), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_user_permissions + +DROP TABLE IF EXISTS `pmgr_user_permissions`; +CREATE TABLE `pmgr_user_permissions` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `user_id` INT(10) UNSIGNED NOT NULL, + `permission_value_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + KEY `user_key` (`user_id`), + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_site_permissions + +DROP TABLE IF EXISTS `pmgr_site_permissions`; +CREATE TABLE `pmgr_site_permissions` ( + `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `site_id` INT(10) UNSIGNED NOT NULL, + `permission_value_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + KEY `site_key` (`site_id`), + PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; @@ -380,46 +522,6 @@ CREATE TABLE `pmgr_sites` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8; --- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------- --- TABLE pmgr_site_options - -DROP TABLE IF EXISTS `pmgr_site_options`; -CREATE TABLE `pmgr_site_options` ( - `site_id` INT(10) UNSIGNED NOT NULL, - `name` VARCHAR(50) NOT NULL, - `value` VARCHAR(255) NOT NULL, - `comment` VARCHAR(255) DEFAULT NULL, - - PRIMARY KEY (`site_id`, `name`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - - --- ---------------------------------------------------------------------- --- ---------------------------------------------------------------------- --- TABLE pmgr_site_memberships --- --- Which users are allowed to access which sites, --- and under which set of group permissions (possibly multiple) - --- SELECT U.id, P.name, MAX(P.access) --- FROM pmgr_users U --- LEFT JOIN pmgr_site_membership M ON M.user_id = U.id --- LEFT JOIN pmgr_groups G ON G.id = M.group_id --- LEFT JOIN pmgr_group_permissions P ON P.group_id = G.id --- GROUP BY U.id, P.name - -DROP TABLE IF EXISTS `pmgr_site_memberships`; -CREATE TABLE `pmgr_site_memberships` ( - `site_id` INT(10) UNSIGNED NOT NULL, - `user_id` INT(10) UNSIGNED NOT NULL, - `group_id` INT(10) UNSIGNED NOT NULL, - `comment` VARCHAR(255) DEFAULT NULL, - - PRIMARY KEY (`site_id`, `user_id`, `group_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - - -- ---------------------------------------------------------------------- -- ---------------------------------------------------------------------- -- TABLE pmgr_site_areas @@ -437,6 +539,38 @@ CREATE TABLE `pmgr_site_areas` ( +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ###################################################################### +-- ## +-- ## MEMBERSHIPS +-- ## + + +-- ---------------------------------------------------------------------- +-- ---------------------------------------------------------------------- +-- TABLE pmgr_memberships +-- +-- Which users are allowed to access which sites, +-- and under which set of group permissions (possibly multiple) + +DROP TABLE IF EXISTS `pmgr_memberships`; +CREATE TABLE `pmgr_memberships` ( + `site_id` INT(10) UNSIGNED NOT NULL, + `user_id` INT(10) UNSIGNED NOT NULL, + `group_id` INT(10) UNSIGNED NOT NULL, + `comment` VARCHAR(255) DEFAULT NULL, + + PRIMARY KEY (`site_id`, `user_id`, `group_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + -- ###################################################################### -- ###################################################################### -- ###################################################################### @@ -475,8 +609,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/db/scratch.sql b/db/scratch.sql index 2279ce7..27191ee 100644 --- a/db/scratch.sql +++ b/db/scratch.sql @@ -157,3 +157,422 @@ WHERE -- catch other types not considered in this query OR T.type NOT IN ('RECEIPT', 'CREDIT_NOTE', 'INVOICE', 'PAYMENT') + + + +-- ################################################################# +-- ################################################################# +-- ################################################################# +-- ################################################################# +-- ################################################################# +-- ################################################################# +-- ################################################################# +-- ################################################################# +-- ################################################################# +-- ## USER / GROUP + +INSERT INTO pmgr_groups (`code`, `name`, `rank`) + VALUES('Owner', 'Owner Group', 25); +SET @o_gid = LAST_INSERT_ID(); + +INSERT INTO pmgr_groups (`code`, `name`, `rank`) + VALUES('Admin', 'Admin Group', 50); +SET @a_gid = LAST_INSERT_ID(); + +INSERT INTO pmgr_groups (`code`, `name`, `rank`) + VALUES('Manager', 'Manager Group', 75); +SET @m_gid = LAST_INSERT_ID(); + +INSERT INTO pmgr_groups (`code`, `name`) + VALUES('Temp', 'Temporary Help'); +SET @t_gid = LAST_INSERT_ID(); + +INSERT INTO pmgr_users (`code`, `login`, `contact_id`) + VALUES('AP', 'abijah', 0); +SET @a_uid = LAST_INSERT_ID(); + +INSERT INTO pmgr_users (`code`, `login`, `contact_id`) + VALUES('SK', 'shirley', 0); +SET @s_uid = LAST_INSERT_ID(); + +INSERT INTO pmgr_users (`code`, `login`, `contact_id`) + VALUES('DE', 'dan', 0); +SET @d_uid = LAST_INSERT_ID(); + +INSERT INTO pmgr_users (`code`, `login`, `contact_id`) + VALUES('KD', 'kevin', 0); +SET @k_uid = LAST_INSERT_ID(); + +INSERT INTO pmgr_sites (`code`, `name`) + VALUES('VSS', 'Valley Storage'); +SET @v_sid = LAST_INSERT_ID(); + +INSERT INTO pmgr_sites (`code`, `name`) + VALUES('FAKE', 'Fake Site'); +SET @f_sid = LAST_INSERT_ID(); + +-- Site Membership + +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@v_sid, @a_uid, @o_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@v_sid, @a_uid, @a_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@v_sid, @a_uid, @m_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@v_sid, @s_uid, @m_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@v_sid, @d_uid, @t_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@f_sid, @s_uid, @a_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@f_sid, @s_uid, @m_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@f_sid, @k_uid, @o_gid); +INSERT INTO pmgr_site_memberships (`site_id`, `user_id`, `group_id`) + VALUES(@f_sid, @d_uid, @t_gid); + + +-- Options + +INSERT INTO pmgr_options (`name`) VALUES ('theme'); +SET @t_oid = LAST_INSERT_ID(); +INSERT INTO pmgr_options (`name`) VALUES ('menu'); +SET @m_oid = LAST_INSERT_ID(); + +-- Default Option Values + +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@t_oid, 'blue'); +INSERT INTO pmgr_default_options (`option_value_id`) VALUES(LAST_INSERT_ID()); +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@m_oid, 'basic'); +INSERT INTO pmgr_default_options (`option_value_id`) VALUES(LAST_INSERT_ID()); + +-- Group options + +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@t_oid, 'gold'); +INSERT INTO pmgr_group_options (`group_id`, `option_value_id`) + VALUES(@o_gid, LAST_INSERT_ID()); +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@t_oid, 'silver'); +INSERT INTO pmgr_group_options (`group_id`, `option_value_id`) + VALUES(@a_gid, LAST_INSERT_ID()); +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@t_oid, 'red'); +INSERT INTO pmgr_group_options (`group_id`, `option_value_id`) + VALUES(@m_gid, LAST_INSERT_ID()); + +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@m_oid, 'advanced'); +INSERT INTO pmgr_group_options (`group_id`, `option_value_id`) + VALUES(@o_gid, LAST_INSERT_ID()); +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@m_oid, 'advanced'); +INSERT INTO pmgr_group_options (`group_id`, `option_value_id`) + VALUES(@a_gid, LAST_INSERT_ID()); +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@m_oid, 'restricted'); +INSERT INTO pmgr_group_options (`group_id`, `option_value_id`) + VALUES(@t_gid, LAST_INSERT_ID()); + +-- User Options +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@m_oid, 'special'); +INSERT INTO pmgr_user_options (`user_id`, `option_value_id`) + VALUES(@s_uid, LAST_INSERT_ID()); + +-- Site Options +INSERT INTO pmgr_option_values (`option_id`, `value`) VALUES (@t_oid, 'site-theme'); +INSERT INTO pmgr_site_options (`site_id`, `option_value_id`) + VALUES(@f_sid, LAST_INSERT_ID()); + + +-- SELECT U.id, P.name, MAX(P.access) +-- FROM pmgr_users U +-- LEFT JOIN pmgr_site_membership M ON M.user_id = U.id +-- LEFT JOIN pmgr_groups G ON G.id = M.group_id +-- LEFT JOIN pmgr_group_permissions P ON P.group_id = G.id +-- GROUP BY U.id, P.name + + +-- User access to site +SELECT U.id, U.login, COUNT(G.id) AS 'groups', MIN(G.rank) AS highest_rank + FROM pmgr_users U + JOIN pmgr_site_memberships M ON M.user_id = U.id + JOIN pmgr_sites S ON S.id = M.site_id + JOIN pmgr_groups G ON G.id = M.group_id +WHERE S.code = 'VSS' +GROUP BY U.id + + +-- User Options +SELECT O.id, O.name, O.default, + GROUP_CONCAT(Uopt.value) AS 'value', COUNT(U.id) AS 'count' + FROM pmgr_options O + LEFT JOIN pmgr_user_options Uopt ON Uopt.option_id = O.id + LEFT JOIN pmgr_users U ON U.id = Uopt.user_id +WHERE U.id = 1 +GROUP BY O.id + +-- Group Options +SELECT O.id, O.name, O.default, + GROUP_CONCAT(Gopt.value) AS 'value', COUNT(G.id) AS 'count' + FROM pmgr_options O + LEFT JOIN pmgr_group_options Gopt ON Gopt.option_id = O.id + LEFT JOIN pmgr_groups G ON G.id = Gopt.group_id +WHERE G.id = 1 +GROUP BY O.id + + +-- Site Options +SELECT O.id, O.name, O.default, + GROUP_CONCAT(Sopt.value) AS 'value', COUNT(S.id) AS 'count' + FROM pmgr_options O + LEFT JOIN pmgr_site_options Sopt ON Sopt.option_id = O.id + LEFT JOIN pmgr_sites S ON S.id = Sopt.site_id +WHERE S.id = 1 +GROUP BY O.id + + +-- Option value for member & site +SELECT O.id, O.name, O.default, + S.id AS site_id, Sopt.value, + G.id AS group_id, Gopt.value, + U.id AS user_id, Uopt.value + FROM pmgr_options O + LEFT JOIN pmgr_site_options Sopt ON Sopt.option_id = O.id + LEFT JOIN pmgr_sites S ON S.id = Sopt.site_id + LEFT JOIN pmgr_group_options Gopt ON Gopt.option_id = O.id + LEFT JOIN pmgr_groups G ON G.id = Gopt.group_id + LEFT JOIN pmgr_user_options Uopt ON Uopt.option_id = O.id + LEFT JOIN pmgr_users U ON U.id = Uopt.user_id +WHERE O.name = 'theme' +--GROUP BY O.id + + + +-- Option value for member & site +-- 1) User +SET @sid = 1; +SET @uid = 1; +SET @oid = 1; +SELECT O.name, U.id, Uopt.value + FROM pmgr_options O + JOIN pmgr_user_options Uopt ON Uopt.option_id = O.id + JOIN pmgr_users U ON U.id = Uopt.user_id +-- JOIN pmgr_site_memberships M ON M.user_id = U.id +-- JOIN pmgr_groups G ON G.id = M.group_id +-- JOIN pmgr_sites S ON S.id = M.site_id +WHERE -- S.id = @sid AND + U.id = @uid AND O.id = @oid +; + +-- 2) Group +SELECT O.name, G.rank, G.id, Gopt.value + FROM pmgr_options O + JOIN pmgr_group_options Gopt ON Gopt.option_id = O.id + JOIN pmgr_groups G ON G.id = Gopt.group_id + JOIN pmgr_site_memberships M ON M.group_id = G.id + JOIN pmgr_users U ON U.id = M.user_id + JOIN pmgr_sites S ON S.id = M.site_id +WHERE S.id = @sid AND U.id = @uid AND O.id = @oid +ORDER BY G.rank +; + +-- 3) Site +SELECT O.name, S.id, Sopt.value + FROM pmgr_options O + JOIN pmgr_site_options Sopt ON Sopt.option_id = O.id + JOIN pmgr_sites S ON S.id = Sopt.site_id +-- JOIN pmgr_site_memberships M ON M.site_id = S.id +-- JOIN pmgr_groups G ON G.id = M.group_id +-- JOIN pmgr_users U ON U.id = M.user_id +WHERE S.id = @sid +-- AND U.id = @uid + AND O.id = @oid +; + +-- 3) Default +SELECT O.name, O.default AS 'value' + FROM pmgr_options O +WHERE O.id = @oid +; + + +-- User Permissions + + +-- Group Permissions + +-- All option values, in order +SELECT O.name, V.value, + U.id AS uid, G.id AS gid, S.id as sid, + Dopt.id AS did, G.rank + FROM pmgr_option_values V + JOIN pmgr_options O ON O.id = V.option_id + LEFT JOIN pmgr_user_options Uopt ON Uopt.option_value_id = V.id + LEFT JOIN pmgr_group_options Gopt ON Gopt.option_value_id = V.id + LEFT JOIN pmgr_site_options Sopt ON Sopt.option_value_id = V.id + LEFT JOIN pmgr_default_options Dopt ON Dopt.option_value_id = V.id + LEFT JOIN pmgr_groups G ON G.id = Gopt.group_id + LEFT JOIN pmgr_users U ON U.id = Uopt.user_id + LEFT JOIN pmgr_sites S ON S.id = Sopt.site_id +WHERE O.id = @oid +ORDER BY IF(U.id IS NOT NULL, 1, + IF (G.id IS NOT NULL, 2, + IF (S.id IS NOT NULL, 3, 4))) ASC, + IF (G.id IS NOT NULL, G.rank, 0) ASC + + +-- Option values relevant to the user and site, in order +SELECT O.name, V.value, + U.id AS uid, G.id AS gid, S.id as sid, + Dopt.id AS did, G.rank + FROM pmgr_option_values V + JOIN pmgr_options O ON O.id = V.option_id + LEFT JOIN pmgr_user_options Uopt ON Uopt.option_value_id = V.id + LEFT JOIN pmgr_group_options Gopt ON Gopt.option_value_id = V.id + LEFT JOIN pmgr_site_options Sopt ON Sopt.option_value_id = V.id + LEFT JOIN pmgr_default_options Dopt ON Dopt.option_value_id = V.id + LEFT JOIN pmgr_groups G ON G.id = Gopt.group_id + LEFT JOIN pmgr_users U ON U.id = Uopt.user_id + LEFT JOIN pmgr_sites S ON S.id = Sopt.site_id + JOIN pmgr_site_memberships M ON M.user_id = U.id AND M.site_id = S.id +WHERE S.id = @sid AND U.id = @uid AND O.id = @oid +ORDER BY IF(U.id IS NOT NULL, 1, + IF (G.id IS NOT NULL, 2, + IF (S.id IS NOT NULL, 3, 4))) ASC, + IF (G.id IS NOT NULL, G.rank, 0) ASC + + + + + +SET @sid = 1; +SET @uid = 1; +SET @oid = 1; +SELECT O.name, V.value, + U.id AS uid, + -- G.id AS gid, + S.id as sid, + Dopt.id AS did + -- G.rank + FROM pmgr_option_values V + JOIN pmgr_options O ON O.id = V.option_id + LEFT JOIN pmgr_user_options Uopt ON Uopt.option_value_id = V.id + LEFT JOIN pmgr_site_options Sopt ON Sopt.option_value_id = V.id +-- LEFT JOIN pmgr_users U ON U.id = Uopt.user_id +-- LEFT JOIN pmgr_group_options Gopt ON Gopt.option_value_id = V.id + LEFT JOIN pmgr_default_options Dopt ON Dopt.option_value_id = V.id +-- LEFT JOIN pmgr_groups G ON G.id = Gopt.group_id + LEFT JOIN pmgr_users U ON U.id = Uopt.user_id + LEFT JOIN pmgr_sites S ON S.id = Sopt.site_id + JOIN pmgr_site_memberships M ON M.user_id = U.id -- AND M.site_id = S.id +WHERE -- S.id = @sid AND U.id = @uid AND + O.id = @oid +ORDER BY IF(U.id IS NOT NULL, 1, +-- IF (G.id IS NOT NULL, 2, + IF (S.id IS NOT NULL, 3, 4)) -- ) ASC, +-- IF (G.id IS NOT NULL, G.rank, 0) ASC + + + + + +-- ------------------------------------------------------------ +-- ------------------------------------------------------------ +-- ------------------------------------------------------------ +-- Working version (without defaults) +SET @sid = 1; +SET @uid = 1; +SET @oid = 1; +SELECT O.name, O.id AS oid, V.value, V.id AS vid, + U.id AS uid, + G.id AS gid, + S.id AS sid, +-- Dopt.id AS did + G.rank + FROM pmgr_users U + JOIN pmgr_site_memberships M ON M.user_id = U.id + JOIN pmgr_sites S ON S.id = M.site_id + LEFT JOIN pmgr_groups G ON G.id = M.group_id + LEFT JOIN pmgr_user_options Uopt ON Uopt.user_id = U.id + LEFT JOIN pmgr_group_options Gopt ON Gopt.group_id = G.id + LEFT JOIN pmgr_site_options Sopt ON Sopt.site_id = S.id + LEFT JOIN pmgr_option_values V ON (V.id = Uopt.option_value_id OR + V.id = Gopt.option_value_id OR + V.id = Sopt.option_value_id) + JOIN pmgr_options O ON O.id = V.option_id +WHERE S.id = @sid AND U.id = @uid AND O.id = @oid +ORDER BY IF(U.id IS NOT NULL, 1, + IF (G.id IS NOT NULL, 2, + IF (S.id IS NOT NULL, 3, 4))) ASC, + IF (G.id IS NOT NULL, G.rank, 0) ASC +; + + + + +SET @sid = 1; +SET @uid = 1; +SET @oid = 1; +SELECT O.name, O.id AS oid, V.value, V.id AS vid, + U.id AS uid, + G.id AS gid, + S.id AS sid, +-- Dopt.id AS did + G.rank + FROM pmgr_options O + LEFT JOIN pmgr_option_values V ON V.option_id = O.id + -- Now have the option and all possible values + LEFT JOIN pmgr_user_options Uopt ON Uopt.option_value_id = V.id + LEFT JOIN pmgr_group_options Gopt ON Gopt.option_value_id = V.id + LEFT JOIN pmgr_site_options Sopt ON Sopt.option_value_id = V.id + -- Now have the user/group/site that each value applies to + LEFT JOIN pmgr_users U U ON Uopt.user_id = U.id OR Uopt.user_id IS NULL + -- Now restricted to our user + JOIN pmgr_site_memberships M ON M.user_id = U.id + JOIN pmgr_sites S ON S.id = M.site_id + + + + ON O.id = V.option_id + LEFT JOIN pmgr_groups G ON G.id = M.group_id + LEFT JOIN pmgr_option_values V ON (V.id = Uopt.option_value_id OR + V.id = Gopt.option_value_id OR + V.id = Sopt.option_value_id) + JOIN +WHERE S.id = @sid AND U.id = @uid AND O.id = @oid +ORDER BY IF(U.id IS NOT NULL, 1, + IF (G.id IS NOT NULL, 2, + IF (S.id IS NOT NULL, 3, 4))) ASC, + IF (G.id IS NOT NULL, G.rank, 0) ASC +; + + + + + + + + + +SET @sid = 1; +SET @uid = 1; +SET @oid = 1; +SELECT O.name, O.id AS oid, V.value, V.id AS vid, + U.id AS uid, + G.id AS gid, + S.id AS sid, +-- Dopt.id AS did + G.rank + FROM pmgr_options O LEFT JOIN pmgr_option_values V ON V.option_id = O.id, + pmgr_users U + JOIN pmgr_site_memberships M ON M.user_id = U.id + JOIN pmgr_sites S ON S.id = M.site_id + LEFT JOIN pmgr_groups G ON G.id = M.group_id + LEFT JOIN pmgr_user_options Uopt ON Uopt.user_id = U.id + LEFT JOIN pmgr_group_options Gopt ON Gopt.group_id = G.id + LEFT JOIN pmgr_site_options Sopt ON Sopt.site_id = S.id, +WHERE S.id = @sid AND U.id = @uid AND O.id = @oid + AND (V.id = Uopt.option_value_id OR + V.id = Gopt.option_value_id OR + V.id = Sopt.option_value_id) +ORDER BY IF(U.id IS NOT NULL, 1, + IF (G.id IS NOT NULL, 2, + IF (S.id IS NOT NULL, 3, 4))) ASC, + IF (G.id IS NOT NULL, G.rank, 0) ASC +; diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl deleted file mode 100644 index 13d222a..0000000 --- a/scripts/sitelink2pmgr.pl +++ /dev/null @@ -1,1603 +0,0 @@ -#perl -w -use strict; -use DBI; -use Data::Dumper; -use File::Copy; - -my $closing_one_transaction = 0; -my $work_from_scratch = 1; - -# Internally adjust all numbers coming from the database to -# be in inches. Not necessary to go to this detail, but the -# actual units used is irrelevant, provided everything is to -# scale, and this factor ensures that any fractional units -# become whole (e.g. 7.5 "feet" becomes 90 "units") -my $internal_adjustment_factor = 12; - -my $schema_file = shift || die("Must specify schema file\n"); -my $slink_file = shift || die("Must specify sitelink file\n"); - -my $slink_file = ";Data Source=$slink_file"; -my $slink_pass = ";Jet OLEDB:Database Password=2web"; -my $sdsn="Provider=Microsoft.Jet.OLEDB.4.0$slink_pass$slink_file"; -my $sdbh = DBI->connect("dbi:ADO:$sdsn", undef, undef, {PrintError => 1, - RaiseError => 1}); - -# Connect to the database. -my($hostname, $database, $user, $password) = ('localhost', - 'property_manager', - 'pmgr', 'pmgruser'); - -$database = shift if @ARGV; -$user = shift if @ARGV; -$password = shift if @ARGV; - -print "Connecting to $database as $user\n"; -my $db_handle = DBI->connect("DBI:mysql:database=$database;host=$hostname", - $user, $password, - {'PrintError' => 1, - 'RaiseError' => 0}); - - -$SIG{__DIE__} = \&Die; - -my ($query, $result, $nrows, $row); -my (%newdb) = ( 'schema' => [], - 'tables' => {}, - 'ids' => {}, - 'lookup' => {'state' => { 1=>'AK', 14=>'ID', 48=>'WA' }} ); - - -###################################################################### -###################################################################### -## Die - -sub Die { - my @text = @_; - warn "----------------------------------------------------------\n"; - warn "FATAL ERROR: @text\n"; - my $count = 0; - { - my ($package, $filename, $line, $sub) = caller($count); - last unless defined $line; - warn sprintf("%02i %5i %-35s %-20s\n", $count++, $line, $sub, - $filename); - redo; - } - exit 1; -} - - -###################################################################### -###################################################################### -## addRow - -sub addRow { - my ($table, $cols, $noid) = @_; - die unless $table; - die unless ref($cols) eq 'HASH'; - - die "Table `$table` is unknown!" - unless defined $newdb{'tables'}{$table}; - - my $id; - if ($noid) { - $id = $cols->{'id'}; - } - - if (!defined $id) { - $id = ++$newdb{'tables'}{$table}{'autoid'}; - } - - $cols->{'id'} = $id - unless ($noid); - - # For debug purposes - my $line = (caller())[2]; - $cols->{'--LINE--'} = "addRow called from line: $line"; - - $newdb{'tables'}{$table}{'rows'}[$id] = $cols; - return $id; -} - - -###################################################################### -###################################################################### -## updateRow - -sub updateRow { - my ($table, $id, $cols) = @_; - die unless $table; - die unless $id; - die unless ref($cols) eq 'HASH'; - - die "Table `$table` is unknown!" - unless defined $newdb{'tables'}{$table}; - - die "Table `$table` : ID `$id` does not exist!" - unless $newdb{'tables'}{$table}{'rows'}[$id]; - - # For debug purposes - my $line = (caller())[2]; - $cols->{'--UPDATE-LINE--'} = [] unless $cols->{'--UPDATE-LINE--'}; - push(@{$cols->{'--UPDATE-LINE--'}}, "updateRow called from line: $line"); - - #$newdb{'tables'}{$table}{'rows'}[$id] = $cols; - return $id; -} - - -###################################################################### -###################################################################### -## query - -sub query { - my ($dbh, $sql, $data, $ignore) = @_; - #print("$sql\n\n"); #return [ { 'id' => 7 } ]; - #print("$sql\n\n") if $sql =~ /^\s*UPDATE/i; - #return 1 unless $sql =~ /^\s*SELECT/i; - - my ($sth, $result); - if ($sql =~ /^\s*SELECT/i) { - $sth = $dbh->prepare($sql); - $sth->execute(); - $result = $sth->fetchall_arrayref({}); - } else { - $result = $dbh->do($sql); - } - - if (!$result && !$ignore) { - print STDERR "SQL Query FAILED:\n"; - print STDERR "$sql\n\n"; - print STDERR Dumper $data - if defined $data; - die; - } - return ($sth, $result); -} - - -###################################################################### -###################################################################### -## executeSchema - -sub executeSchema { - foreach (@{$newdb{'schema'}}) { - query($db_handle, $_); - } - - foreach my $table (values %{$newdb{'tables'}}) { - foreach (@{$table->{'schema'}}) { - query($db_handle, $_); - } - } -} - - -###################################################################### -###################################################################### -## buildTables - -sub buildTables { - foreach my $table_name (sort keys %{$newdb{'tables'}}) { - my $table = $newdb{'tables'}{$table_name}; - my $count = 0; - foreach (@{$table->{'rows'}}) { - next unless defined $_; - ++$count; - } - - printf("%-30s : %d rows\n", $table->{'name'}, $count); - - foreach (@{$table->{'rows'}}) { - next unless defined $_; - - my %row = %$_; - delete $row{'--LINE--'}; - - my $query; - $query = "INSERT INTO " . $table->{'name'}; - $query .= " (" . join(", ", map({"`$_`"} keys(%row))) . ")"; - $query .= " VALUES (" . join(", ", map({s/'/''/g if defined $_; - defined $_ - ? (/^\w+\(.*\)$/ - ? $_ - : "'$_'" ) - : "NULL" } - values(%row))) . ")"; - query($db_handle, $query, $_); - } - } -} - - -###################################################################### -###################################################################### -## helper functions - -sub sizeCode { - my ($width, $depth) = @_; - return "YARD" - if ($width == 12 && $depth == 40); - return "APARTMENT" - if ($width == 20 && $depth == 30); - return sprintf("%02dx%02d", $width, $depth); -} - -sub datefmt { - my ($dt) = @_; - return undef unless $dt; - my @dt = split(/\/|\s/, $dt); - #print("$dt : " . sprintf("%04d-%02d-%02d", $dt[2], $dt[0], $dt[1]) . "\n"); - return sprintf("%04d-%02d-%02d%s", $dt[2], $dt[0], $dt[1], $dt[3] ? ' '.$dt[3] : ""); -} - -sub dates { - my ($type, $dt, $dt_end, $comment, $ledger_id) = @_; - - # Nothing should be stamped before possession - my $stamp = $dt; - if ($stamp =~ m%^0?[12]/% || ($stamp =~ m%^0?3/(\d+)/% && $1 <= 25)) { - $stamp = "3/25/2009 16:00"; - } - - my $effective_dt = $dt; - my $through_dt = $dt_end; - - # Use different dates for security deposits - if ($type eq 'charge' && $comment eq 'Security Deposit') { - $effective_dt = $newdb{'lookup'}{'ledger'}{$ledger_id}{'lease_date'}; - $through_dt = undef; - } - - # REVISIT : 20090708 - # Do we want to have effective dates on invoices? - # Do we want to have effective dates for payments? - # The Receipt already has an effective date. - if ($type eq 'invoice') { - $effective_dt = undef; - $through_dt = undef; - } - - return (datefmt($stamp), datefmt($effective_dt), datefmt($through_dt)); -} - - -###################################################################### -###################################################################### -###################################################################### -###################################################################### -## BUILD THE DATABASE - -open(SCHEMA, "<$schema_file") || die ("Can't open schema ($!)\n"); -my $schema_query = ""; -my $table; -while () { - next if /^\s*--/; - if (/DROP\s+TABLE\s.*`?(pmgr_(\w+))/i) { - $table = $2; - $newdb{'tables'}{$table} = { 'name' => $1, - 'schema' => [], - 'autoid' => 0, - 'rows' => [] }; - } - - $schema_query .= $_; - if (/;\s*$/) { - $schema_query =~ s/^\s+//; - $schema_query =~ s/\s*;\s*$//; - if (!$table) { - push(@{$newdb{'schema'}}, $schema_query); - } else { - push(@{$newdb{'tables'}{$table}{'schema'}}, $schema_query); - } - $schema_query = ""; - } -} -close(SCHEMA); - -executeSchema(); - - -################################################################# -## Test Contact - -addRow('contacts', { - 'first_name' => 'Abijah', -# 'middle_name' => 'M', - 'last_name' => 'Perkins' }); - -addRow('contact_addresses', { - 'address' => '1324 N Liberty Lake Rd\nPMB 263', - 'city' => 'Liberty Lake', - 'state' => 'WA', - 'postcode' => '99019', - 'country' => 'USA' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, - 'method' => 'ADDRESS', - 'type' => 'MAIN', - 'preference' => 'PRIMARY' }, - 1); - -addRow('contact_addresses', { - 'address' => '5221 W Myrtlewood Ct', - 'city' => 'Spokane', - 'state' => 'WA', - 'postcode' => '99208', - 'country' => 'USA' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, - 'method' => 'ADDRESS', - 'type' => 'HOME', - 'preference' => 'ALTERNATE' }, - 1); - -# addRow('contact_addresses', -# { 'address' => 'PO Box 69', -# 'city' => 'Granger', -# 'state' => 'WA', -# 'postcode' => '98932', -# 'country' => 'USA' }); -# addRow('contacts_methods', -# { 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, -# 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, -# 'method' => 'ADDRESS', -# 'type' => 'HOME', -# 'preference' => 'ALTERNATE' }, -# 1); - -addRow('contact_phones', { - 'type' => 'MOBILE', - 'phone' => '5098445573' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, - 'method' => 'PHONE', - 'type' => 'MAIN', - 'preference' => 'PRIMARY' }, - 1); - -addRow('contact_phones', { - 'type' => 'MOBILE', - 'phone' => '5098445973' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, - 'method' => 'PHONE', - 'type' => 'MAIN', - 'preference' => 'ALTERNATE' }, - 1); - -addRow('contact_phones', { - 'type' => 'VIRTUAL', - 'phone' => '5095901112' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, - 'method' => 'PHONE', - 'type' => 'BUSINESS', - 'preference' => 'WORK' }, - 1); - -# addRow('contact_phones', -# { 'type' => 'LANDLINE', -# 'phone' => '5098541491' }); -# addRow('contacts_methods', -# { 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, -# 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, -# 'method' => 'PHONE', -# 'type' => 'HOME', -# 'preference' => 'ALTERNATE' }, -# 1); - -addRow('contact_phones', { - 'type' => 'VIRTUAL', - 'phone' => '8774488664' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, - 'method' => 'PHONE', - 'type' => 'BUSINESS', - 'preference' => 'WORK' }, - 1); - -addRow('contact_phones', { - 'type' => 'FAX', - 'phone' => '8662960131' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, - 'method' => 'PHONE', - 'type' => 'BUSINESS', - 'preference' => 'WORK' }, - 1); - -addRow('contact_emails', { - 'email' => 'abijah\@PerkinsHouse.com' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, - 'method' => 'EMAIL', - 'type' => 'HOME', - 'preference' => 'PRIMARY' }, - 1); - -addRow('contact_emails', { - 'email' => 'abijah\@PerkinsREI.com' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, - 'method' => 'EMAIL', - 'type' => 'HOME', - 'preference' => 'WORK' }, - 1); - -addRow('contact_emails', { - 'email' => 'abijah\@ValleyStorage.info' }); -addRow('contacts_methods', { - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'}, - 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, - 'method' => 'EMAIL', - 'type' => 'BUSINESS', - 'preference' => 'WORK' }, - 1); - - -################################################################# -## GROUPS - -addRow('groups', { - 'code' => 'Owner', - 'name' => 'Owner Group' }); -addRow('group_permissions', { - 'group_id' => $newdb{'tables'}{'groups'}{'autoid'}, - 'name' => 'EVERYTHING', - 'access' => 'FORCED' }, - 1); - - -################################################################# -## USERS - -addRow('users', { - 'code' => 'AP', - 'login' => 'abijah', - 'contact_id' => $newdb{'tables'}{'contacts'}{'autoid'} }); - - -################################################################# -## SITES - -addRow('sites', { - 'code' => 'VSS', - 'name' => 'Valley Storage' }); - -addRow('site_memberships', { - 'site_id' => $newdb{'tables'}{'sites'}{'autoid'}, - 'user_id' => $newdb{'tables'}{'users'}{'autoid'}, - 'group_id' => $newdb{'tables'}{'groups'}{'autoid'} }, - 1); - -addRow('site_areas', { - 'site_id' => $newdb{'tables'}{'sites'}{'autoid'}, - 'code' => 'Main', - 'name' => 'Main Facility Area' }); - - -################################################################# -## LEASES - -addRow('lease_types', { - 'code' => 'SL', - 'name' => 'Storage Lease' }); - - -################################################################# -## LEDGERS - -$newdb{'lookup'}{'account'} = {}; - -$query = "SELECT * FROM pmgr_accounts"; -$result = query($db_handle, $query); -foreach $row (@$result) { - addRow('ledgers', { - 'account_id' => $row->{'id'}, - 'name' => $row->{'id'} . '-1', - 'comment' => undef }); - - $newdb{'lookup'}{'account'}{$row->{'name'}} - = {'account_id' => $row->{'id'}, - 'ledger_id' => $newdb{'tables'}{'ledgers'}{'autoid'} }; - - if ((!defined $newdb{'tables'}{'accounts'}{'autoid'}) || - $row->{'id'} > $newdb{'tables'}{'accounts'}{'autoid'}) { - $newdb{'tables'}{'accounts'}{'autoid'} = $row->{'id'}; - } -} - -# For compatibility, while deciding on account names -if (!defined $newdb{'lookup'}{'account'}{'Cash'}) { - $newdb{'lookup'}{'account'}{'Cash'} - = $newdb{'lookup'}{'account'}{'Till'}; -} - -$newdb{'lookup'}{'charge_type'} = {}; -$newdb{'lookup'}{'charge_type'}{'Rent'} = - $newdb{'lookup'}{'account'}{'Rent'}; -$newdb{'lookup'}{'charge_type'}{'Late Fee'} = - $newdb{'lookup'}{'account'}{'Late Charge'}; -$newdb{'lookup'}{'charge_type'}{'Security Deposit'} = - $newdb{'lookup'}{'account'}{'Security Deposit'}; - - -################################################################# -## MONETARY TYPES - -$newdb{'lookup'}{'tender_type'} = {}; - -foreach my $tender_name ('Cash', 'Check', 'Money Order', 'ACH', - 'Concession', # REVISIT : 20090723 Do we really want this?? - #'Debit Card', 'Credit Card', - ) { - my ($tillable, $fields) = (0, 0); - my ($name1, $name2, $name3, $name4); - my ($name_field) = ('id'); - - $tillable = 1 - if ($tender_name =~ /^Cash|Check|Money Order$/); - - ($name1, $name_field) = ('Check Number', 'data1') - if ($tender_name eq 'Check'); - - ($name1, $name_field) = ('Money Order Number', 'data1') - if ($tender_name eq 'Money Order'); - - ($name1, $name2, $name3, $name_field) = ('Routing Number', 'Account Number', 'Batch Number', 'data3') - if ($tender_name eq 'ACH'); - - ($name1, $name2) = ('Debit Card Number', 'Expiration Date') - if ($tender_name eq 'Debit Card'); - - ($name1, $name2, $name3) = ('Debit Card Number', 'Expiration Date', 'Billing Zip Code') - if ($tender_name eq 'Credit Card'); - - addRow('tender_types', { - 'name' => $tender_name, - 'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'}, - 'deposit_account_id' => $newdb{'lookup'}{'account'}{'Bank'}{'account_id'}, - 'tillable' => $tillable, - 'auto_deposit' => ($tender_name eq 'ACH') ? 1 : 0, - 'data1_name' => $name1, - 'data2_name' => $name2, - 'data3_name' => $name3, - 'data4_name' => $name4, - 'naming_field' => $name_field, - }); - - $newdb{'lookup'}{'tender_type'}{$tender_name} - = { 'tender_type_id' => $newdb{'tables'}{'tender_types'}{'autoid'}, - 'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{$tender_name}{'ledger_id'}, - }; -} - - -################################################################# -## MONETARY - -$newdb{'lookup'}{'payment_type'} = {}; - -# SITELINK PAYMENT TYPE CODES -my %SITELINK_ACCOUNT_TYPE = -( 1 => 'Cash', - 2 => 'Check', - 3 => 'Money Order', - 4 => 'ACH', - 12 => 'Concession', -); - -foreach my $account_type (keys(%SITELINK_ACCOUNT_TYPE)) { - my $payment_name = $SITELINK_ACCOUNT_TYPE{$account_type}; - my ($ttid, $aid, $lid); - - if (defined $newdb{'lookup'}{'tender_type'}{$payment_name}) { - ($ttid, $aid, $lid) = ( $newdb{'lookup'}{'tender_type'}{$payment_name}{'tender_type_id'}, - $newdb{'lookup'}{'tender_type'}{$payment_name}{'account_id'}, - $newdb{'lookup'}{'tender_type'}{$payment_name}{'ledger_id'} ); - } - else { - ($ttid, $aid, $lid) = ( undef, - $newdb{'lookup'}{'account'}{$payment_name}{'account_id'}, - $newdb{'lookup'}{'account'}{$payment_name}{'ledger_id'} ); - } - - $newdb{'lookup'}{'payment_type'}{$account_type} - = { 'name' => $payment_name, - 'tender_type_id' => $ttid, - 'account_id' => $aid, - 'ledger_id' => $lid, - }; -} - - -################################################################# -## SPECIAL CASE FOR CLOSING - -$newdb{'lookup'}{'_closing'} -= { 'name' => 'Closing', - 'stamp' => (dates('receipt', '01/01/01'))[0], - 'amount' => 0, - 'tender_type_id' => undef, - 'debit_account_id' => $newdb{'lookup'}{'account'}{'Closing'}{'account_id'}, - 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Closing'}{'ledger_id'}, - 'credit_account_id' => $newdb{'lookup'}{'account'}{'A/R'}{'account_id'}, - 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'}, -}; - - - -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -## -## UNITS -## - -my @unit_sort_order = - qw( - A01 A02 A03 A04 A05 A06 - B01 B02 B03 B04 B05 B06 B07 - C01 C02 C03 C04 C05 C06 C07 C08 C09 - 10 11 12 13 14 15 16 17 18 19 22 23 24 25 26 27 28 29 - 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 - D01 D02 D03 D04 D05 D06 D07 D08 D09 D10 D11 - APT - Y01 Y02 Y03 Y04 Y05 Y06 Y07 Y08 Y09 Y10 - ); -my $unit_sort_order = 0; -my %unit_sort_order; -foreach (@unit_sort_order) { - $unit_sort_order += 1; # use 100 for later insertion - $unit_sort_order{$_} = $unit_sort_order; -} - -my @unit_walk_order = - qw( - 19 18 17 16 15 14 13 12 11 10 - C01 C02 C03 C04 C05 C06 C07 C08 C09 - APT - 38 37 36 35 34 33 32 31 30 29 28 - B01 B02 B03 B04 B05 B06 B07 - A01 A02 A03 A04 A05 A06 - 27 26 25 24 23 22 - D11 D10 D09 D08 D07 D06 D05 D04 D03 D02 D01 - 45 44 43 42 41 40 39 - Y01 Y02 Y03 Y04 Y05 Y06 Y07 Y08 Y09 Y10 - ); -my $unit_walk_order = 0; -my %unit_walk_order; -foreach (@unit_walk_order) { - $unit_walk_order += 1; # use 100 for later insertion - $unit_walk_order{$_} = $unit_walk_order; -} - -###################################################################### -## Unit Types - -$newdb{'lookup'}{'unit_type'} = {}; - -$query = "SELECT * FROM UnitType ORDER BY TypeID"; -foreach $row (@{query($sdbh, $query)}) { - addRow('unit_types', { - 'code' => 'xxx', - 'name' => $row->{'UnitType'} }); - $newdb{'lookup'}{'unit_type'}{$row->{'TypeID'}} = - $newdb{'tables'}{'unit_types'}{'autoid'}; -} - -###################################################################### -## Unit Sizes - -$newdb{'lookup'}{'unit_size'} = {}; - -$query = "SELECT * FROM UnitInfo WHERE UnitID <> 'POS\$' ORDER BY UnitID"; -foreach $row (@{query($sdbh, $query)}) { - my $sz = sizeCode($row->{'Width'}, $row->{'Depth'}); - next if defined $newdb{'lookup'}{'unit_size'}{$sz}; - - addRow('unit_sizes', { - 'unit_type_id' => $row->{'Type'}, - 'code' => $sz, - 'name' => $sz, - 'width' => $internal_adjustment_factor * $row->{'Width'}, - 'depth' => $internal_adjustment_factor * $row->{'Depth'}, - 'deposit' => $row->{'StdSecDep'}, - 'rent' => $row->{'StdRent'} }); - - $newdb{'lookup'}{'unit_size'}{$sz} - = { 'id' => $newdb{'tables'}{'unit_sizes'}{'autoid'}, - 'rent' => $row->{'StdRent'}, - 'dep' => $row->{'StdSecDep'} }; -} - -###################################################################### -## Units - -$newdb{'lookup'}{'unit'} = {}; - -foreach $row (@{query($sdbh, $query)}) { - my $sz = sizeCode($row->{'Width'}, $row->{'Depth'}); - my $szid = $newdb{'lookup'}{'unit_size'}{$sz}{'id'}; - - addRow('units', { - 'unit_size_id' => $szid, - 'code' => $row->{'UnitID'}, - 'name' => $row->{'UnitID'}, - 'status' => $row->{'Rented'} ?'OCCUPIED' :($row->{'Rentable'} ?'VACANT' :'UNAVAILABLE'), - 'sort_order' => $unit_sort_order{$row->{'UnitID'}}, - 'walk_order' => $unit_walk_order{$row->{'UnitID'}}, - 'deposit' => $row->{'StdSecDep'}, - 'rent' => $row->{'StdRent'} }); - - $newdb{'lookup'}{'unit'}{$row->{'UnitID'}} - = { 'id' => $newdb{'tables'}{'units'}{'autoid'} }; -} - - -###################################################################### -## Map - -my %info = ('extents' => {}, 'units' => {}); - -# Get the overall site limits -$query = "SELECT MIN(M.Top) AS mintop, MIN(M.Left) AS minlft,"; -$query .= " MAX(M.Top + IIF(M.reverseWL, U.Width, U.Depth)) AS bot,"; -$query .= " MAX(M.Left + IIF(M.reverseWL, U.Depth, U.Width)) AS rgt"; -$query .= ' FROM UnitInfo U INNER JOIN mapUnitsV2 M ON M.unitID = U.UnitID'; -$result = query($sdbh, $query); - -# Fetch and verify the result -my $row = shift(@$result); -die("MIN query failed!") unless $row; - -# Compute the actual boundaries, adjusting for a (0,0) origin -my $top_adjustment = 0 - $row->{'mintop'}; -my $left_adjustment = 0 - $row->{'minlft'}; -$info{'extents'}{'top'} = 0; -$info{'extents'}{'left'} = 0; -$info{'extents'}{'bottom'} = $internal_adjustment_factor * ($top_adjustment + $row->{'bot'} + 0); -$info{'extents'}{'right'} = $internal_adjustment_factor * ($left_adjustment + $row->{'rgt'} + 0); - -addRow('maps', { - 'name' => 'Main Facility Map', - 'site_area_id' => $newdb{'tables'}{'site_areas'}{'autoid'}, - 'width' => $info{'extents'}{'right'} - $info{'extents'}{'left'}, - 'depth' => $info{'extents'}{'bottom'} - $info{'extents'}{'top'} }); - -# Get list of units and positions -$query = "SELECT U.UnitID, U.UnitID as name,"; -$query .= " ($top_adjustment + M.Top) AS pt_t,"; -$query .= " ($left_adjustment + M.Left) AS pt_l,"; -$query .= " IIF(M.reverseWL, U.Depth, U.Width) AS Width,"; -$query .= " IIF(M.reverseWL, U.Width, U.Depth) AS Depth,"; -$query .= " M.reverseWL, U.Rented, U.Rentable"; -$query .= " FROM UnitInfo U INNER JOIN mapUnitsV2 M ON M.unitID = U.UnitID"; - -# Go through each one, calculating the map location -foreach $row (@{query($sdbh, $query)}) { - addRow('maps_units', { - 'map_id' => $newdb{'tables'}{'maps'}{'autoid'}, - 'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'}, - 'pt_top' => $internal_adjustment_factor * ($row->{'pt_t'}), - 'pt_left' => $internal_adjustment_factor * ($row->{'pt_l'}), - 'transpose' => $row->{'reverseWL'} }); -} - - -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -## -## TENANTS -## - - -###################################################################### -## Tenants - -$newdb{'lookup'}{'tenant'} = {}; - -$query = "SELECT * FROM TenantInfo WHERE FirstName <> 'POS' ORDER BY TenantID"; -foreach $row (@{query($sdbh, $query)}) { - - $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}} - = { 'name' => "$row->{'LastName'}, $row->{'FirstName'}" }; - - addRow('contacts', { - 'first_name' => $row->{'FirstName'}, - 'middle_name' => $row->{'MiddleName'}, - 'last_name' => $row->{'LastName'}, - 'id_local' => $row->{'IDNum'} || undef, - 'id_local_state' => $row->{'IDNum'} ? $newdb{'lookup'}{'state'}{$row->{'DLStateID'}} : undef }); - - $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'} = - $newdb{'tables'}{'contacts'}{'autoid'}; - - addRow('customers', { - 'name' => "$row->{'LastName'}, $row->{'FirstName'}", - 'primary_contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, - }); - - $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'} = - $newdb{'tables'}{'customers'}{'autoid'}; - - addRow('contacts_customers', { - 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'}, - 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, - 'type' => 'TENANT' }, - 1); - - if ($row->{'City'}) { - addRow('contact_addresses', { - 'address' => $row->{'HomeAddress'} . ($row->{'HomeAddr2'} ? "\n".$row->{'HomeAddr2'} : "") || undef, - 'city' => $row->{'City'}, - 'state' => $newdb{'lookup'}{'state'}{$row->{'StateID'}}, - 'postcode' => $row->{'Zip'} || undef, - 'country' => 'USA' }); - addRow('contacts_methods', { - 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, - 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, - 'method' => 'ADDRESS', - 'type' => 'HOME', - 'preference' => 'PRIMARY' }, - 1); - } - - foreach ({'type' => 'LANDLINE', 'preference' => 'PRIMARY', 'phone' => $row->{'Phone'}}, - {'type' => 'LANDLINE', 'preference' => 'WORK', - 'phone' => $row->{'BusinessPhone'}, 'ext' => $row->{'BusinessExt'}}, - {'type' => 'FAX', 'preference' => 'PRIMARY', 'phone' => $row->{'FAX'}}, - {'type' => 'PAGER', 'preference' => 'PRIMARY', 'phone' => $row->{'Pager'}}, - {'type' => 'MOBILE', 'preference' => 'ALTERNATE', 'phone' => $row->{'CellPhone'}}) - { - if ($_->{'phone'}) { - addRow('contact_phones', { - 'type' => $_->{'type'}, - 'phone' => $_->{'phone'}, - 'ext' => $_->{'ext'} }); - addRow('contacts_methods', { - 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, - 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, - 'method' => 'PHONE', - 'type' => 'MAIN', - 'preference' => $_->{'preference'} }, - 1); - } - } - - if ($row->{'Email'}) { - addRow('contact_emails', { - 'email' => $row->{'Email'} }); - addRow('contacts_methods', { - 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'id'}, - 'method_id' => $newdb{'tables'}{'contact_emails'}{'autoid'}, - 'method' => 'EMAIL', - 'type' => 'MAIN', - 'preference' => 'PRIMARY' }, - 1); - } - - next unless $row->{'AltFirstName'} || $row->{'AltLastName'} || $row->{'AltAddress'} || $row->{'AltPhone'}; - - addRow('contacts', { - 'first_name' => $row->{'AltFirstName'} || undef, - 'middle_name' => $row->{'AltMI'} || undef, - 'last_name' => $row->{'AltLastName'} || undef }); - - $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'} = - $newdb{'tables'}{'contacts'}{'autoid'}; - - addRow('contacts_customers', { - 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'}, - 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'}, - 'type' => 'ALTERNATE' }, - 1); - - if ($row->{'AltCity'}) { - addRow('contact_addresses', { - 'address' => $row->{'AltAddress'} . ($row->{'AltAddr2'} ? "\n".$row->{'AltAddr2'} : ""), - 'city' => $row->{'AltCity'}, - 'state' => $newdb{'lookup'}{'state'}{$row->{'AltStateID'}}, - 'postcode' => $row->{'AltZip'}, - 'country' => 'USA' }); - addRow('contacts_methods', { - 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'}, - 'method_id' => $newdb{'tables'}{'contact_addresses'}{'autoid'}, - 'method' => 'ADDRESS', - 'type' => 'MAIN', - 'preference' => 'PRIMARY' }, - 1); - } - - if ($row->{'AltPhone'}) { - addRow('contact_phones', { - 'type' => 'LANDLINE', - 'phone' => $row->{'AltPhone'}, - 'ext' => undef }); - addRow('contacts_methods', { - 'contact_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'alt'}, - 'method_id' => $newdb{'tables'}{'contact_phones'}{'autoid'}, - 'method' => 'PHONE', - 'type' => 'MAIN', - 'preference' => 'PRIMARY' }, - 1); - } -} - - -###################################################################### -## Tenant Leases - -$newdb{'lookup'}{'ledger'} = {}; - -$query = "SELECT L.*, A.TenantID FROM TenantLedger L LEFT JOIN `Access` A ON A.LedgerID = L.LedgerID WHERE L.UnitID <> 'POS\$' ORDER BY L.DateIn"; -foreach $row (@{query($sdbh, $query)}) { - - $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}} - = { 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'}, - 'lease_date' => $row->{'DateIn'}, - }; - - addRow('leases', { - 'number' => $newdb{'tables'}{'leases'}{'autoid'}+1, - #'number' => $row->{'LedgerID'}, - 'lease_type_id' => $newdb{'tables'}{'lease_types'}{'autoid'}, - 'unit_id' => $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}{'id'}, - 'customer_id' => $newdb{'lookup'}{'tenant'}{$row->{'TenantID'}}{'customer_id'}, - 'lease_date' => datefmt($row->{'DateIn'}), - 'movein_date' => datefmt($row->{'DateIn'}), - 'moveout_date' => datefmt($row->{'DateOut'}), - #'close_date' => datefmt($row->{'DateClosed'}), - 'rent' => $row->{'Rent'}, - #'comment' => "LedgerID: $row->{'LedgerID'}", - }); - - $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}}{'lease_id'} = - $newdb{'tables'}{'leases'}{'autoid'}; -} - - - -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -## -## INVOICES -## - -###################################################################### -## Invoices - -$newdb{'lookup'}{'charge'} = {}; - -$query = "SELECT *, ChargeAmount+TaxAmount AS InvoiceAmount FROM Charges ORDER BY ChargeID"; -foreach $row (@{query($sdbh, $query)}) { - - my ($stamp, $effective_date, $through_date) = - dates('invoice', $row->{'ChargeDate'}, $row->{'EndDate'}, - $row->{'ChargeDescription'}, $row->{'LedgerID'}); - - addRow('transactions', { - 'type' => 'INVOICE', - 'stamp' => $stamp, - 'customer_id' => $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}}{'customer_id'}, - 'account_id' => $newdb{'lookup'}{'account'}{'A/R'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'}, - 'crdr' => 'DEBIT', - #'amount' => $row->{'InvoiceAmount'}, - #'comment' => "Invoice Transaction", - }); - - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}} - = { 'invoice' => {'id' => $newdb{'tables'}{'transactions'}{'autoid'}, - 'amount' => $row->{'InvoiceAmount'} }, - }; - - # Charges are the only way we have to figure out security - # deposit requirements for a lease. So, if we encounter - # a security deposit charge, update the lease to reflect. - if ($row->{'ChargeDescription'} eq 'Security Deposit') { - $newdb{'tables'}{'leases'}{'rows'}[ - $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}}{'lease_id'} - ]{'deposit'} = $row->{'ChargeAmount'}; - } - -} - - -###################################################################### -## Charges - -$query = "SELECT * FROM Charges ORDER BY ChargeID"; -foreach $row (@{query($sdbh, $query)}) { - - my (undef, $effective_date, $through_date) = - dates('charge', $row->{'ChargeDate'}, $row->{'EndDate'}, - $row->{'ChargeDescription'}, $row->{'LedgerID'}); - - # Fix Brenda Harmon bug - $row->{'ChargeAmount'} = 50 - if ($row->{'ChargeID'} == 19); - - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'amount'} - = $row->{'ChargeAmount'}; - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'} - = $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}}{'customer_id'}, - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'} - = $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}}{'lease_id'}; - - # Charge must credit the Charge ledger... - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'credit_account_id'} - = $newdb{'lookup'}{'charge_type'}{$row->{'ChargeDescription'}}{'account_id'}; - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'credit_ledger_id'} - = $newdb{'lookup'}{'charge_type'}{$row->{'ChargeDescription'}}{'ledger_id'}; - - # ...and debit the A/R ledger. - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_account_id'} - = $newdb{'lookup'}{'account'}{'A/R'}{'account_id'}; - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_ledger_id'} - = $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'}; - - # debit: A/R credit: Rent/LateCharge/Etc - foreach ('debit', 'credit') { - my $CRDR = $_; - $CRDR =~ tr/a-z/A-Z/; - addRow('ledger_entries', { - 'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'id'}, - 'account_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{$_.'_account_id'}, - 'ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{$_.'_ledger_id'}, - 'crdr' => $CRDR, - 'amount' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'amount'}, - #'comment' => "$_ Ledger Entry: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}", - }); - - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{$_.'_entry_id'} - = $newdb{'tables'}{'ledger_entries'}{'autoid'}; - } - - addRow('double_entries', { - #'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'id'}, - 'debit_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_entry_id'}, - 'credit_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'credit_entry_id'}, - #'comment' => "Double Entry: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}", - }); - - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'double_entry_id'} - = $newdb{'tables'}{'double_entries'}{'autoid'}; - - # Add the Charge Statement Entry - addRow('statement_entries', { - 'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'id'}, - 'type' => 'CHARGE', - 'effective_date' => $effective_date, - 'through_date' => $through_date, - 'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'}, - 'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'}, - 'account_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'credit_account_id'}, - 'amount' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'amount'}, - #'comment' => "Charge: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}", - }); - - $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_entry_id'} - = $newdb{'tables'}{'statement_entries'}{'autoid'}; - - next unless $row->{'TaxAmount'}; - -# # Add the tax charge entry -# # debit: Invoice credit: Tax -# addRow('ledger_entries', -# { 'effective_date' => $effective_date, -# 'through_date' => $through_date, -# 'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'id'}, -# 'debit_ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'debit_ledger_id'}, -# 'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Tax'}{'ledger_id'}, -# 'amount' => $row->{'TaxAmount'}, -# #'comment' => "Tax for ChargeID:$row->{'ChargeID'}", -# }); - -# $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tax_ledger_entry_id'} -# = $newdb{'tables'}{'ledger_entries'}{'autoid'}; -} - - -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -###################################################################### -## -## RECEIPTS -## - -###################################################################### -## Receipts - -$newdb{'lookup'}{'receipt'} = {}; - -# Sitelink splits one physical payment into multiple "payments" to match each charge. -# The solution here is kludgy, but for our cases at least, it brings those pseudo-payments -# back into a single one. This presumes there is only one PaymentType per receipt. -$query = - "SELECT R.ReceiptNum, R.ReceiptDate, P.PaymentType, P.CheckNum, SUM(P.PaymentAmount) AS ReceiptAmount" . - " FROM Receipts R, Payments P" . - " WHERE P.ReceiptNum = R.ReceiptNum" . - " GROUP BY R.ReceiptNum, R.ReceiptDate, P.PaymentType, P.CheckNum" . - " ORDER BY R.ReceiptNum, P.PaymentType"; - -# print Dumper query($sdbh, $query); -# exit; - -foreach $row (@{query($sdbh, $query)}) { - -# if ($newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'ledger_entry_id'}) { -# next; -# } - - my ($stamp, $effective_date, $through_date) = - dates('receipt', $row->{'ReceiptDate'}, undef); - - if ($newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}) { - print Dumper $newdb{'lookup'}{'receipt'}; - print Dumper $row; - die "REALLY?"; - } - - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}} - = { 'date' => $stamp, - 'effective_date' => $effective_date, - 'through_date' => $through_date, - 'amount' => $row->{'ReceiptAmount'}, - }; - - if ($stamp eq $newdb{'lookup'}{'_closing'}{'stamp'}) { - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'} - = $newdb{'lookup'}{'_closing'}{'name'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_type_id'} - = $newdb{'lookup'}{'_closing'}{'tender_type_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'} - = $newdb{'lookup'}{'_closing'}{'debit_account_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'} - = $newdb{'lookup'}{'_closing'}{'debit_ledger_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_account_id'} - = $newdb{'lookup'}{'_closing'}{'credit_account_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_ledger_id'} - = $newdb{'lookup'}{'_closing'}{'credit_ledger_id'}; - - $newdb{'lookup'}{'_closing'}{'amount'} += - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'amount'}; - - if ($newdb{'lookup'}{'_closing'}{'transaction_id'}) { - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'} = - $newdb{'lookup'}{'_closing'}{'transaction_id'}; - next; - } - } - else { - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'} - = $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'name'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_type_id'} - = $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'tender_type_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'} - = $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'account_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'} - = $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'ledger_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_account_id'} - = $newdb{'lookup'}{'account'}{'A/R'}{'account_id'}; - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_ledger_id'} - = $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'}; - - if ($SITELINK_ACCOUNT_TYPE{$row->{'PaymentType'}} eq 'Check') { - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'data1'} - = $row->{'CheckNum'}; - } - } - - addRow('transactions', { - 'type' => 'RECEIPT', - 'stamp' => $stamp, - 'customer_id' => undef, # Must be set later - 'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_account_id'}, - 'ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_ledger_id'}, - 'crdr' => 'CREDIT', - #'comment' => "Receipt: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}", - }); - - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'} - = $newdb{'tables'}{'transactions'}{'autoid'}; - - # Receipt must debit the "money" asset (bank, cash, check, etc)... - # ...and credit the A/R ledger - # (These were set above, based on whether part of closing or not) - - foreach ('debit', 'credit') { - my $CRDR = $_; - $CRDR =~ tr/a-z/A-Z/; - addRow('ledger_entries', { - 'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'}, - 'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{$_.'_account_id'}, - 'ledger_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{$_.'_ledger_id'}, - 'crdr' => $CRDR, - 'amount' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'amount'}, - #'comment' => "$_ Entry Receipt: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}", - }); - - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{$_.'_entry_id'} - = $newdb{'tables'}{'ledger_entries'}{'autoid'}; - } - - addRow('double_entries', { - #'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'}, - - 'debit_entry_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_entry_id'}, - 'credit_entry_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_entry_id'}, - #'comment' => "Double Entry: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}", - }); - - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'double_entry_id'} - = $newdb{'tables'}{'double_entries'}{'autoid'}; - - # Add the physical payment - addRow('tenders', { - 'ledger_entry_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_entry_id'}, - 'name' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'}, - 'tender_type_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_type_id'}, - 'data1' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'data1'}, - #'comment' => "Physical Payment: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}", - }); - - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_id'} - = $newdb{'tables'}{'tenders'}{'autoid'}; - - - # Special case for closing - if ($closing_one_transaction && $stamp eq $newdb{'lookup'}{'_closing'}{'stamp'}) { - $newdb{'lookup'}{'_closing'}{'transaction_id'} = - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'}; - $newdb{'lookup'}{'_closing'}{'debit_entry_id'} = - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_entry_id'}; - $newdb{'lookup'}{'_closing'}{'credit_entry_id'} = - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_entry_id'}; - $newdb{'lookup'}{'_closing'}{'tender_id'} = - $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_id'}; - } - -} - - - -###################################################################### -## Payments to Charges assignments - -$newdb{'lookup'}{'payment'} = {}; - -$query = "SELECT * FROM Payments ORDER BY PaymentID"; -foreach $row (@{query($sdbh, $query)}) -{ - my (undef, $effective_date, $through_date) = - dates('payment', $row->{'PaymentDate'}); - - # Figure out how much of the charge can be reconciled - my $charge_amount = $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'amount'}; - my $payment_amount = $row->{'PaymentAmount'}; - - my $reconcile_amount = ($charge_amount < $payment_amount) ? $charge_amount : $payment_amount; - - $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}} - = { 'receipt_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'}, - 'tender_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_id'}, -# 'effective_date' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'effective_date'}, -# 'effective_date' => $effective_date; -# 'through_date' => $through_date; - 'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'}, - 'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'}, - 'amount' => $reconcile_amount, - - 'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'}, - }; - - # Update the receipt & tender customer_id, now that we have payment info - $newdb{'tables'}{'transactions'}{'rows'}[ - $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'} - ]{'customer_id'} = $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'}; - $newdb{'tables'}{'tenders'}{'rows'}[ - $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'tender_id'} - ]{'customer_id'} = $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'}; - - # Use the Memo as our comment, if it exists - my $comment = $row->{'Memo'} - #|| "Payment: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}; Charge: $row->{'ChargeID'}" - ; - - # Add the Payment Statement Entry - addRow('statement_entries', { - 'transaction_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'}, - 'type' => 'DISBURSEMENT', -# 'effective_date' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'effective_date'}, -# 'through_date' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'through_date'}, - 'effective_date' => $effective_date, - 'through_date' => $through_date, - 'customer_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'}, - 'lease_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'lease_id'}, - 'account_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'account_id'}, - 'amount' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'amount'}, - 'charge_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_entry_id'}, - 'comment' => $comment, - }); - - $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'statement_entry_id'} - = $newdb{'tables'}{'statement_entries'}{'autoid'}; -} - - -###################################################################### -## Special case - Fix the entries for our closing transaction - -if ($newdb{'lookup'}{'_closing'}{'debit_entry_id'}) { - $newdb{'tables'}{'ledger_entries'}{'rows'}[ - $newdb{'lookup'}{'_closing'}{'debit_entry_id'} - ]{'amount'} = $newdb{'lookup'}{'_closing'}{'amount'}; -} -if ($newdb{'lookup'}{'_closing'}{'credit_entry_id'}) { - $newdb{'tables'}{'ledger_entries'}{'rows'}[ - $newdb{'lookup'}{'_closing'}{'credit_entry_id'} - ]{'amount'} = $newdb{'lookup'}{'_closing'}{'amount'}; -} - - -###################################################################### -## Special case - Equities / Loans / Petty Cash - -my ($stamp, $effective_date, $through_date); - -print("Set up Petty Cash...\n"); - -# Add the first loan -# debit: Equity credit: Loan -addRow('transactions', { - 'type' => 'TRANSFER', - 'stamp' => datefmt('03/25/2009 16:00'), - 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, - 'crdr' => 'DEBIT', - 'comment' => "HTP Loan #1", - }); -addRow('ledger_entries', { - 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, - 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, - 'crdr' => 'DEBIT', - 'amount' => 5000, - 'comment' => "Equity: HTP Loan #1", - }); -addRow('ledger_entries', { - 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, - 'account_id' => $newdb{'lookup'}{'account'}{'Loan'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, - 'crdr' => 'CREDIT', - 'amount' => 5000, - 'comment' => "Loan: HTP Loan #1", - }); -addRow('double_entries', { - 'debit_entry_id' => $newdb{'tables'}{'ledger_entries'}{'autoid'}-1, - 'credit_entry_id' => $newdb{'tables'}{'ledger_entries'}{'autoid'}, - }); - -# Add the second loan -# debit: Equity credit: Loan -addRow('transactions', { - 'type' => 'TRANSFER', - 'stamp' => datefmt('04/01/2009 16:00'), - 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, - 'crdr' => 'DEBIT', - 'comment' => "HTP Loan #2", - }); -addRow('ledger_entries', { - 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, - 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, - 'crdr' => 'DEBIT', - 'amount' => 1000, - 'comment' => "Equity: HTP Loan #2", - }); -addRow('ledger_entries', { - 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, - 'account_id' => $newdb{'lookup'}{'account'}{'Loan'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Loan'}{'ledger_id'}, - 'crdr' => 'CREDIT', - 'amount' => 1000, - 'comment' => "Loan: HTP Loan #2", - }); -addRow('double_entries', { - 'debit_entry_id' => $newdb{'tables'}{'ledger_entries'}{'autoid'}-1, - 'credit_entry_id' => $newdb{'tables'}{'ledger_entries'}{'autoid'}, - }); - - -# Cheat for now, using equity for Petty Cash -# debit: Petty Cash credit: Equity -addRow('transactions', { - 'type' => 'TRANSFER', - 'stamp' => datefmt('03/25/2009 16:00'), - 'account_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'ledger_id'}, - 'crdr' => 'DEBIT', - 'comment' => "Petty Cash Funding", - }); -addRow('ledger_entries', { - 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, - 'account_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Petty Cash'}{'ledger_id'}, - 'crdr' => 'DEBIT', - 'amount' => 750, - 'comment' => "Petty Cash: Petty Cash Funding", - }); -addRow('ledger_entries', { - 'transaction_id' => $newdb{'tables'}{'transactions'}{'autoid'}, - 'account_id' => $newdb{'lookup'}{'account'}{'Equity'}{'account_id'}, - 'ledger_id' => $newdb{'lookup'}{'account'}{'Equity'}{'ledger_id'}, - 'crdr' => 'CREDIT', - 'amount' => 750, - 'comment' => "Equity: Petty Cash Funding", - }); -addRow('double_entries', { - 'debit_entry_id' => $newdb{'tables'}{'ledger_entries'}{'autoid'}-1, - 'credit_entry_id' => $newdb{'tables'}{'ledger_entries'}{'autoid'}, - }); - - -###################################################################### -## Debug ... work from scratch -if ($work_from_scratch) { - # delete $newdb{'tables'}{'contacts'}{'rows'}; - # delete $newdb{'tables'}{'contacts_methods'}{'rows'}; - # delete $newdb{'tables'}{'contacts_addresses'}{'rows'}; - # delete $newdb{'tables'}{'contacts_emails'}{'rows'}; - # delete $newdb{'tables'}{'contacts_phones'}{'rows'}; - delete $newdb{'tables'}{'contacts_customers'}{'rows'}; - delete $newdb{'tables'}{'customers'}{'rows'}; - delete $newdb{'tables'}{'double_entries'}{'rows'}; - delete $newdb{'tables'}{'leases'}{'rows'}; - delete $newdb{'tables'}{'ledger_entries'}{'rows'}; - delete $newdb{'tables'}{'statement_entries'}{'rows'}; - delete $newdb{'tables'}{'tenders'}{'rows'}; - delete $newdb{'tables'}{'transactions'}{'rows'}; - - foreach (@{$newdb{'tables'}{'units'}{'rows'}}) { - $_->{'status'} = 'VACANT' - if defined $_ && ($_->{'status'} =~ /^(OCCUPIED)$/ || $_->{'name'} =~ /^Y/); - } -} - - -###################################################################### -## Build the Database - -$Data::Dumper::Sortkeys = 1; -# print Dumper \%newdb; -# exit; - -buildTables(); - - -###################################################################### -## Special cases - Name corrections -print("Special Cases...\n"); -$query = - "UPDATE pmgr_contacts" . - " SET first_name = 'Krystan'" . - " WHERE first_name = 'Kristan' AND last_name = 'Mancini'"; -query($db_handle, $query); -$query = - "UPDATE pmgr_customers" . - " SET name = 'Mancini, Krystan'" . - " WHERE name = 'Mancini, Kristan'"; -query($db_handle, $query); -$query = - "UPDATE pmgr_contacts" . - " SET first_name = NULL, last_name = NULL, company_name = 'Valley Bible Church'" . - " WHERE first_name = 'VBC' AND last_name = 'Tenant'"; -query($db_handle, $query); -$query = - "UPDATE pmgr_customers" . - " SET name = 'Valley Bible Church'" . - " WHERE name = 'Tenant, VBC'"; -query($db_handle, $query); - - -###################################################################### -## Contact Display Names - -print("Set Contact Display Names...\n"); - -$query = - "UPDATE pmgr_contacts". - " SET display_name =" . - " IF(first_name IS NOT NULL AND last_name IS NOT NULL," . - " CONCAT(last_name, ', ', first_name)," . - " IF(first_name IS NOT NULL, first_name, last_name))"; -query($db_handle, $query); - - -###################################################################### -## Unit Lease Assignments - -print("Set Current Leases...\n"); - -$query = "UPDATE pmgr_units U, pmgr_leases L - SET U.`current_lease_id` = L.id - WHERE L.unit_id = U.id AND L.close_date IS NULL"; -query($db_handle, $query); - -# All current_lease_counts will be zero at the moment, since -# everything was just created. This will update any customers -# that have ever leased anything. -$query = "UPDATE pmgr_customers C, - (SELECT L.customer_id, - SUM(IF(L.close_date IS NULL, 1, 0)) AS current, - SUM(IF(L.close_date IS NULL, 0, 1)) AS closed - FROM pmgr_leases L - GROUP BY L.customer_id) AS X - SET C.`lease_count` = X.current + X.closed, - C.`current_lease_count` = X.current, - C.`past_lease_count` = X.closed - WHERE X.customer_id = C.id"; -query($db_handle, $query); - - -###################################################################### -## Invoice/Receipt totals - -print("Set Invoice/Receipt Totals...\n"); - -$query = "UPDATE pmgr_transactions T, pmgr_ledger_entries E - SET T.`amount` = COALESCE(T.`amount`,0) + E.amount - WHERE E.transaction_id = T.id AND E.account_id = T.account_id"; -query($db_handle, $query); - - -###################################################################### -## Tender Names - -print("Set Tender Names...\n"); - -$query = "UPDATE pmgr_tenders T, pmgr_tender_types TT - SET T.`name` = CONCAT(T.`name`, ' #', - IF(T.tender_type_id IN (2,3), T.data1, T.id)) - WHERE T.tender_type_id IS NULL OR TT.id = T.tender_type_id"; -query($db_handle, $query); - - -###################################################################### -## Invoice date fixes - -# print("Fix Invoice Dates...\n"); - -# $query = "UPDATE pmgr_transactions T, pmgr_statement_entries E -# SET T.`stamp` = -# WHERE E.transaction_id = T.id AND E.account_id = T.account_id"; -# query($db_handle, $query); - diff --git a/site/.htaccess b/site/.htaccess index 0ed8662..861117a 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 5ed9976..5775c93 100644 --- a/site/app_controller.php +++ b/site/app_controller.php @@ -35,16 +35,312 @@ * @subpackage cake.app */ class AppController extends Controller { + var $uses = array('Option', 'Permission'); var $helpers = array('Html', 'Form', 'Javascript', 'Format', 'Time', 'Grid'); var $components = array('DebugKit.Toolbar'); + var $sidemenu = array('areas' => array('SITE' => false, 'CONTROLLER' => false, 'ACTION' => false, 'SANDBOX' => false)); + var $std_area = 10; + var $admin_area = 20; + var $dev_area = 30; + var $op_area = 40; + var $new_area = 50; + function __construct() { $this->params['dev'] = false; $this->params['admin'] = false; parent::__construct(); } - function sideMenuLinks() { + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: sideMenuAreaVerify + * - Verifies the validity of the sidemenu area/subarea/priority, + * and ensures the class member is set to appropriately handle it. + */ + + function sideMenuAreaVerify(&$area, $subarea, $priority = null) { + $area = strtoupper($area); + if (!array_key_exists($area, $this->sidemenu['areas'])) + $this->INTERNAL_ERROR("Sidemenu link '{$area}': Unknown"); + + if ($area == 'SITE') + $name = 'Navigation'; + elseif ($area == 'CONTROLLER') + $name = Inflector::humanize($this->params['controller']); + elseif ($area == 'ACTION') + $name = Inflector::humanize(Inflector::singularize($this->params['controller'])); + elseif ($area == 'SANDBOX') + $name = 'Sandbox'; + + if (empty($this->sidemenu['areas'][$area])) + $this->sidemenu['areas'][$area] + = array('enable' => true, 'name' => $name, 'subareas' => array()); + + if (empty($subarea)) + return; + + $subname = $name; + if ($subarea == $this->std_area) + $subname .= ''; + elseif ($subarea == $this->op_area) + //$subname .= '-Ops'; + $subname = 'Actions'; + elseif ($subarea == $this->new_area) + //$subname .= '-New'; + $subname = 'Creation'; + elseif ($subarea == $this->admin_area) + $subname .= '-Admin'; + elseif ($subarea == $this->dev_area) + $subname .= '-Dev'; + else + $subname .= '-' . $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]['subareas'][$subarea]['priorities'][$priority])) + $this->sidemenu['areas'][$area]['subareas'][$subarea]['priorities'][$priority] + = array(); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: sideMenuAreaName + * - Sets the name of the sidemenu area/subarea + */ + + function sideMenuAreaName($name, $area, $subarea = null) { + $this->sideMenuAreaVerify($area, $subarea); + if (empty($subarea)) + $this->sidemenu['areas'][$area]['name'] = $name; + else + $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'); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: sideMenuEnable + * - Enables/Disables an area or subarea of the sidemenu + */ + + function sideMenuEnable($area, $subarea = null, $enable = true) { + $this->sideMenuAreaVerify($area, $subarea); + if (isset($subarea)) + $this->sidemenu['areas'][$area]['subareas'][$subarea]['enable'] = $enable; + else + $this->sidemenu['areas'][$area]['enable'] = $enable; + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: addSideMenuLink + * - Adds another link to the sidemenu area/subarea/priority + */ + + function addSideMenuLink($name, $url, $extra, $area, $subarea = null, $priority = 10) { + if (empty($subarea)) + $subarea = $this->std_area; + $this->sideMenuAreaVerify($area, $subarea); + $this->sidemenu['areas'][$area]['subareas'][$subarea]['priorities'][$priority][] + = array('name' => $name, 'url' => $url) + (empty($extra) ? array() : $extra); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: addDefaultSideMenuLinks + * - Adds the standard links present on all generated pages + */ + + function addDefaultSideMenuLinks() { + + $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'); + $this->addSideMenuLink('Leases', + array('controller' => 'leases', 'action' => 'index'), null, + 'SITE'); + $this->addSideMenuLink('Customers', + array('controller' => 'customers', 'action' => 'index'), null, + 'SITE'); + $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('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); + //array('name' => 'RESET DATA', array('controller' => 'accounts', 'action' => 'reset_data')); + + + $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); + if (!empty($this->params['admin'])) + $this->addSideMenuLink('Assess Charges', + array('controller' => 'leases', 'action' => 'assess_all'), null, + 'SITE', $this->op_area); + + $url_components = array('plugin', 'controller', 'action', 'named'); + if (devbox()) { +/* $sources = ConnectionManager::sourceList(); */ +/* $db = ConnectionManager::getDataSource($sources[0])->config['database']; */ +/* $this->sideMenuAreaName($db, 'SANDBOX', $this->std_area); */ + $this->sideMenuAreaName('DevBox', 'SANDBOX', $this->std_area); + $this->addSideMenuLink('Rebuild DevBox', + array('controller' => 'util', 'action' => 'rebuild_devbox'), null, + 'SANDBOX'); + } + elseif (sandbox()) { + $this->addSideMenuLink('Rebuild Sandbox', + array('controller' => 'util', 'action' => 'rebuild_sandbox'), null, + 'SANDBOX'); + $this->addSideMenuLink('Leave Sandbox', + array('sand_route' => false) + + array_intersect_key($this->params, array_flip($url_components)) + + $this->params['pass'], + null, 'SANDBOX'); + } + else { + $this->addSideMenuLink('Enter Sandbox', + array('sand_route' => true) + + array_intersect_key($this->params, array_flip($url_components)) + + $this->params['pass'], + null, 'SANDBOX'); + } + + // 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() { + } + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * hook: beforeFilter + * - Called just before the action function + */ + + function beforeFilter() { + $this->params['user'] = $this->Permission->User->currentUser(); + $this->params['admin'] = $this->Option->enabled('admin'); + $this->params['dev'] = devbox(); + + if ($this->params['dev'] && !$this->Option->enabled('dev')) + $this->redirect("/"); + + if (!$this->params['dev']) + Configure::write('debug', '0'); + + $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); + } + + $this->authorize("controller.{$this->params['controller']}"); + $this->authorize("action.{$this->params['controller']}.{$this->params['action']}"); + + $this->log('----------------------------------------------------------------------', 'request'); + $this->log('----------------------------------------------------------------------', 'request'); + $this->log($this->params, 'request'); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * hook: beforeRender + * - Called just before rendering the page + */ + + function beforeRender() { // Stupid Cake... our constructor sets admin/dev, // but cake stomps it somewhere along the way // after constructing the CakeError controller. @@ -53,51 +349,56 @@ class AppController extends Controller { $this->params['admin'] = false; } - $menu = array(); - $menu[] = array('name' => 'Common', 'header' => true); - $menu[] = array('name' => 'Site Map', 'url' => array('controller' => 'maps', 'action' => 'view', 1)); - $menu[] = array('name' => 'Units', 'url' => array('controller' => 'units', 'action' => 'index')); - $menu[] = array('name' => 'Leases', 'url' => array('controller' => 'leases', 'action' => 'index')); - $menu[] = array('name' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index')); - $menu[] = array('name' => 'Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit')); + foreach ($this->sidemenu['areas'] AS $aname => &$area) { + if (empty($area['enable'])) + $area = array(); + if (empty($area['subareas'])) + continue; + ksort($area['subareas']); - if ($this->params['admin']) { - $menu[] = array('name' => 'Admin', 'header' => true); - $menu[] = array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index')); - $menu[] = array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index')); - $menu[] = array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index')); - $menu[] = array('name' => 'Tenders', 'url' => array('controller' => 'tenders', 'action' => 'index')); - $menu[] = array('name' => 'Transactions', 'url' => array('controller' => 'transactions', 'action' => 'index')); - $menu[] = array('name' => 'Ldgr Entries', 'url' => array('controller' => 'ledger_entries', 'action' => 'index')); - $menu[] = array('name' => 'Stmt Entries', 'url' => array('controller' => 'statement_entries', 'action' => 'index')); - $menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')); - $menu[] = array('name' => 'Assess Charges', 'url' => array('controller' => 'leases', 'action' => 'assess_all')); + 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(array_diff_key($this->sidemenu['areas'], array('SANDBOX'=>1))) 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); } - if ($this->params['dev']) { - $menu[] = array('name' => 'Development', 'header' => true); - $menu[] = array('name' => 'Un-Nuke', 'url' => '#', 'htmlAttributes' => - array('onclick' => '$(".pr-section").show(); return false;')); - $menu[] = array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')); - //array('name' => 'RESET DATA', 'url' => array('controller' => 'accounts', 'action' => 'reset_data')); - } - - return $menu; + //pr($this->sidemenu); + $this->set('sidemenu', $this->sidemenu); } - function beforeFilter() { - $this->params['dev'] = - (!empty($this->params['dev_route'])); - $this->params['admin'] = - (!empty($this->params['admin_route']) || !empty($this->params['dev_route'])); - if (!$this->params['dev']) - Configure::write('debug', '0'); - } - - function beforeRender() { - $this->set('sidemenu', $this->sideMenuLinks()); - } + /************************************************************************** + ************************************************************************** + ************************************************************************** + * override: redirect + */ function redirect($url, $status = null, $exit = true) { // OK, since the controller will not be able to @@ -127,28 +428,6 @@ class AppController extends Controller { return parent::redirect($url, $status, $exit); } - function reset_data() { - $this->layout = null; - $this->autoLayout = false; - $this->autoRender = false; - Configure::write('debug', '0'); - $script = $_SERVER['DOCUMENT_ROOT'] . '/pmgr/build.cmd'; - echo "

" . date('r') . "\n"; - //echo "

Script: $script" . "\n"; - $db = & $this->Account->getDataSource(); - $script .= ' "' . $db->config['database'] . '"'; - $script .= ' "' . $db->config['login'] . '"'; - $script .= ' "' . $db->config['password'] . '"'; - $handle = popen($script . ' 2>&1', 'r'); - //echo "

Handle: $handle; " . gettype($handle) . "\n"; - echo "

\n";
-    while (($read = fread($handle, 2096))) {
-      echo $read;
-    }
-    echo "
\n"; - pclose($handle); - } - /************************************************************************** ************************************************************************** @@ -156,8 +435,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 @@ -294,6 +579,7 @@ class AppController extends Controller { $xml = preg_replace("//", ">", $xml); echo ("\n
\n$xml\n
\n"); + $this->render_empty(); } } @@ -314,8 +600,8 @@ class AppController extends Controller { // Grouping (which would not be typical) $query['group'] = $this->gridDataCountGroup($params, $model); - // DEBUG PURPOSES ONLY! - $params['count_query'] = $query; + if ($params['debug']) + $params['count_query'] = $query; // Get the number of records prior to pagination return $this->gridDataCountExecute($params, $model, $query); @@ -571,8 +857,8 @@ class AppController extends Controller { isset($params['sidx']) ? $params['sidx'] : null, isset($params['sord']) ? $params['sord'] : null); - // DEBUG PURPOSES ONLY! - $params['query'] = $query; + if ($params['debug']) + $params['query'] = $query; return $this->gridDataRecordsExecute($params, $model, $query); } @@ -695,6 +981,7 @@ class AppController extends Controller { $this->gridDataPostProcessLinks($params, $model, $records, array()); // DEBUG PURPOSES ONLY! + //if ($params['debug']) //$params['records'] = $records; } @@ -772,6 +1059,7 @@ class AppController extends Controller { continue; // DEBUG PURPOSES ONLY! + //if ($params['debug']) //$params['linkrecord'][] = compact('table', 'field', 'id', 'controller', 'record'); $record[$table][$field] = '\n"; } + function authorize($name) { + if ($this->Permission->deny($name)) + $this->UNAUTHORIZED("Unauthorized: $name"); + } + + function UNAUTHORIZED($msg) { + //$this->redirect('controller' => '???', 'action' => 'login'); + //$this->render('/unauthorized'); + $this->set('message', '

' . $msg . '

'); + $this->render_empty(); + } + function INTERNAL_ERROR($msg, $depth = 0) { INTERNAL_ERROR($msg, false, $depth+1); $this->render_empty(); - $this->_stop(); } function render_empty() { - $this->render('/empty'); + echo $this->render('/empty'); + $this->_stop(); } } diff --git a/site/app_helper.php b/site/app_helper.php index 1b5e0b1..04153e6 100644 --- a/site/app_helper.php +++ b/site/app_helper.php @@ -39,7 +39,7 @@ App::import('Core', 'Helper'); class AppHelper extends Helper { function url($url = null, $full = false) { - foreach(array('admin_route', 'dev_route') AS $mod) { + foreach(array('sand_route', 'dev_route') AS $mod) { if (isset($this->params[$mod]) && is_array($url) && !isset($url[$mod])) $url[$mod] = $this->params[$mod]; } diff --git a/site/app_model.php b/site/app_model.php index 7eb7f10..d83a8fe 100644 --- a/site/app_model.php +++ b/site/app_model.php @@ -42,6 +42,10 @@ class AppModel extends Model { var $useNullForEmpty = true; var $formatDateFields = true; + // Loaded related models with no association + var $knows = array(); + var $app_knows = array('Option'); + // Default Log Level, if not specified at the function level var $default_log_level = 5; @@ -58,16 +62,35 @@ class AppModel extends Model { var $max_log_level; - // REVISIT : 20090730 - // Why is this constructor crashing? - // Clearly it's in some sort of infinite - // loop, but it seems the correct way - // to have a constructor call the parent... + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: __construct + */ + + function __construct($id = false, $table = null, $ds = null) { + parent::__construct($id, $table, $ds); + + $this->knows = array_merge($this->app_knows, $this->knows); + //$this->pr(1, array('knows' => $this->knows)); + foreach ($this->knows as $alias => $modelName) { + if (is_numeric($alias)) { + $alias = $modelName; + } + + // Don't overwrite any existing alias + if (!empty($this->{$alias}) || get_class($this) == $alias) + continue; + + $model = array('class' => $modelName, 'alias' => $alias); + if (PHP5) { + $this->{$alias} = ClassRegistry::init($model); + } else { + $this->{$alias} =& ClassRegistry::init($model); + } + } + } -/* function __construct() { */ -/* parent::__construct(); */ -/* $this->prClassLevel(5, 'Model'); */ -/* } */ /************************************************************************** ************************************************************************** @@ -81,7 +104,8 @@ class AppModel extends Model { $caller = array_shift($trace); $caller = array_shift($trace); if (empty($class)) - $class = $caller['class']; + $class = get_class($this); + $this->pr(50, compact('class', 'level')); $this->class_log_level[$class] = $level; } @@ -90,9 +114,10 @@ class AppModel extends Model { $caller = array_shift($trace); $caller = array_shift($trace); if (empty($class)) - $class = $caller['class']; + $class = get_class($this); if (empty($function)) $function = $caller['function']; + $this->pr(50, compact('class', 'function', 'level')); $this->function_log_level["{$class}-{$function}"] = $level; } @@ -280,7 +305,9 @@ class AppModel extends Model { if (preg_match("/^_/", $name) && !$all) unset($vars[$name]); } - pr($vars); + //$vars['class'] = get_class_vars(get_class($this)); + + $this->pr(1, $vars); } @@ -480,9 +507,9 @@ class AppModel extends Model { return date('Y-m-d', strtotime($dateString)); } - function INTERNAL_ERROR($msg, $depth = 0) { - INTERNAL_ERROR($msg, false, $depth+1); - echo $this->requestAction(array('controller' => 'accounts', + function INTERNAL_ERROR($msg, $depth = 0, $force_stop = false) { + INTERNAL_ERROR($msg, $force_stop, $depth+1); + echo $this->requestAction(array('controller' => 'util', 'action' => 'render_empty'), array('return', 'bare' => false) ); diff --git a/site/build_devbox.cmd b/site/build_devbox.cmd new file mode 100644 index 0000000..79b99d5 --- /dev/null +++ b/site/build_devbox.cmd @@ -0,0 +1,5 @@ +@echo off +mysqldump --user=pmgr --password=pmgruser --opt property_manager > H:\pmgr_dev.sql +mysql --user=pmgr --password=pmgruser --database=pmgr_dev < H:\pmgr_dev.sql +del H:\pmgr_dev.sql +echo Build Complete! diff --git a/site/build_sandbox.cmd b/site/build_sandbox.cmd new file mode 100644 index 0000000..3143b81 --- /dev/null +++ b/site/build_sandbox.cmd @@ -0,0 +1,5 @@ +@echo off +mysqldump --user=pmgr --password=pmgruser --opt property_manager > H:\pmgr_sand.sql +mysql --user=pmgr --password=pmgruser --database=pmgr_sand < H:\pmgr_sand.sql +del H:\pmgr_sand.sql +echo Build Complete! diff --git a/site/config/bootstrap.php b/site/config/bootstrap.php index 06af98a..d03f0e3 100644 --- a/site/config/bootstrap.php +++ b/site/config/bootstrap.php @@ -32,7 +32,29 @@ * */ +function sandbox() { + $r = Router::requestRoute(); + return !empty($r[3]['sand_route']); +} + +function devbox() { + $r = Router::requestRoute(); + return !empty($r[3]['dev_route']); +} + +function server_request_var($var) { + if (preg_match("/^HTTP_ACCEPT|REMOTE_PORT/", $var)) + return false; + return (preg_match("/^HTTP|REQUEST|REMOTE/", $var)); +} + function INTERNAL_ERROR($message, $exit = true, $drop = 0) { + $O = new Object(); + for ($i=0; $i<3; ++$i) { + $O->log(str_repeat("\\", 80)); + $O->log(str_repeat("/", 80)); + } + $O->log("INTERNAL ERROR: $message"); echo '
' . "\n"; echo '

INTERNAL ERROR:

' . "\n"; echo '

' . $message . '

' . "\n"; @@ -40,8 +62,10 @@ function INTERNAL_ERROR($message, $exit = true, $drop = 0) { echo '
It is a problem within the application itself and should be reported to the administrator.' . "\n"; // Print out the entire stack trace + $O->log(str_repeat("-", 30)); + $O->log("Stack:"); echo '
' . "\nStack Trace:\n"; - echo '
    ' . "\n"; + echo '
      ' . "\n"; $trace = array_slice(debug_backtrace(false), $drop); for ($i = 0; $i < count($trace); ++$i) { $bline = $trace[$i]['line']; @@ -57,14 +81,36 @@ function INTERNAL_ERROR($message, $exit = true, $drop = 0) { $bclas = null; } + $O->log(" $bfile:$bline (" . ($bclas ? "$bclas::$bfunc" : "entry point") . ")"); echo("
    1. $bfile:$bline (" . ($bclas ? "$bclas::$bfunc" : "entry point") . ")
    2. \n"); } echo "
    \n"; + $O->log(str_repeat("-", 30)); + $O->log("HTTP Request:"); echo '
    ' . "\nHTTP Request:\n"; - echo '

    ' . "\n";
    -  print_r($_REQUEST);
    -  echo "\n
    \n"; + echo '
      ' . "\n"; + foreach($_REQUEST AS $k => $v) { + $O->log(sprintf(" %-20s => %s", $k, $v)); + echo("
    • $k => $v
    • \n"); + } + echo "
    \n"; + + $O->log(str_repeat("-", 30)); + $O->log("Server:"); + $SRV = array_intersect_key($_SERVER, array_flip(array_filter(array_keys($_SERVER), 'server_request_var'))); + echo '
    ' . "\nServer:\n"; + echo '
      ' . "\n"; + foreach($SRV AS $k => $v) { + if ($k == 'REQUEST_TIME') + $v = date('c', $v); + $O->log(sprintf(" %-20s => %s", $k, $v)); + echo("
    • $k => $v
    • \n"); + } + echo "
    \n"; + + echo '
    ' . "\n"; + echo date('c') . "
    \n"; echo '
'; if ($exit) 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 1bccd6c..6cdddfa 100644 --- a/site/config/database.php +++ b/site/config/database.php @@ -10,5 +10,12 @@ class DATABASE_CONFIG { 'database' => 'property_manager', 'prefix' => 'pmgr_', ); + + function __construct() { + if (devbox()) + $this->default['database'] = 'pmgr_dev'; + if (sandbox()) + $this->default['database'] = 'pmgr_sand'; + } } ?> \ No newline at end of file diff --git a/site/config/routes.php b/site/config/routes.php index 01d09ac..6135fdd 100644 --- a/site/config/routes.php +++ b/site/config/routes.php @@ -37,15 +37,15 @@ $default_path = array('controller' => 'maps', 'action' => 'view', '1'); Router::connect('/', $default_path); /* - * Route for admin functionality + * Route for sandbox functionality */ -Router::connect('/admin', - array('admin_route' => true) + $default_path); -Router::connect('/admin/:controller/:action/*', - array('admin_route' => true, 'action' => null)); +Router::connect('/sand', + array('sand_route' => true) + $default_path); +Router::connect('/sand/:controller/:action/*', + array('sand_route' => true, 'action' => null)); /* - * Route for development functionality + * Route for developement functionality */ Router::connect('/dev', array('dev_route' => true) + $default_path); diff --git a/site/controllers/accounts_controller.php b/site/controllers/accounts_controller.php index 0554f26..c7d1a77 100644 --- a/site/controllers/accounts_controller.php +++ b/site/controllers/accounts_controller.php @@ -2,30 +2,38 @@ class AccountsController extends AppController { - var $uses = array('Account', 'LedgerEntry'); - - var $sidemenu_links = - array(array('name' => 'Accounts', 'header' => true), - array('name' => 'All', 'url' => array('controller' => 'accounts', 'action' => 'all')), - array('name' => 'Asset', 'url' => array('controller' => 'accounts', 'action' => 'asset')), - array('name' => 'Liability', 'url' => array('controller' => 'accounts', 'action' => 'liability')), - array('name' => 'Equity', 'url' => array('controller' => 'accounts', 'action' => 'equity')), - array('name' => 'Income', 'url' => array('controller' => 'accounts', 'action' => 'income')), - array('name' => 'Expense', 'url' => array('controller' => 'accounts', 'action' => 'expense')), - ); - /************************************************************************** ************************************************************************** ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); + + 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); } - + /************************************************************************** ************************************************************************** ************************************************************************** @@ -39,7 +47,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 all() { $this->gridView('All Accounts', 'all'); } /************************************************************************** @@ -90,9 +98,8 @@ class AccountsController extends AppController { $conditions[] = array('Account.type' => strtoupper($params['action'])); } - // REVISIT : 20090811 - // No security issues have been worked out yet - $conditions[] = array('Account.level >=' => 10); + $conditions[] = array('Account.level >=' => + $this->Permission->level('controller.accounts')); return $conditions; } @@ -173,9 +180,8 @@ class AccountsController extends AppController { ('order' => array('CloseTransaction.stamp' => 'DESC'))), ), 'conditions' => array(array('Account.id' => $id), - // REVISIT : 20090811 - // No security issues have been worked out yet - array('Account.level >=' => 10), + array('Account.level >=' => + $this->Permission->level('controller.accounts')), ), ) ); @@ -189,12 +195,12 @@ class AccountsController extends AppController { $stats = $this->Account->stats($id, true); $stats = $stats['Ledger']; - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); - $this->sidemenu_links[] = - array('name' => 'New Ledger', 'url' => array('action' => 'newledger', $id)); - $this->sidemenu_links[] = - array('name' => 'Collected', 'url' => array('action' => 'collected', $id)); + $this->addSideMenuLink('New Ledger', + array('action' => 'newledger', $id), null, + 'ACTION', $this->admin_area); + $this->addSideMenuLink('Collected', + array('action' => 'collected', $id), null, + '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 ea2e20d..29b740c 100644 --- a/site/controllers/contacts_controller.php +++ b/site/controllers/contacts_controller.php @@ -2,19 +2,7 @@ class ContactsController extends AppController { - var $sidemenu_links = array(); - /************************************************************************** - ************************************************************************** - ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu - */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); - } - - /************************************************************************** ************************************************************************** ************************************************************************** @@ -35,19 +23,34 @@ 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); - if ($index === 'Contact.last_name') { - $order[] = 'Contact.first_name ' . $direction; - } - if ($index === 'Contact.first_name') { - $order[] = 'Contact.last_name ' . $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[] = 'Contact.last_name ' . $direction; + $order[] = 'Contact.first_name ' . $direction; + return $order; } function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { - $links['Contact'] = array('id'); + $links['Contact'] = array('display_name'); return parent::gridDataPostProcessLinks($params, $model, $records, $links); } @@ -78,13 +81,9 @@ class ContactsController extends AppController { )); // Set up dynamic menu items - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); - - $this->sidemenu_links[] = - array('name' => 'Edit', - 'url' => array('action' => 'edit', - $id)); + $this->addSideMenuLink('Edit', + array('action' => 'edit', $id), null, + 'ACTION'); // Prepare to render. $title = 'Contact: ' . $contact['Contact']['display_name']; diff --git a/site/controllers/customers_controller.php b/site/controllers/customers_controller.php index 5244feb..a090377 100644 --- a/site/controllers/customers_controller.php +++ b/site/controllers/customers_controller.php @@ -1,28 +1,34 @@ 'Customers', 'header' => true), - array('name' => 'Current', 'url' => array('controller' => 'customers', 'action' => 'current')), - array('name' => 'Past', 'url' => array('controller' => 'customers', 'action' => 'past')), - array('name' => 'All', 'url' => array('controller' => 'customers', 'action' => 'all')), - array('name' => 'Add Customer', 'url' => array('controller' => 'customers', 'action' => 'add')), - ); - - //var $components = array('RequestHandler'); /************************************************************************** ************************************************************************** ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); + + 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, */ +/* 'CONTROLLER', $this->new_area); */ } - + /************************************************************************** ************************************************************************** ************************************************************************** @@ -81,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; } @@ -111,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'; @@ -219,52 +239,71 @@ 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->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); - - $this->sidemenu_links[] = - array('name' => 'Edit', - 'url' => array('action' => 'edit', - $id)); - - $this->sidemenu_links[] = - array('name' => 'Move-In', - 'url' => array('action' => 'move_in', - $id)); - -/* if ($show_moveout) { */ -/* $this->sidemenu_links[] = */ -/* array('name' => 'Move-Out', */ -/* 'url' => array('action' => 'move_out', */ -/* $id)); */ -/* } */ if ($show_payment || $outstanding_balance > 0) - $this->sidemenu_links[] = - array('name' => 'New Receipt', - 'url' => array('action' => 'receipt', - $id)); + $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->sidemenu_links[] = - array('name' => 'Write-Off', - 'url' => array('action' => 'bad_debt', - $id)); + $this->addSideMenuLink('Write-Off', + array('action' => 'bad_debt', $id), null, + 'ACTION'); if ($outstanding_balance < 0) - $this->sidemenu_links[] = - array('name' => 'Issue Refund', - 'url' => array('action' => 'refund', $id)); + $this->addSideMenuLink('Issue Refund', + array('action' => 'refund', $id), null, + 'ACTION'); + + $this->addSideMenuLink('Edit', + array('action' => 'edit', $id), null, + 'ACTION'); // Prepare to render. $title = 'Customer: ' . $customer['Customer']['name']; @@ -322,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) { @@ -385,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/double_entries_controller.php b/site/controllers/double_entries_controller.php index 42a61a9..479fb2c 100644 --- a/site/controllers/double_entries_controller.php +++ b/site/controllers/double_entries_controller.php @@ -2,20 +2,7 @@ class DoubleEntriesController extends AppController { - var $sidemenu_links = array(); - - /************************************************************************** - ************************************************************************** - ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu - */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); - } - - /************************************************************************** ************************************************************************** ************************************************************************** @@ -47,6 +34,9 @@ class DoubleEntriesController extends AppController { array('contain' => array('Ledger' => array('Account')), 'conditions' => array('DebitEntry.id' => $entry['DebitEntry']['id']), )); + $entry['Ledger']['link'] = + $entry['Ledger']['Account']['level'] >= + $this->Permission->level('controller.accounts'); $entry['DebitLedger'] = $entry['Ledger']; unset($entry['Ledger']); @@ -55,6 +45,9 @@ class DoubleEntriesController extends AppController { array('contain' => array('Ledger' => array('Account')), 'conditions' => array('CreditEntry.id' => $entry['CreditEntry']['id']), )); + $entry['Ledger']['link'] = + $entry['Ledger']['Account']['level'] >= + $this->Permission->level('controller.accounts'); $entry['CreditLedger'] = $entry['Ledger']; unset($entry['Ledger']); diff --git a/site/controllers/leases_controller.php b/site/controllers/leases_controller.php index ed501c7..ab49c71 100644 --- a/site/controllers/leases_controller.php +++ b/site/controllers/leases_controller.php @@ -2,26 +2,32 @@ class LeasesController extends AppController { - var $sidemenu_links = - array(array('name' => 'Leases', 'header' => true), - array('name' => 'Active', 'url' => array('controller' => 'leases', 'action' => 'active')), - array('name' => 'Closed', 'url' => array('controller' => 'leases', 'action' => 'closed')), - array('name' => 'Delinquent', 'url' => array('controller' => 'leases', 'action' => 'delinquent')), - array('name' => 'All', 'url' => array('controller' => 'leases', 'action' => 'all')), - ); - /************************************************************************** ************************************************************************** ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); + + function addGridViewSideMenuLinks() { + parent::addGridViewSideMenuLinks(); + + $this->addSideMenuLink('Active', + array('controller' => 'leases', 'action' => 'active'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Closed', + array('controller' => 'leases', 'action' => 'closed'), null, + 'CONTROLLER'); + $this->addSideMenuLink('Delinquent', + array('controller' => 'leases', 'action' => 'delinquent'), null, + 'CONTROLLER'); + $this->addSideMenuLink('All', + array('controller' => 'leases', 'action' => 'all'), null, + 'CONTROLLER'); } - + /************************************************************************** ************************************************************************** ************************************************************************** @@ -29,11 +35,11 @@ class LeasesController extends AppController { * - Generate a listing of leases */ - function index() { $this->all(); } - function active() { $this->gridView('Active 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', 'all'); } + function all() { $this->gridView('All Leases'); } /************************************************************************** @@ -177,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'); } @@ -387,6 +394,10 @@ class LeasesController extends AppController { $this->set(compact('default_late')); if ($type === 'move-in') { + // Make sure we have a valid lease that we're moving in + if (empty($lease)) + $this->redirect(array('action' => 'index')); + $movein = array(); $movein['time'] = strtotime($lease['Lease']['movein_date']); $movein['effective_time'] = strtotime($lease['Lease']['movein_date']); @@ -467,28 +478,21 @@ class LeasesController extends AppController { // yet still have an outstanding balance. This can happen if someone // were to reverse charges, or if a payment should come back NSF. if (!isset($lease['Lease']['close_date']) || $outstanding_balance > 0) { - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); - if (!isset($lease['Lease']['moveout_date'])) - $this->sidemenu_links[] = - array('name' => 'Move-Out', 'url' => array('action' => 'move_out', - $id)); + $this->addSideMenuLink('Move-Out', + array('action' => 'move_out', $id), null, + 'ACTION'); if (!isset($lease['Lease']['close_date'])) - $this->sidemenu_links[] = - array('name' => 'New Invoice', 'url' => array('action' => 'invoice', - $id)); + $this->addSideMenuLink('New Invoice', + array('action' => 'invoice', $id), null, + 'ACTION'); - $this->sidemenu_links[] = - array('name' => 'New Receipt', 'url' => array('controller' => 'customers', - 'action' => 'receipt', - $lease['Customer']['id'])); - -/* if ($outstanding_balance < 0) */ -/* $this->sidemenu_links[] = */ -/* array('name' => 'Transfer Credit to Customer', */ -/* 'url' => array('action' => 'promote_surplus', $id)); */ + $this->addSideMenuLink('New Receipt', + array('controller' => 'customers', + 'action' => 'receipt', + $lease['Customer']['id']), null, + 'ACTION'); // REVISIT : // Not allowing refund to be issued from the lease, as @@ -500,19 +504,19 @@ class LeasesController extends AppController { $this->INTERNAL_ERROR("Should not have a customer lease credit."); /* if ($outstanding_balance < 0) */ -/* $this->sidemenu_links[] = */ -/* array('name' => 'Issue Refund', */ -/* 'url' => array('action' => 'refund', $id)); */ +/* $this->addSideMenuLink('Issue Refund', */ +/* array('action' => 'refund', $id), null, */ +/* 'ACTION'); */ if (isset($lease['Lease']['moveout_date']) && $outstanding_balance > 0) - $this->sidemenu_links[] = - array('name' => 'Write-Off', 'url' => array('action' => 'bad_debt', - $id)); + $this->addSideMenuLink('Write-Off', + array('action' => 'bad_debt', $id), null, + 'ACTION'); if ($this->Lease->closeable($id)) - $this->sidemenu_links[] = - array('name' => 'Close', 'url' => array('action' => 'close', - $id)); + $this->addSideMenuLink('Close', + array('action' => 'close', $id), null, + 'ACTION'); } // Prepare to render diff --git a/site/controllers/ledger_entries_controller.php b/site/controllers/ledger_entries_controller.php index d1e7805..be78cc7 100644 --- a/site/controllers/ledger_entries_controller.php +++ b/site/controllers/ledger_entries_controller.php @@ -2,19 +2,6 @@ class LedgerEntriesController extends AppController { - var $sidemenu_links = array(); - - - /************************************************************************** - ************************************************************************** - ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu - */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); - } - /************************************************************************** ************************************************************************** @@ -130,8 +117,12 @@ class LedgerEntriesController extends AppController { function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { $links['LedgerEntry'] = array('id'); $links['Transaction'] = array('id'); - $links['Ledger'] = array('id'); - $links['Account'] = array('controller' => 'accounts', 'name'); + // REVISIT : 20090827 + // Need to take 'level' into account + if ($this->Permission->allow('controller.accounts')) { + $links['Ledger'] = array('id'); + $links['Account'] = array('name'); + } $links['Tender'] = array('name'); return parent::gridDataPostProcessLinks($params, $model, $records, $links); } @@ -157,12 +148,8 @@ class LedgerEntriesController extends AppController { array('fields' => array('id', 'sequence', 'name'), 'Account' => array('fields' => array('id', 'name', 'type'), - 'conditions' => - // REVISIT : 20090811 - // No security issues have been worked out yet - array('Account.level >=' => 5), - ), - ), + ), + ), 'Tender' => array('fields' => array('id', 'name'), diff --git a/site/controllers/ledgers_controller.php b/site/controllers/ledgers_controller.php index 5aa073b..3cfb46a 100644 --- a/site/controllers/ledgers_controller.php +++ b/site/controllers/ledgers_controller.php @@ -2,25 +2,29 @@ class LedgersController extends AppController { - var $sidemenu_links = - array(array('name' => 'Ledgers', 'header' => true), - array('name' => 'Current', 'url' => array('controller' => 'ledgers', 'action' => 'current')), - array('name' => 'Closed', 'url' => array('controller' => 'ledgers', 'action' => 'closed')), - array('name' => 'All', 'url' => array('controller' => 'ledgers', 'action' => 'all')), - ); - /************************************************************************** ************************************************************************** ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); + + 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'); } - + /************************************************************************** ************************************************************************** ************************************************************************** @@ -82,32 +86,32 @@ class LedgersController extends AppController { $conditions[] = array('Ledger.close_transaction_id !=' => null); } - // REVISIT : 20090811 - // No security issues have been worked out yet - $conditions[] = array('Account.level >=' => 10); + $conditions[] = array('Account.level >=' => + $this->Permission->level('controller.accounts')); return $conditions; } function gridDataOrder(&$params, &$model, $index, $direction) { - $id_sequence = false; - if ($index === 'id_sequence') { - $id_sequence = true; - $index = 'Ledger.account_id'; - } - $order = parent::gridDataOrder($params, $model, $index, $direction); - if ($id_sequence) { - $order[] = 'Ledger.sequence ' . $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[] = 'Account.name ' . $direction; + $order[] = 'Ledger.sequence ' . $direction; return $order; } function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { - $links['Ledger'] = array('id_sequence'); - $links['Account'] = array('name'); + // REVISIT : 20090827 + // Need to take 'level' into account + if ($this->Permission->allow('controller.accounts')) { + $links['Ledger'] = array('sequence'); + $links['Account'] = array('name'); + } return parent::gridDataPostProcessLinks($params, $model, $records, $links); } @@ -127,9 +131,8 @@ class LedgersController extends AppController { 'Account', ), 'conditions' => array(array('Ledger.id' => $id), - // REVISIT : 20090811 - // No security issues have been worked out yet - array('Account.level >=' => 10), + array('Account.level >=' => + $this->Permission->level('controller.accounts')), ), ) ); 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/statement_entries_controller.php b/site/controllers/statement_entries_controller.php index b260699..c14333f 100644 --- a/site/controllers/statement_entries_controller.php +++ b/site/controllers/statement_entries_controller.php @@ -2,20 +2,7 @@ class StatementEntriesController extends AppController { - var $sidemenu_links = array(); - - /************************************************************************** - ************************************************************************** - ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu - */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); - } - - /************************************************************************** ************************************************************************** ************************************************************************** @@ -121,11 +108,10 @@ class StatementEntriesController extends AppController { if (isset($customer_id)) $conditions[] = array('StatementEntry.customer_id' => $customer_id); - if (isset($statement_entry_id)) { + if (isset($statement_entry_id)) $conditions[] = array('OR' => array(array('ChargeEntry.id' => $statement_entry_id), array('DisbursementEntry.id' => $statement_entry_id))); - } if ($params['action'] === 'unreconciled') { $query = array('conditions' => $conditions); @@ -145,7 +131,10 @@ class StatementEntriesController extends AppController { function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { $links['StatementEntry'] = array('id'); $links['Transaction'] = array('id'); - $links['Account'] = array('name'); + // REVISIT : 20090827 + // Need to take 'level' into account + if ($this->Permission->allow('controller.accounts')) + $links['Account'] = array('name'); $links['Customer'] = array('name'); $links['Lease'] = array('number'); $links['Unit'] = array('name'); @@ -266,15 +255,12 @@ class StatementEntriesController extends AppController { ('first', array('contain' => array ('Transaction' => array('fields' => array('id', 'type', 'stamp')), - 'Account' => array('id', 'name', 'type'), + 'Account' => array('id', 'name', 'type', 'level'), 'Customer' => array('fields' => array('id', 'name')), - 'Lease' => array('fields' => array('id')), + 'Lease' => array('fields' => array('id', 'number')), ), 'conditions' => array(array('StatementEntry.id' => $id), - // REVISIT : 20090811 - // No security issues have been worked out yet - array('Account.level >=' => 5) ), )); @@ -283,6 +269,10 @@ class StatementEntriesController extends AppController { $this->redirect(array('controller' => 'accounts', 'action'=>'index')); } + $entry['Account']['link'] = + $entry['Account']['level'] >= + $this->Permission->level('controller.accounts'); + $stats = $this->StatementEntry->stats($id); if (in_array(strtoupper($entry['StatementEntry']['type']), $this->StatementEntry->debitTypes())) @@ -293,24 +283,16 @@ class StatementEntriesController extends AppController { if (strtoupper($entry['StatementEntry']['type']) === 'CHARGE') { - $reversable = $this->StatementEntry->reversable($id); - // Set up dynamic menu items - if ($reversable || $stats['balance'] > 0) - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); - - if ($reversable) - $this->sidemenu_links[] = - array('name' => 'Reverse', - 'url' => array('action' => 'reverse', - $id)); + if ($this->StatementEntry->reversable($id)) + $this->addSideMenuLink('Reverse', + array('action' => 'reverse', $id), null, + 'ACTION'); if ($stats['balance'] > 0) - $this->sidemenu_links[] = - array('name' => 'Waive Balance', - 'url' => array('action' => 'waive', - $id)); + $this->addSideMenuLink('Waive Balance', + array('action' => 'waive', $id), null, + 'ACTION'); } // Prepare to render. diff --git a/site/controllers/tenders_controller.php b/site/controllers/tenders_controller.php index 8e8be18..53619d2 100644 --- a/site/controllers/tenders_controller.php +++ b/site/controllers/tenders_controller.php @@ -2,20 +2,7 @@ class TendersController extends AppController { - var $sidemenu_links = array(); - - /************************************************************************** - ************************************************************************** - ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu - */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); - } - - /************************************************************************** ************************************************************************** ************************************************************************** @@ -75,7 +62,7 @@ class TendersController extends AppController { function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { $links['Tender'] = array('name', 'id'); $links['Customer'] = array('name'); - $links['TenderType'] = array('name'); + //$links['TenderType'] = array('name'); return parent::gridDataPostProcessLinks($params, $model, $records, $links); } @@ -163,17 +150,6 @@ class TendersController extends AppController { )); - // Set up dynamic menu items - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); - - // Watch out for the special "Closing" entries - if (!empty($tender['TenderType']['id'])) - $this->sidemenu_links[] = - array('name' => 'Edit', - 'url' => array('action' => 'edit', - $id)); - 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. @@ -181,12 +157,18 @@ class TendersController extends AppController { // (or if we're in development mode) && (!empty($tender['TenderType']['data1_name']) || !empty($this->params['dev'])) ) { - $this->sidemenu_links[] = - array('name' => 'NSF', - 'url' => array('action' => 'nsf', - $id)); + $this->addSideMenuLink('NSF', + array('action' => 'nsf', $id), null, + '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 eca9677..b14341d 100644 --- a/site/controllers/transactions_controller.php +++ b/site/controllers/transactions_controller.php @@ -4,26 +4,38 @@ class TransactionsController extends AppController { var $components = array('RequestHandler'); - var $sidemenu_links = - array(array('name' => 'Transactions', 'header' => true), - array('name' => 'All', 'url' => array('controller' => 'transactions', 'action' => 'all')), - array('name' => 'Invoices', 'url' => array('controller' => 'transactions', 'action' => 'invoice')), - array('name' => 'Receipts', 'url' => array('controller' => 'transactions', 'action' => 'receipt')), - array('name' => 'Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit')), - ); - /************************************************************************** ************************************************************************** ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); + + 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); } - + /************************************************************************** ************************************************************************** ************************************************************************** @@ -36,10 +48,9 @@ class TransactionsController extends AppController { function invoice() { $this->gridView('Invoices'); } function receipt() { $this->gridView('Receipts'); } function deposit() { - $this->sidemenu_links = array - (array('name' => 'Operations', 'header' => true), - array('name' => 'New Deposit', 'url' => array('controller' => 'tenders', - 'action' => 'deposit'))); +/* $this->addSideMenuLink('New Deposit', */ +/* array('controller' => 'tenders', 'action' => 'deposit'), null, */ +/* 'CONTROLLER', $this->new_area); */ $this->gridView('Deposits'); } @@ -84,10 +95,6 @@ class TransactionsController extends AppController { if (in_array($params['action'], array('invoice', 'receipt', 'deposit'))) $conditions[] = array('Transaction.type' => strtoupper($params['action'])); - // REVISIT : 20090811 - // No security issues have been worked out yet - $conditions[] = array('Account.level >=' => 5); - return $conditions; } @@ -105,7 +112,7 @@ class TransactionsController extends AppController { * - handles the creation of a charge invoice */ - function postInvoice() { + function postInvoice($redirect = true) { if (!$this->RequestHandler->isPost()) { echo('

THIS IS NOT A POST FOR SOME REASON

'); return; @@ -120,6 +127,17 @@ class TransactionsController extends AppController { die("

INVOICE FAILED

"); } + if ($redirect) { + if (!empty($this->data['Customer']['id'])) + $this->redirect(array('controller' => 'customers', + 'action' => 'receipt', + $this->data['Customer']['id'])); + else + $this->redirect(array('controller' => 'leases', + 'action' => 'view', + $this->data['Lease']['id'])); + } + $this->layout = null; $this->autoLayout = false; $this->autoRender = false; @@ -133,7 +151,7 @@ class TransactionsController extends AppController { * - handles the creation of a receipt */ - function postReceipt() { + function postReceipt($redirect = true) { if (!$this->RequestHandler->isPost()) { echo('

THIS IS NOT A POST FOR SOME REASON

'); return; @@ -157,6 +175,11 @@ class TransactionsController extends AppController { die("

RECEIPT FAILED

"); } + if ($redirect) + $this->redirect(array('controller' => 'customers', + 'action' => 'view', + $this->data['Customer']['id'])); + $this->layout = null; $this->autoLayout = false; $this->autoRender = false; @@ -269,7 +292,7 @@ class TransactionsController extends AppController { $this->Session->setFlash(__('Unable to Create Deposit', true)); $this->redirect(array('controller' => 'tenders', 'action'=>'deposit')); } - + // Present the deposit slip to the user $this->redirect(array('controller' => 'transactions', 'action' => 'deposit_slip', @@ -370,9 +393,11 @@ class TransactionsController extends AppController { * irreversibly destroys the data. It is not for normal use. */ - function destroy($id = null) { + function destroy($id) { + $this->Transaction->id = $id; + $customer_id = $this->Transaction->field('customer_id'); $this->Transaction->destroy($id); - //$this->redirect(array('action' => 'index')); + $this->redirect(array('controller' => 'customers', 'action' => 'view', $customer_id)); } @@ -388,42 +413,35 @@ class TransactionsController extends AppController { ('first', array('contain' => array(// Models - 'Account(id,name)', - 'Ledger(id,name)', + 'Account(id,name,level)', + 'Ledger(id,sequence)', 'NsfTender(id,name)', ), 'conditions' => array(array('Transaction.id' => $id), - // REVISIT : 20090811 - // No security issues have been worked out yet - array('OR' => - array(array('Account.level >=' => 5), - array('Account.id' => null))), ), )); - // REVISIT : 20090815 - // for debug purposes only (pr output) - $this->Transaction->stats($id); - if (empty($transaction)) { $this->Session->setFlash(__('Invalid Item.', true)); $this->redirect(array('action'=>'index')); } - if ($transaction['Transaction']['type'] === 'DEPOSIT' || $this->params['dev']) { - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); + $transaction['Account']['link'] = + $transaction['Account']['level'] >= + $this->Permission->level('controller.accounts'); - if ($transaction['Transaction']['type'] === 'DEPOSIT') - $this->sidemenu_links[] = - array('name' => 'View Slip', 'url' => array('action' => 'deposit_slip', $id)); - if ($this->params['dev']) - $this->sidemenu_links[] = - array('name' => 'Destroy', 'url' => array('action' => 'destroy', $id), - 'confirmMessage' => ("This may leave the database in an unstable state." . - " Do NOT do this unless you know what you're doing." . - " Proceed anyway?")); - } + if ($transaction['Transaction']['type'] === 'DEPOSIT') + $this->addSideMenuLink('View Slip', + array('action' => 'deposit_slip', $id), null, + 'ACTION'); + + $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->admin_area); // OK, prepare to render. $title = 'Transaction #' . $transaction['Transaction']['id']; @@ -440,15 +458,12 @@ class TransactionsController extends AppController { */ function deposit_slip($id) { - // Build a container for the deposit slip data - $deposit = array('types' => array()); - - $this->id = $id; - $deposit += - $this->Transaction->find('first', array('contain' => false)); + // Find the deposit transaction + $this->Transaction->id = $id; + $deposit = $this->Transaction->find('first', array('contain' => false)); // Get a summary of all forms of tender in the deposit - $result = $this->Transaction->find + $tenders = $this->Transaction->find ('all', array('link' => array('DepositTender' => array('fields' => array(), @@ -463,16 +478,17 @@ class TransactionsController extends AppController { 'group' => 'TenderType.id', )); - if (empty($result)) { - die(); + // Verify the deposit exists, and that something was actually deposited + if (empty($deposit) || empty($tenders)) { $this->Session->setFlash(__('Invalid Deposit.', true)); $this->redirect(array('action'=>'deposit')); } // Add the summary to our deposit slip data container - foreach ($result AS $type) { - $deposit['types'][$type['TenderType']['id']] = - $type['TenderType'] + $type[0]; + $deposit['types'] = array(); + foreach ($tenders AS $tender) { + $deposit['types'][$tender['TenderType']['id']] = + $tender['TenderType'] + $tender[0]; } $deposit_total = 0; @@ -482,10 +498,9 @@ class TransactionsController extends AppController { if ($deposit['Transaction']['amount'] != $deposit_total) $this->INTERNAL_ERROR("Deposit items do not add up to deposit slip total"); - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); - $this->sidemenu_links[] = - array('name' => 'View Transaction', 'url' => array('action' => 'view', $id)); + $this->addSideMenuLink('View', + array('action' => 'view', $id), null, + 'ACTION'); $title = 'Deposit Slip'; $this->set(compact('title', 'deposit')); 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 50f15a0..1cc50f2 100644 --- a/site/controllers/units_controller.php +++ b/site/controllers/units_controller.php @@ -2,26 +2,38 @@ class UnitsController extends AppController { - var $sidemenu_links = - array(array('name' => 'Units', 'header' => true), - array('name' => 'Occupied', 'url' => array('controller' => 'units', 'action' => 'occupied')), - array('name' => 'Vacant', 'url' => array('controller' => 'units', 'action' => 'vacant')), - array('name' => 'Unavailable', 'url' => array('controller' => 'units', 'action' => 'unavailable')), - array('name' => 'All', 'url' => array('controller' => 'units', 'action' => 'all')), - ); - /************************************************************************** ************************************************************************** ************************************************************************** - * override: sideMenuLinks - * - Generates controller specific links for the side menu + * override: addGridViewSideMenuLinks + * - Adds grid view navigation side menu links */ - function sideMenuLinks() { - return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); + + 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'); } - + /************************************************************************** ************************************************************************** ************************************************************************** @@ -33,6 +45,8 @@ 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'); } @@ -81,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)); } @@ -100,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; } @@ -139,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)); } @@ -189,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'); } + + /************************************************************************** ************************************************************************** ************************************************************************** @@ -232,39 +268,66 @@ class UnitsController extends AppController { $outstanding_deposit = $this->Unit->Lease->securityDepositBalance($unit['CurrentLease']['id']); } - // Set up dynamic menu items - $this->sidemenu_links[] = - array('name' => 'Operations', 'header' => true); + // 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'); - $this->sidemenu_links[] = - array('name' => 'Edit', 'url' => array('action' => 'edit', - $id)); + // 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 (isset($unit['CurrentLease']['id']) && - !isset($unit['CurrentLease']['moveout_date'])) { - $this->sidemenu_links[] = - array('name' => 'Move-Out', 'url' => array('action' => 'move_out', - $id)); + // 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'); } elseif ($this->Unit->available($unit['Unit']['status'])) { - $this->sidemenu_links[] = - array('name' => 'Move-In', 'url' => array('action' => 'move_in', - $id)); + $this->addSideMenuLink('Move-In', + array('action' => 'move_in', $id), null, + 'ACTION'); } else { // Unit is unavailable (dirty, damaged, reserved, business-use, etc) } - if (isset($unit['CurrentLease']['id']) && - !isset($unit['CurrentLease']['close_date'])) { - $this->sidemenu_links[] = - array('name' => 'New Invoice', 'url' => array('controller' => 'leases', - 'action' => 'invoice', - $unit['CurrentLease']['id'])); - $this->sidemenu_links[] = - array('name' => 'New Receipt', 'url' => array('controller' => 'customers', - 'action' => 'receipt', - $unit['CurrentLease']['customer_id'])); + // 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', + $unit['CurrentLease']['id']), null, + 'ACTION'); + $this->addSideMenuLink('New Receipt', + array('controller' => 'customers', + 'action' => 'receipt', + $unit['CurrentLease']['customer_id']), null, + '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', @@ -328,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/controllers/util_controller.php b/site/controllers/util_controller.php new file mode 100644 index 0000000..3a4ea43 --- /dev/null +++ b/site/controllers/util_controller.php @@ -0,0 +1,76 @@ +layout = null; + $this->autoLayout = false; + $this->autoRender = false; + Configure::write('debug', '0'); + $script = $_SERVER['DOCUMENT_ROOT'] . '/pmgr/build.cmd'; + echo "

" . date('r') . "\n"; + //echo "

Script: $script" . "\n"; + $handle = popen($script . ' 2>&1', 'r'); + //echo "

Handle: $handle; " . gettype($handle) . "\n"; + echo "

\n";
+    while (($read = fread($handle, 2096))) {
+      echo $read;
+    }
+    echo "
\n"; + pclose($handle); + } + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: rebuild_box + */ + + function rebuild_box($type) { + $this->layout = null; + $this->autoLayout = false; + $this->autoRender = false; + Configure::write('debug', '0'); + $script = preg_replace('%/webroot/index.php$%', + '/build_'.$type.'box.cmd', + $_SERVER['SCRIPT_FILENAME']); + + // REVISIT : 20090828 + // Just use system call + $handle = popen($script . ' 2>&1', 'r'); + while (($read = fread($handle, 2096))) { + // Do nothing + } + pclose($handle); + + $url = $_SERVER['HTTP_REFERER']; + if (empty($url)) + $url = "/"; + + $this->redirect($url); + } + + function rebuild_sandbox() { $this->rebuild_box('sand'); } + function rebuild_devbox() { $this->rebuild_box('dev'); } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: logmsg + * - action to allow posting log message data + */ + + function logmsg() { + } + +} 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/default_option.php b/site/models/default_option.php new file mode 100644 index 0000000..e472e40 --- /dev/null +++ b/site/models/default_option.php @@ -0,0 +1,21 @@ +prEnter(compact('name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['DefaultOption'] = array(); + $query['link']['DefaultOption']['type'] = 'INNER'; + $query['link']['DefaultOption']['fields'] = array(); + return $this->prReturn($this->OptionValue->values($name, $query)); + } + +} diff --git a/site/models/default_permission.php b/site/models/default_permission.php new file mode 100644 index 0000000..920bd8f --- /dev/null +++ b/site/models/default_permission.php @@ -0,0 +1,21 @@ +prEnter(compact('name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['DefaultPermission'] = array(); + $query['link']['DefaultPermission']['type'] = 'INNER'; + $query['link']['DefaultPermission']['fields'] = array(); + return $this->prReturn($this->PermissionValue->values($name, $query)); + } + +} diff --git a/site/models/group.php b/site/models/group.php new file mode 100644 index 0000000..114ec73 --- /dev/null +++ b/site/models/group.php @@ -0,0 +1,38 @@ +groupIds(); + + if (empty(self::$current_group_ids)) + // We must force a stop here, since this is typically + // called very early on, and so will cause a recursive + // crash as we try to render the internal error and + // again stumble on this problem. + $this->INTERNAL_ERROR('INVALID MEMBERSHIP', 0, true); + + return self::$current_group_ids; + } + + function groupIds($user_id = null, $site_id = null) { + if (empty($user_id)) + $user_id = $this->User->currentUserId(); + if (empty($site_id)) + $site_id = $this->Site->currentSiteId(); + + return $this->Membership->memberGroups($user_id, $site_id); + } + +} diff --git a/site/models/group_option.php b/site/models/group_option.php new file mode 100644 index 0000000..ccd7266 --- /dev/null +++ b/site/models/group_option.php @@ -0,0 +1,25 @@ +prEnter(compact('id', 'name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['GroupOption'] = array(); + $query['link']['GroupOption']['fields'] = array(); + $query['link']['GroupOption']['Group'] = array(); + $query['link']['GroupOption']['Group']['fields'] = array(); + $query['conditions'][] = array('Group.id' => $ids); + $query['order'][] = 'Group.rank'; + return $this->prReturn($this->OptionValue->values($name, $query)); + } + +} diff --git a/site/models/group_permission.php b/site/models/group_permission.php new file mode 100644 index 0000000..2d798d4 --- /dev/null +++ b/site/models/group_permission.php @@ -0,0 +1,25 @@ +prEnter(compact('id', 'name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['GroupPermission'] = array(); + $query['link']['GroupPermission']['fields'] = array(); + $query['link']['GroupPermission']['Group'] = array(); + $query['link']['GroupPermission']['Group']['fields'] = array(); + $query['conditions'][] = array('Group.id' => $ids); + $query['order'][] = 'Group.rank'; + return $this->prReturn($this->PermissionValue->values($name, $query)); + } + +} diff --git a/site/models/membership.php b/site/models/membership.php new file mode 100644 index 0000000..f444b3c --- /dev/null +++ b/site/models/membership.php @@ -0,0 +1,37 @@ +prEnter(compact('user_id', 'site_id')); + + $this->cacheQueries = true; + $groups = $this->find('all', array + ('recursive' => -1, + 'fields' => array('group_id'), + 'conditions' => array(array('user_id' => $user_id), + array('site_id' => $site_id)), + )); + $this->cacheQueries = false; + + if (empty($groups)) + return $this->prReturn(null); + + $group_ids = array(); + foreach ($groups AS $group) + $group_ids[] = $group['Membership']['group_id']; + + return $this->prReturn($group_ids); + } + + function memberOf($user_id, $site_id) { + $groups = $this->memberGroups($user_id, $site_id); + return (!empty($groups)); + } + +} diff --git a/site/models/option.php b/site/models/option.php new file mode 100644 index 0000000..b32361f --- /dev/null +++ b/site/models/option.php @@ -0,0 +1,76 @@ +prClassLevel(30); */ +/* //$this->OptionValue->prClassLevel(30); */ +/* $this->Group->Membership->prClassLevel(30); */ +/* $this->OptionValue->SiteOption->prClassLevel(30); */ +/* $this->OptionValue->UserOption->prClassLevel(30); */ +/* $this->OptionValue->GroupOption->prClassLevel(30); */ +/* $this->OptionValue->DefaultOption->prClassLevel(30); */ + $this->prEnter(compact('name')); + + if (!empty(self::$option_set[$name]) && !$force) + return $this->prReturn(self::$option_set[$name]); + + self::$option_set[$name] = array(); + + $site_id = $this->Site->currentSiteId(); + $user_id = $this->User->currentUserId(); + $group_ids = $this->Group->currentGroupIds(); + +/* $site_id = 2; */ +/* $user_id = 4; */ +/* $group_ids = $this->Group->groupIds($user_id, $site_id); */ + + if (!empty($site_id)) + self::$option_set[$name] = + array_merge(self::$option_set[$name], + $this->OptionValue->SiteOption->values($site_id, $name)); + + if (!empty($user_id)) + self::$option_set[$name] = + array_merge(self::$option_set[$name], + $this->OptionValue->UserOption->values($user_id, $name)); + + if (!empty($group_ids)) + self::$option_set[$name] = + array_merge(self::$option_set[$name], + $this->OptionValue->GroupOption->values($group_ids, $name)); + + self::$option_set[$name] = + array_merge(self::$option_set[$name], + $this->OptionValue->DefaultOption->values($name)); + + return $this->prReturn(self::$option_set[$name]); + } + + function get($name) { + $this->prEnter(compact('name')); + $values = $this->getAll($name); + if (empty($values)) + return null; + return $this->prReturn($values[0]); + } + + function enabled($name) { + $val = $this->get($name); + return (!empty($val)); + } + + function disabled($name) { + return (!$this->enabled($name)); + } + +} diff --git a/site/models/option_value.php b/site/models/option_value.php new file mode 100644 index 0000000..0c1fa3c --- /dev/null +++ b/site/models/option_value.php @@ -0,0 +1,35 @@ +prEnter(compact('name', 'query')); + $this->queryInit($query); + + $query['link']['Option'] = array(); + + if (!empty($name)) { + $query['conditions'][] = array('Option.name' => $name); + $query['link']['Option']['fields'] = array(); + } + + $this->cacheQueries = true; + $values = array(); + foreach ($this->find('all', $query) AS $result) + $values[] = $result['OptionValue']['value']; + $this->cacheQueries = false; + + return $this->prReturn($values); + } + +} diff --git a/site/models/permission.php b/site/models/permission.php new file mode 100644 index 0000000..f4b5ac2 --- /dev/null +++ b/site/models/permission.php @@ -0,0 +1,105 @@ +prClassLevel(30); */ +/* $this->PermissionValue->prClassLevel(30); */ +/* $this->Group->Membership->prClassLevel(30); */ +/* $this->PermissionValue->SitePermission->prClassLevel(30); */ +/* $this->PermissionValue->UserPermission->prClassLevel(30); */ +/* $this->PermissionValue->GroupPermission->prClassLevel(30); */ +/* $this->PermissionValue->DefaultPermission->prClassLevel(30); */ + $this->prEnter(compact('name')); + + if (!empty(self::$permission_set[$name]) && !$force) + return $this->prReturn(self::$permission_set[$name]); + + self::$permission_set[$name] = array(); + + $site_id = $this->Site->currentSiteId(); + $user_id = $this->User->currentUserId(); + $group_ids = $this->Group->currentGroupIds(); + +/* $site_id = 1; */ +/* $user_id = 2; */ +/* $group_ids = $this->Group->groupIds($user_id, $site_id); */ + + if (empty($group_ids)) { + self::$permission_set[$name][$name][] = array('access' => 'DENY', 'level' => null); + $site_id = null; + $user_id = null; + } + + if (!empty($site_id)) + self::$permission_set[$name] = + array_merge(self::$permission_set[$name], + $this->PermissionValue->SitePermission->values($site_id, $name)); + + if (!empty($user_id)) + self::$permission_set[$name] = + array_merge(self::$permission_set[$name], + $this->PermissionValue->UserPermission->values($user_id, $name)); + + if (!empty($group_ids)) { + self::$permission_set[$name] = + array_merge(self::$permission_set[$name], + $this->PermissionValue->GroupPermission->values($group_ids, $name)); + + self::$permission_set[$name] = + array_merge(self::$permission_set[$name], + $this->PermissionValue->DefaultPermission->values($name)); + + self::$permission_set[$name][] = array('access' => 'ALLOW', 'level' => null); + } + + return $this->prReturn(self::$permission_set[$name]); + } + + function get($name) { + $this->prEnter(compact('name')); + + // REVISIT : 20090827 + // This is a pretty crappy algorithm. How do we decide whether DENY really + // means DENY, or whether an ALLOW has priority. + // Oh well, it works for now... + + $values = $this->getAll($name); + $result = array_shift($values); + + foreach ($values AS $value) + if (empty($result['level']) || (!empty($value['level']) && $value['level'] < $result['level'])) + $result['level'] = $value['level']; + + if ($result['access'] !== 'ALLOW') + $result['level'] = 9999999; + + return $this->prReturn($result); + } + + function allow($name) { + $this->prEnter(compact('name')); + $result = $this->get($name); + return $this->prReturn($result['access'] === 'ALLOW'); + } + + function deny($name) { + $this->prEnter(compact('name')); + return $this->prReturn(!$this->allow($name)); + } + + function level($name) { + $this->prEnter(compact('name')); + $result = $this->get($name); + return $this->prReturn($result['level']); + } + +} diff --git a/site/models/permission_value.php b/site/models/permission_value.php new file mode 100644 index 0000000..ce7ec39 --- /dev/null +++ b/site/models/permission_value.php @@ -0,0 +1,36 @@ +prEnter(compact('name', 'query')); + $this->queryInit($query); + + $query['link']['Permission'] = array(); + + if (!empty($name)) { + $query['conditions'][] = array('Permission.name' => $name); + $query['link']['Permission']['fields'] = array(); + } + + $this->cacheQueries = true; + $values = array(); + foreach ($this->find('all', $query) AS $result) + $values[] = array('access' => $result['PermissionValue']['access'], + 'level' => $result['PermissionValue']['level']); + $this->cacheQueries = false; + + return $this->prReturn($values); + } + +} diff --git a/site/models/site.php b/site/models/site.php index 4825faa..5473031 100644 --- a/site/models/site.php +++ b/site/models/site.php @@ -1,16 +1,37 @@ array('numeric'), - 'name' => array('notempty') - ); + var $hasMany = + array('SiteArea', + 'SiteOption', + 'Membership', + ); - var $hasMany = array( - 'SiteArea', - 'SiteOption', - ); + static $current_site_id; + function currentSiteId() { + if (!empty(self::$current_site_id)) + return self::$current_site_id; + + // REVISIT : 20090827 + // Must get the actual site + $code = 'VSS'; + + $site = $this->find + ('first', + array('recursive' => -1, + 'conditions' => compact('code'))); + + if (!empty($site['Site']['id'])) + self::$current_site_id = $site['Site']['id']; + else + // We must force a stop here, since this is typically + // called very early on, and so will cause a recursive + // crash as we try to render the internal error and + // again stumble on this problem. + $this->INTERNAL_ERROR('UNKNOWN SITE', 0, true); + + return self::$current_site_id; + } } ?> \ No newline at end of file diff --git a/site/models/site_option.php b/site/models/site_option.php new file mode 100644 index 0000000..1ef89a3 --- /dev/null +++ b/site/models/site_option.php @@ -0,0 +1,24 @@ +prEnter(compact('id', 'name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['SiteOption'] = array(); + $query['link']['SiteOption']['fields'] = array(); + $query['link']['SiteOption']['Site'] = array(); + $query['link']['SiteOption']['Site']['fields'] = array(); + $query['conditions'][] = array('Site.id' => $id); + return $this->prReturn($this->OptionValue->values($name, $query)); + } + +} diff --git a/site/models/site_permission.php b/site/models/site_permission.php new file mode 100644 index 0000000..6fad60e --- /dev/null +++ b/site/models/site_permission.php @@ -0,0 +1,24 @@ +prEnter(compact('id', 'name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['SitePermission'] = array(); + $query['link']['SitePermission']['fields'] = array(); + $query['link']['SitePermission']['Site'] = array(); + $query['link']['SitePermission']['Site']['fields'] = array(); + $query['conditions'][] = array('Site.id' => $id); + return $this->prReturn($this->PermissionValue->values($name, $query)); + } + +} diff --git a/site/models/transaction.php b/site/models/transaction.php index de8923a..bdce007 100644 --- a/site/models/transaction.php +++ b/site/models/transaction.php @@ -350,10 +350,14 @@ class Transaction extends AppModel { if (isset($ids['transaction_id'])) $ids['deposit_id'] = $ids['transaction_id']; - if (!empty($ids['deposit_id']) && !empty($control['update_tender'])) { + $this->pr(21, array_intersect_key($ids, array('deposit_id'=>1)) + + array_intersect_key($data['control'], array('update_tender'=>1))); + + if (!empty($ids['deposit_id']) && !empty($data['control']['update_tender'])) { + $this->pr(21, compact('tender_groups')); foreach ($tender_groups AS $group => $tender_ids) { $entry_id = $ids['entries'][$group]['DoubleEntry']['Entry2']['ledger_entry_id']; - $this->pr(10, compact('group', 'tender_ids', 'entry_id')); + $this->pr(19, compact('group', 'tender_ids', 'entry_id')); $this->LedgerEntry->Tender->updateAll (array('Tender.deposit_transaction_id' => $ids['deposit_id'], 'Tender.deposit_ledger_entry_id' => $entry_id), @@ -530,6 +534,8 @@ class Transaction extends AppModel { (in_array($transaction['type'], array('INVOICE', 'RECEIPT')) && empty($transaction['customer_id'])) ) { + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Transaction verification failed'); return $this->prReturn(false); } @@ -545,6 +551,8 @@ class Transaction extends AppModel { } if (!empty($se) && !$this->StatementEntry->verifyStatementEntry($se)) { + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Transaction entry verification failed'); return $this->prReturn(false); } } @@ -584,8 +592,11 @@ class Transaction extends AppModel { // Save transaction to the database $this->create(); - if (!$this->save($transaction)) + if (!$this->save($transaction)) { + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Failed to save Transaction'); return $this->prReturn(array('error' => true) + $ret); + } $ret['transaction_id'] = $transaction['id'] = $this->id; // Add the entries @@ -661,6 +672,11 @@ class Transaction extends AppModel { if (!empty($transaction['customer_id'])) { $this->Customer->update($transaction['customer_id']); } + + if (!empty($ret['error'])) + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Failed to save Transaction'); + return $this->prReturn($ret); } @@ -681,8 +697,11 @@ class Transaction extends AppModel { $this->prEnter(compact('control', 'transaction', 'entries', 'split')); // Verify that we have a transaction - if (empty($transaction['id'])) + if (empty($transaction['id'])) { + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Invalid Transaction ID for adding entries'); return $this->prReturn(array('error' => true)); + } // If the entries are not already split, do so now. if ($split) { @@ -742,6 +761,10 @@ class Transaction extends AppModel { } } + if (!empty($ret['error'])) + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Failed to save Transaction Entries'); + return $this->prReturn($ret); } @@ -762,8 +785,11 @@ class Transaction extends AppModel { // Verify that we have a transaction and entries if (empty($transaction) || - (empty($entries) && empty($control['allow_no_entries']))) + (empty($entries) && empty($control['allow_no_entries']))) { + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Split Entries failed to validate'); return $this->prReturn(array('error' => true)); + } // set ledger ID as the current ledger of the specified account if (empty($transaction['ledger_id'])) @@ -972,8 +998,11 @@ class Transaction extends AppModel { )); $this->pr(20, compact('nsf_ledger_entry')); - if (!$nsf_ledger_entry) + if (!$nsf_ledger_entry) { + // REVISIT : 20090828; Callers are not yet able to handle errors + $this->INTERNAL_ERROR('Failed to locate NSF ledger entry'); return $this->prReturn(array('error' => true) + $ret); + } // Build a transaction to adjust all of the statement entries $rollback = 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/models/user.php b/site/models/user.php new file mode 100644 index 0000000..46662a8 --- /dev/null +++ b/site/models/user.php @@ -0,0 +1,39 @@ +find + ('first', + array('recursive' => -1, + 'conditions' => array('login' => $this->currentUser()))); + + if (!empty($user['User']['id'])) + self::$current_user_id = $user['User']['id']; + else + // We must force a stop here, since this is typically + // called very early on, and so will cause a recursive + // crash as we try to render the internal error and + // again stumble on this problem. + $this->INTERNAL_ERROR('UNKNOWN USER', 0, true); + + return self::$current_user_id; + } + +} diff --git a/site/models/user_option.php b/site/models/user_option.php new file mode 100644 index 0000000..88fa1f8 --- /dev/null +++ b/site/models/user_option.php @@ -0,0 +1,24 @@ +prEnter(compact('id', 'name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['UserOption'] = array(); + $query['link']['UserOption']['fields'] = array(); + $query['link']['UserOption']['User'] = array(); + $query['link']['UserOption']['User']['fields'] = array(); + $query['conditions'][] = array('User.id' => $id); + return $this->prReturn($this->OptionValue->values($name, $query)); + } + +} diff --git a/site/models/user_permission.php b/site/models/user_permission.php new file mode 100644 index 0000000..8cdc5b3 --- /dev/null +++ b/site/models/user_permission.php @@ -0,0 +1,24 @@ +prEnter(compact('id', 'name')); + + $query = array(); + $this->queryInit($query); + + $query['link']['UserPermission'] = array(); + $query['link']['UserPermission']['fields'] = array(); + $query['link']['UserPermission']['User'] = array(); + $query['link']['UserPermission']['User']['fields'] = array(); + $query['conditions'][] = array('User.id' => $id); + return $this->prReturn($this->PermissionValue->values($name, $query)); + } + +} diff --git a/site/views/accounts/collected.ctp b/site/views/accounts/collected.ctp index 0d0df56..e030e26 100644 --- a/site/views/accounts/collected.ctp +++ b/site/views/accounts/collected.ctp @@ -178,20 +178,8 @@ echo $this->element('statement_entries', array diff --git a/site/views/accounts/view.ctp b/site/views/accounts/view.ctp index 897ab78..ddf1e61 100644 --- a/site/views/accounts/view.ctp +++ b/site/views/accounts/view.ctp @@ -16,7 +16,6 @@ if (isset($account['Account'])) $account = $account['Account']; $rows = array(); -$rows[] = array('ID', $account['id']); $rows[] = array('Name', $account['name']); $rows[] = array('Type', $account['type']); $rows[] = array('External Name', $account['external_name']); @@ -78,12 +77,12 @@ echo $this->element('ledger_entries', array (// Grid configuration 'config' => array ('grid_div_id' => 'ledger-ledger-entry-list', - 'caption' => ("Current Ledger: " . - "(". $current_ledger['name'] .")"), - 'filter' => array('Ledger.id' => $current_ledger['id']), + 'caption' => "Current Ledger: #{$current_ledger['sequence']}", + 'filter' => array('Ledger.id' => $current_ledger['id']), 'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance', empty($account['receipts']) ? 'Tender' : null), 'include' => array('Debit', 'Credit', 'Sub-Total'), + 'limit' => 50, ))); @@ -102,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) { '