From c9f9d0867bdf1a7063c42e42d79dcc164e1676b0 Mon Sep 17 00:00:00 2001
From: Abijah
Date: Wed, 27 May 2009 04:17:45 +0000
Subject: [PATCH 001/717] Added branch point for initial work. The site
directory will be added using the svn_import script, and will represent the
output of the command 'cake bake pmgr'
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@2 97e9348a-65ac-dc4b-aefc-98561f571b83
From 3251ba340df17c8d700840e518935fd929c919e3 Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 04:18:18 +0000
Subject: [PATCH 002/717] Create directories to load project into.
* branches/initial_20090526/site: New directory.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@3 97e9348a-65ac-dc4b-aefc-98561f571b83
From 4502b73b2ed6c9c8729f293176866874266da9b0 Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 04:18:23 +0000
Subject: [PATCH 003/717] Load pmgr into branches/initial_20090526/site.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@4 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/.htaccess | 5 +
site/app_controller.php | 39 ++
site/app_helper.php | 41 ++
site/app_model.php | 41 ++
site/config/acl.ini.php | 74 +++
site/config/bootstrap.php | 44 ++
site/config/core.php | 227 +++++++++
site/config/database.php | 14 +
site/config/database.php.default | 101 ++++
site/config/inflections.php | 70 +++
site/config/routes.php | 39 ++
site/config/sql/db_acl.php | 79 +++
site/config/sql/db_acl.sql | 40 ++
site/config/sql/i18n.php | 56 ++
site/config/sql/i18n.sql | 26 +
site/config/sql/sessions.php | 53 ++
site/config/sql/sessions.sql | 16 +
site/controllers/pages_controller.php | 86 ++++
site/index.php | 24 +
.../cache/models/cake_model_default_pmgr_list | 2 +
.../tmp/cache/persistent/cake_core_core_paths | 2 +
.../cache/persistent/cake_core_default_en_us | 2 +
site/tmp/cache/persistent/cake_core_dir_map | 2 +
site/tmp/cache/persistent/cake_core_file_map | 2 +
site/views/elements/email/html/default.ctp | 31 ++
site/views/elements/email/text/default.ctp | 25 +
site/views/layouts/ajax.ctp | 25 +
site/views/layouts/default.ctp | 64 +++
site/views/layouts/email/html/default.ctp | 37 ++
site/views/layouts/email/text/default.ctp | 29 ++
site/views/layouts/flash.ctp | 44 ++
site/views/layouts/js/default.ctp | 2 +
site/views/layouts/rss/default.ctp | 17 +
site/views/layouts/xml/default.ctp | 2 +
site/views/pages/home.ctp | 80 +++
site/webroot/.htaccess | 6 +
site/webroot/css.php | 102 ++++
site/webroot/css/cake.generic.css | 480 ++++++++++++++++++
site/webroot/favicon.ico | Bin 0 -> 372 bytes
site/webroot/img/cake.icon.gif | Bin 0 -> 233 bytes
site/webroot/img/cake.power.gif | Bin 0 -> 201 bytes
site/webroot/index.php | 93 ++++
site/webroot/js/vendors.php | 42 ++
site/webroot/test.php | 181 +++++++
44 files changed, 2345 insertions(+)
create mode 100644 site/.htaccess
create mode 100644 site/app_controller.php
create mode 100644 site/app_helper.php
create mode 100644 site/app_model.php
create mode 100644 site/config/acl.ini.php
create mode 100644 site/config/bootstrap.php
create mode 100644 site/config/core.php
create mode 100644 site/config/database.php
create mode 100644 site/config/database.php.default
create mode 100644 site/config/inflections.php
create mode 100644 site/config/routes.php
create mode 100644 site/config/sql/db_acl.php
create mode 100644 site/config/sql/db_acl.sql
create mode 100644 site/config/sql/i18n.php
create mode 100644 site/config/sql/i18n.sql
create mode 100644 site/config/sql/sessions.php
create mode 100644 site/config/sql/sessions.sql
create mode 100644 site/controllers/pages_controller.php
create mode 100644 site/index.php
create mode 100644 site/tmp/cache/models/cake_model_default_pmgr_list
create mode 100644 site/tmp/cache/persistent/cake_core_core_paths
create mode 100644 site/tmp/cache/persistent/cake_core_default_en_us
create mode 100644 site/tmp/cache/persistent/cake_core_dir_map
create mode 100644 site/tmp/cache/persistent/cake_core_file_map
create mode 100644 site/views/elements/email/html/default.ctp
create mode 100644 site/views/elements/email/text/default.ctp
create mode 100644 site/views/layouts/ajax.ctp
create mode 100644 site/views/layouts/default.ctp
create mode 100644 site/views/layouts/email/html/default.ctp
create mode 100644 site/views/layouts/email/text/default.ctp
create mode 100644 site/views/layouts/flash.ctp
create mode 100644 site/views/layouts/js/default.ctp
create mode 100644 site/views/layouts/rss/default.ctp
create mode 100644 site/views/layouts/xml/default.ctp
create mode 100644 site/views/pages/home.ctp
create mode 100644 site/webroot/.htaccess
create mode 100644 site/webroot/css.php
create mode 100644 site/webroot/css/cake.generic.css
create mode 100644 site/webroot/favicon.ico
create mode 100644 site/webroot/img/cake.icon.gif
create mode 100644 site/webroot/img/cake.power.gif
create mode 100644 site/webroot/index.php
create mode 100644 site/webroot/js/vendors.php
create mode 100644 site/webroot/test.php
diff --git a/site/.htaccess b/site/.htaccess
new file mode 100644
index 0000000..0ed8662
--- /dev/null
+++ b/site/.htaccess
@@ -0,0 +1,5 @@
+
+ RewriteEngine on
+ RewriteRule ^$ webroot/ [L]
+ RewriteRule (.*) webroot/$1 [L]
+
\ No newline at end of file
diff --git a/site/app_controller.php b/site/app_controller.php
new file mode 100644
index 0000000..87357ed
--- /dev/null
+++ b/site/app_controller.php
@@ -0,0 +1,39 @@
+
\ No newline at end of file
diff --git a/site/app_helper.php b/site/app_helper.php
new file mode 100644
index 0000000..eb23db7
--- /dev/null
+++ b/site/app_helper.php
@@ -0,0 +1,41 @@
+
\ No newline at end of file
diff --git a/site/app_model.php b/site/app_model.php
new file mode 100644
index 0000000..7d083b0
--- /dev/null
+++ b/site/app_model.php
@@ -0,0 +1,41 @@
+
\ No newline at end of file
diff --git a/site/config/acl.ini.php b/site/config/acl.ini.php
new file mode 100644
index 0000000..94a9a9a
--- /dev/null
+++ b/site/config/acl.ini.php
@@ -0,0 +1,74 @@
+;
+; SVN FILE: $Id: acl.ini.php 7945 2008-12-19 02:16:01Z gwoo $
+;/**
+; * Short description for file.
+; *
+; *
+; * PHP versions 4 and 5
+; *
+; * CakePHP(tm) : Rapid Development Framework http://www.cakephp.org/
+; * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+; *
+; * Licensed under The MIT License
+; * Redistributions of files must retain the above copyright notice.
+; *
+; * @filesource
+; * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+; * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+; * @package cake
+; * @subpackage cake.app.config
+; * @since CakePHP(tm) v 0.10.0.1076
+; * @version $Revision: 7945 $
+; * @modifiedby $LastChangedBy: gwoo $
+; * @lastmodified $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
+; * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+; */
+
+; acl.ini.php - Cake ACL Configuration
+; ---------------------------------------------------------------------
+; Use this file to specify user permissions.
+; aco = access control object (something in your application)
+; aro = access request object (something requesting access)
+;
+; User records are added as follows:
+;
+; [uid]
+; groups = group1, group2, group3
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; Group records are added in a similar manner:
+;
+; [gid]
+; allow = aco1, aco2, aco3
+; deny = aco4, aco5, aco6
+;
+; The allow, deny, and groups sections are all optional.
+; NOTE: groups names *cannot* ever be the same as usernames!
+;
+; ACL permissions are checked in the following order:
+; 1. Check for user denies (and DENY if specified)
+; 2. Check for user allows (and ALLOW if specified)
+; 3. Gather user's groups
+; 4. Check group denies (and DENY if specified)
+; 5. Check group allows (and ALLOW if specified)
+; 6. If no aro, aco, or group information is found, DENY
+;
+; ---------------------------------------------------------------------
+
+;-------------------------------------
+;Users
+;-------------------------------------
+
+[username-goes-here]
+groups = group1, group2
+deny = aco1, aco2
+allow = aco3, aco4
+
+;-------------------------------------
+;Groups
+;-------------------------------------
+
+[groupname-goes-here]
+deny = aco5, aco6
+allow = aco7, aco8
\ No newline at end of file
diff --git a/site/config/bootstrap.php b/site/config/bootstrap.php
new file mode 100644
index 0000000..2c89c74
--- /dev/null
+++ b/site/config/bootstrap.php
@@ -0,0 +1,44 @@
+
\ No newline at end of file
diff --git a/site/config/core.php b/site/config/core.php
new file mode 100644
index 0000000..3add95a
--- /dev/null
+++ b/site/config/core.php
@@ -0,0 +1,227 @@
+ admin_index() and /admin/controller/index
+ * 'superuser' -> superuser_index() and /superuser/controller/index
+ */
+ //Configure::write('Routing.admin', 'admin');
+
+/**
+ * Turn off all caching application-wide.
+ *
+ */
+ //Configure::write('Cache.disable', true);
+/**
+ * Enable cache checking.
+ *
+ * If set to true, for view caching you must still use the controller
+ * var $cacheAction inside your controllers to define caching settings.
+ * You can either set it controller-wide by setting var $cacheAction = true,
+ * or in each action using $this->cacheAction = true.
+ *
+ */
+ //Configure::write('Cache.check', true);
+/**
+ * Defines the default error type when using the log() function. Used for
+ * differentiating error logging and debugging. Currently PHP supports LOG_DEBUG.
+ */
+ define('LOG_ERROR', 2);
+/**
+ * The preferred session handling method. Valid values:
+ *
+ * 'php' Uses settings defined in your php.ini.
+ * 'cake' Saves session files in CakePHP's /tmp directory.
+ * 'database' Uses CakePHP's database sessions.
+ *
+ * To define a custom session handler, save it at /app/config/.php.
+ * Set the value of 'Session.save' to to utilize it in CakePHP.
+ *
+ * To use database sessions, execute the SQL file found at /app/config/sql/sessions.sql.
+ *
+ */
+ Configure::write('Session.save', 'php');
+/**
+ * The name of the table used to store CakePHP database sessions.
+ *
+ * 'Session.save' must be set to 'database' in order to utilize this constant.
+ *
+ * The table name set here should *not* include any table prefix defined elsewhere.
+ */
+ //Configure::write('Session.table', 'cake_sessions');
+/**
+ * The DATABASE_CONFIG::$var to use for database session handling.
+ *
+ * 'Session.save' must be set to 'database' in order to utilize this constant.
+ */
+ //Configure::write('Session.database', 'default');
+/**
+ * The name of CakePHP's session cookie.
+ */
+ Configure::write('Session.cookie', 'CAKEPHP');
+/**
+ * Session time out time (in seconds).
+ * Actual value depends on 'Security.level' setting.
+ */
+ Configure::write('Session.timeout', '120');
+/**
+ * If set to false, sessions are not automatically started.
+ */
+ Configure::write('Session.start', true);
+/**
+ * When set to false, HTTP_USER_AGENT will not be checked
+ * in the session
+ */
+ Configure::write('Session.checkAgent', true);
+/**
+ * The level of CakePHP security. The session timeout time defined
+ * in 'Session.timeout' is multiplied according to the settings here.
+ * Valid values:
+ *
+ * 'high' Session timeout in 'Session.timeout' x 10
+ * 'medium' Session timeout in 'Session.timeout' x 100
+ * 'low' Session timeout in 'Session.timeout' x 300
+ *
+ * CakePHP session IDs are also regenerated between requests if
+ * 'Security.level' is set to 'high'.
+ */
+ Configure::write('Security.level', 'high');
+/**
+ * A random string used in security hashing methods.
+ */
+ Configure::write('Security.salt', 'fbd497077ac32a7ab159333cd7e3eeb85db5c2a5');
+/**
+ * Compress CSS output by removing comments, whitespace, repeating tags, etc.
+ * This requires a/var/cache directory to be writable by the web server for caching.
+ * and /vendors/csspp/csspp.php
+ *
+ * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css().
+ */
+ //Configure::write('Asset.filter.css', 'css.php');
+/**
+ * Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the
+ * output, and setting the config below to the name of the script.
+ *
+ * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link().
+ */
+ //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php');
+/**
+ * The classname and database used in CakePHP's
+ * access control lists.
+ */
+ Configure::write('Acl.classname', 'DbAcl');
+ Configure::write('Acl.database', 'default');
+/**
+ *
+ * Cache Engine Configuration
+ * Default settings provided below
+ *
+ * File storage engine.
+ *
+ * Cache::config('default', array(
+ * 'engine' => 'File', //[required]
+ * 'duration'=> 3600, //[optional]
+ * 'probability'=> 100, //[optional]
+ * 'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
+ * 'prefix' => 'cake_', //[optional] prefix every cache file with this string
+ * 'lock' => false, //[optional] use file locking
+ * 'serialize' => true, [optional]
+ * ));
+ *
+ *
+ * APC (http://pecl.php.net/package/APC)
+ *
+ * Cache::config('default', array(
+ * 'engine' => 'Apc', //[required]
+ * 'duration'=> 3600, //[optional]
+ * 'probability'=> 100, //[optional]
+ * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
+ * ));
+ *
+ * Xcache (http://xcache.lighttpd.net/)
+ *
+ * Cache::config('default', array(
+ * 'engine' => 'Xcache', //[required]
+ * 'duration'=> 3600, //[optional]
+ * 'probability'=> 100, //[optional]
+ * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
+ * 'user' => 'user', //user from xcache.admin.user settings
+ * 'password' => 'password', //plaintext password (xcache.admin.pass)
+ * ));
+ *
+ *
+ * Memcache (http://www.danga.com/memcached/)
+ *
+ * Cache::config('default', array(
+ * 'engine' => 'Memcache', //[required]
+ * 'duration'=> 3600, //[optional]
+ * 'probability'=> 100, //[optional]
+ * 'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
+ * 'servers' => array(
+ * '127.0.0.1:11211' // localhost, default port 11211
+ * ), //[optional]
+ * 'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
+ * ));
+ *
+ */
+ Cache::config('default', array('engine' => 'File'));
+?>
\ No newline at end of file
diff --git a/site/config/database.php b/site/config/database.php
new file mode 100644
index 0000000..c875711
--- /dev/null
+++ b/site/config/database.php
@@ -0,0 +1,14 @@
+ 'mysql',
+ 'persistent' => false,
+ 'host' => 'localhost',
+ 'login' => 'pmgr',
+ 'password' => 'pmgruser',
+ 'database' => 'pmgr',
+ 'prefix' => 'pmgr_',
+ );
+}
+?>
\ No newline at end of file
diff --git a/site/config/database.php.default b/site/config/database.php.default
new file mode 100644
index 0000000..c20fd5d
--- /dev/null
+++ b/site/config/database.php.default
@@ -0,0 +1,101 @@
+ The name of a supported driver; valid options are as follows:
+ * mysql - MySQL 4 & 5,
+ * mysqli - MySQL 4 & 5 Improved Interface (PHP5 only),
+ * sqlite - SQLite (PHP5 only),
+ * postgres - PostgreSQL 7 and higher,
+ * mssql - Microsoft SQL Server 2000 and higher,
+ * db2 - IBM DB2, Cloudscape, and Apache Derby (http://php.net/ibm-db2)
+ * oracle - Oracle 8 and higher
+ * firebird - Firebird/Interbase
+ * sybase - Sybase ASE
+ * adodb-[drivername] - ADOdb interface wrapper (see below),
+ * odbc - ODBC DBO driver
+ *
+ * You can add custom database drivers (or override existing drivers) by adding the
+ * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php',
+ * where 'x' is the name of the database.
+ *
+ * persistent => true / false
+ * Determines whether or not the database should use a persistent connection
+ *
+ * connect =>
+ * ADOdb set the connect to one of these
+ * (http://phplens.com/adodb/supported.databases.html) and
+ * append it '|p' for persistent connection. (mssql|p for example, or just mssql for not persistent)
+ * For all other databases, this setting is deprecated.
+ *
+ * host =>
+ * the host you connect to the database. To add a socket or port number, use 'port' => #
+ *
+ * prefix =>
+ * Uses the given prefix for all the tables in this database. This setting can be overridden
+ * on a per-table basis with the Model::$tablePrefix property.
+ *
+ * schema =>
+ * For Postgres and DB2, specifies which schema you would like to use the tables in. Postgres defaults to
+ * 'public', DB2 defaults to empty.
+ *
+ * encoding =>
+ * For MySQL, MySQLi, Postgres and DB2, specifies the character encoding to use when connecting to the
+ * database. Uses database default.
+ *
+ */
+class DATABASE_CONFIG {
+
+ var $default = array(
+ 'driver' => 'mysql',
+ 'persistent' => false,
+ 'host' => 'localhost',
+ 'login' => 'user',
+ 'password' => 'password',
+ 'database' => 'database_name',
+ 'prefix' => '',
+ );
+
+ var $test = array(
+ 'driver' => 'mysql',
+ 'persistent' => false,
+ 'host' => 'localhost',
+ 'login' => 'user',
+ 'password' => 'password',
+ 'database' => 'test_database_name',
+ 'prefix' => '',
+ );
+}
+?>
\ No newline at end of file
diff --git a/site/config/inflections.php b/site/config/inflections.php
new file mode 100644
index 0000000..429c085
--- /dev/null
+++ b/site/config/inflections.php
@@ -0,0 +1,70 @@
+ value array of regex used to match words.
+ * If key matches then the value is returned.
+ *
+ * $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
+ */
+ $pluralRules = array();
+/**
+ * This is a key only array of plural words that should not be inflected.
+ * Notice the last comma
+ *
+ * $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
+ */
+ $uninflectedPlural = array();
+/**
+ * This is a key => value array of plural irregular words.
+ * If key matches then the value is returned.
+ *
+ * $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
+ */
+ $irregularPlural = array();
+/**
+ * This is a key => value array of regex used to match words.
+ * If key matches then the value is returned.
+ *
+ * $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
+ */
+ $singularRules = array();
+/**
+ * This is a key only array of singular words that should not be inflected.
+ * You should not have to change this value below if you do change it use same format
+ * as the $uninflectedPlural above.
+ */
+ $uninflectedSingular = $uninflectedPlural;
+/**
+ * This is a key => value array of singular irregular words.
+ * Most of the time this will be a reverse of the above $irregularPlural array
+ * You should not have to change this value below if you do change it use same format
+ *
+ * $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
+ */
+ $irregularSingular = array_flip($irregularPlural);
+?>
\ No newline at end of file
diff --git a/site/config/routes.php b/site/config/routes.php
new file mode 100644
index 0000000..44e4c40
--- /dev/null
+++ b/site/config/routes.php
@@ -0,0 +1,39 @@
+ 'pages', 'action' => 'display', 'home'));
+/**
+ * ...and connect the rest of 'Pages' controller's urls.
+ */
+ Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
+?>
\ No newline at end of file
diff --git a/site/config/sql/db_acl.php b/site/config/sql/db_acl.php
new file mode 100644
index 0000000..5f24eab
--- /dev/null
+++ b/site/config/sql/db_acl.php
@@ -0,0 +1,79 @@
+ array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
+ 'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'model' => array('type'=>'string', 'null' => true),
+ 'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'alias' => array('type'=>'string', 'null' => true),
+ 'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
+ );
+
+ var $aros = array(
+ 'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
+ 'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'model' => array('type'=>'string', 'null' => true),
+ 'foreign_key' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'alias' => array('type'=>'string', 'null' => true),
+ 'lft' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'rght' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
+ );
+
+ var $aros_acos = array(
+ 'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
+ 'aro_id' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
+ 'aco_id' => array('type'=>'integer', 'null' => false, 'length' => 10),
+ '_create' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
+ '_read' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
+ '_update' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
+ '_delete' => array('type'=>'string', 'null' => false, 'default' => '0', 'length' => 2),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1))
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/config/sql/db_acl.sql b/site/config/sql/db_acl.sql
new file mode 100644
index 0000000..6d507fe
--- /dev/null
+++ b/site/config/sql/db_acl.sql
@@ -0,0 +1,40 @@
+# $Id: db_acl.sql 7945 2008-12-19 02:16:01Z gwoo $
+#
+# Copyright 2005-2008, Cake Software Foundation, Inc.
+#
+# Licensed under The MIT License
+# Redistributions of files must retain the above copyright notice.
+# http://www.opensource.org/licenses/mit-license.php The MIT License
+
+CREATE TABLE acos (
+ id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ parent_id INTEGER(10) DEFAULT NULL,
+ model VARCHAR(255) DEFAULT '',
+ foreign_key INTEGER(10) UNSIGNED DEFAULT NULL,
+ alias VARCHAR(255) DEFAULT '',
+ lft INTEGER(10) DEFAULT NULL,
+ rght INTEGER(10) DEFAULT NULL,
+ PRIMARY KEY (id)
+);
+
+CREATE TABLE aros_acos (
+ id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ aro_id INTEGER(10) UNSIGNED NOT NULL,
+ aco_id INTEGER(10) UNSIGNED NOT NULL,
+ _create CHAR(2) NOT NULL DEFAULT 0,
+ _read CHAR(2) NOT NULL DEFAULT 0,
+ _update CHAR(2) NOT NULL DEFAULT 0,
+ _delete CHAR(2) NOT NULL DEFAULT 0,
+ PRIMARY KEY(id)
+);
+
+CREATE TABLE aros (
+ id INTEGER(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ parent_id INTEGER(10) DEFAULT NULL,
+ model VARCHAR(255) DEFAULT '',
+ foreign_key INTEGER(10) UNSIGNED DEFAULT NULL,
+ alias VARCHAR(255) DEFAULT '',
+ lft INTEGER(10) DEFAULT NULL,
+ rght INTEGER(10) DEFAULT NULL,
+ PRIMARY KEY (id)
+);
\ No newline at end of file
diff --git a/site/config/sql/i18n.php b/site/config/sql/i18n.php
new file mode 100644
index 0000000..72233ff
--- /dev/null
+++ b/site/config/sql/i18n.php
@@ -0,0 +1,56 @@
+ array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
+ 'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'),
+ 'model' => array('type'=>'string', 'null' => false, 'key' => 'index'),
+ 'foreign_key' => array('type'=>'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
+ 'field' => array('type'=>'string', 'null' => false, 'key' => 'index'),
+ 'content' => array('type'=>'text', 'null' => true, 'default' => NULL),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/config/sql/i18n.sql b/site/config/sql/i18n.sql
new file mode 100644
index 0000000..484d8a2
--- /dev/null
+++ b/site/config/sql/i18n.sql
@@ -0,0 +1,26 @@
+# $Id: i18n.sql 7945 2008-12-19 02:16:01Z gwoo $
+#
+# Copyright 2005-2008, Cake Software Foundation, Inc.
+#
+# Licensed under The MIT License
+# Redistributions of files must retain the above copyright notice.
+# http://www.opensource.org/licenses/mit-license.php The MIT License
+
+CREATE TABLE i18n (
+ id int(10) NOT NULL auto_increment,
+ locale varchar(6) NOT NULL,
+ model varchar(255) NOT NULL,
+ foreign_key int(10) NOT NULL,
+ field varchar(255) NOT NULL,
+ content mediumtext,
+ PRIMARY KEY (id),
+# UNIQUE INDEX I18N_LOCALE_FIELD(locale, model, foreign_key, field),
+# INDEX I18N_LOCALE_ROW(locale, model, foreign_key),
+# INDEX I18N_LOCALE_MODEL(locale, model),
+# INDEX I18N_FIELD(model, foreign_key, field),
+# INDEX I18N_ROW(model, foreign_key),
+ INDEX locale (locale),
+ INDEX model (model),
+ INDEX row_id (foreign_key),
+ INDEX field (field)
+);
\ No newline at end of file
diff --git a/site/config/sql/sessions.php b/site/config/sql/sessions.php
new file mode 100644
index 0000000..7f00a26
--- /dev/null
+++ b/site/config/sql/sessions.php
@@ -0,0 +1,53 @@
+ array('type'=>'string', 'null' => false, 'key' => 'primary'),
+ 'data' => array('type'=>'text', 'null' => true, 'default' => NULL),
+ 'expires' => array('type'=>'integer', 'null' => true, 'default' => NULL),
+ 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/config/sql/sessions.sql b/site/config/sql/sessions.sql
new file mode 100644
index 0000000..23a1925
--- /dev/null
+++ b/site/config/sql/sessions.sql
@@ -0,0 +1,16 @@
+# $Id: sessions.sql 7118 2008-06-04 20:49:29Z gwoo $
+#
+# Copyright 2005-2008, Cake Software Foundation, Inc.
+# 1785 E. Sahara Avenue, Suite 490-204
+# Las Vegas, Nevada 89104
+#
+# Licensed under The MIT License
+# Redistributions of files must retain the above copyright notice.
+# http://www.opensource.org/licenses/mit-license.php The MIT License
+
+CREATE TABLE cake_sessions (
+ id varchar(255) NOT NULL default '',
+ data text,
+ expires int(11) default NULL,
+ PRIMARY KEY (id)
+);
\ No newline at end of file
diff --git a/site/controllers/pages_controller.php b/site/controllers/pages_controller.php
new file mode 100644
index 0000000..0e17106
--- /dev/null
+++ b/site/controllers/pages_controller.php
@@ -0,0 +1,86 @@
+redirect('/');
+ }
+ $page = $subpage = $title = null;
+
+ if (!empty($path[0])) {
+ $page = $path[0];
+ }
+ if (!empty($path[1])) {
+ $subpage = $path[1];
+ }
+ if (!empty($path[$count - 1])) {
+ $title = Inflector::humanize($path[$count - 1]);
+ }
+ $this->set(compact('page', 'subpage', 'title'));
+ $this->render(join('/', $path));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/site/index.php b/site/index.php
new file mode 100644
index 0000000..4e60b84
--- /dev/null
+++ b/site/index.php
@@ -0,0 +1,24 @@
+
\ No newline at end of file
diff --git a/site/tmp/cache/models/cake_model_default_pmgr_list b/site/tmp/cache/models/cake_model_default_pmgr_list
new file mode 100644
index 0000000..fbaa15f
--- /dev/null
+++ b/site/tmp/cache/models/cake_model_default_pmgr_list
@@ -0,0 +1,2 @@
+1243395559
+a:36:{i:0;s:12:"pmgr_actions";i:1;s:27:"pmgr_actions_late_schedules";i:2;s:17:"pmgr_charge_types";i:3;s:19:"pmgr_config_options";i:4;s:18:"pmgr_config_system";i:5;s:20:"pmgr_config_versions";i:6;s:22:"pmgr_contact_addresses";i:7;s:19:"pmgr_contact_emails";i:8;s:20:"pmgr_contact_methods";i:9;s:19:"pmgr_contact_phones";i:10;s:13:"pmgr_contacts";i:11;s:18:"pmgr_group_options";i:12;s:22:"pmgr_group_permissions";i:13;s:11:"pmgr_groups";i:14;s:19:"pmgr_late_schedules";i:15;s:19:"pmgr_lease_contacts";i:16;s:16:"pmgr_lease_types";i:17;s:11:"pmgr_leases";i:18;s:14:"pmgr_map_units";i:19;s:9:"pmgr_maps";i:20;s:10:"pmgr_notes";i:21;s:18:"pmgr_payment_types";i:22;s:15:"pmgr_site_areas";i:23;s:21:"pmgr_site_memberships";i:24;s:17:"pmgr_site_options";i:25;s:10:"pmgr_sites";i:26;s:24:"pmgr_transaction_charges";i:27;s:25:"pmgr_transaction_payments";i:28;s:25:"pmgr_transaction_receipts";i:29;s:32:"pmgr_transaction_reconciliations";i:30;s:15:"pmgr_unit_sizes";i:31;s:15:"pmgr_unit_types";i:32;s:10:"pmgr_units";i:33;s:17:"pmgr_user_options";i:34;s:10:"pmgr_users";i:35;s:5:"posts";}
diff --git a/site/tmp/cache/persistent/cake_core_core_paths b/site/tmp/cache/persistent/cake_core_core_paths
new file mode 100644
index 0000000..f13836c
--- /dev/null
+++ b/site/tmp/cache/persistent/cake_core_core_paths
@@ -0,0 +1,2 @@
+1243395572
+a:10:{s:4:"libs";a:1:{i:0;s:39:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\";}s:5:"model";a:1:{i:0;s:45:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\";}s:8:"behavior";a:1:{i:0;s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behaviors\\\\";}s:10:"controller";a:1:{i:0;s:50:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\";}s:9:"component";a:1:{i:0;s:61:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\components\\\\";}s:4:"view";a:1:{i:0;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\";}s:6:"helper";a:1:{i:0;s:52:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\helpers\\\\";}s:4:"cake";a:1:{i:0;s:34:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\";}s:6:"vendor";a:1:{i:0;s:37:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\vendors\\\\";}s:5:"shell";a:1:{i:0;s:47:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\console\\\\libs\\\\";}}
diff --git a/site/tmp/cache/persistent/cake_core_default_en_us b/site/tmp/cache/persistent/cake_core_default_en_us
new file mode 100644
index 0000000..2c0aef8
--- /dev/null
+++ b/site/tmp/cache/persistent/cake_core_default_en_us
@@ -0,0 +1,2 @@
+1243395572
+a:1:{s:11:"LC_MESSAGES";a:1:{s:0:"";a:1:{s:7:"default";a:0:{}}}}
diff --git a/site/tmp/cache/persistent/cake_core_dir_map b/site/tmp/cache/persistent/cake_core_dir_map
new file mode 100644
index 0000000..1a91880
--- /dev/null
+++ b/site/tmp/cache/persistent/cake_core_dir_map
@@ -0,0 +1,2 @@
+1243395572
+a:3:{s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model";a:4:{i:0;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model";i:1;s:56:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources";i:2;s:60:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources\\\\dbo";i:3;s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behaviors";}s:38:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs";a:24:{i:0;s:38:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs";i:1;s:43:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view";i:2;s:53:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\scaffolds";i:3;s:49:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\pages";i:4;s:51:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts";i:5;s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\xml";i:6;s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\rss";i:7;s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\js";i:8;s:57:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\email";i:9;s:62:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\text";i:10;s:62:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\html";i:11;s:51:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\helpers";i:12;s:50:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\errors";i:13;s:52:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements";i:14;s:58:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements\\\\email";i:15;s:63:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\text";i:16;s:63:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\html";i:17;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model";i:18;s:56:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources";i:19;s:60:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources\\\\dbo";i:20;s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behaviors";i:21;s:49:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller";i:22;s:60:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\components";i:23;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\cache";}s:44:"D:/Website/localhost/public_html\\\\pmgr\\\\models";a:3:{i:0;s:44:"D:/Website/localhost/public_html\\\\pmgr\\\\models";i:1;s:56:"D:\\\\Website\\\\localhost\\\\public_html\\\\pmgr\\\\models\\\\datasources";i:2;s:54:"D:\\\\Website\\\\localhost\\\\public_html\\\\pmgr\\\\models\\\\behaviors";}}
diff --git a/site/tmp/cache/persistent/cake_core_file_map b/site/tmp/cache/persistent/cake_core_file_map
new file mode 100644
index 0000000..e4a4928
--- /dev/null
+++ b/site/tmp/cache/persistent/cake_core_file_map
@@ -0,0 +1,2 @@
+1243395572
+a:2:{s:4:"Core";a:11:{s:12:"Overloadable";s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\overloadable.php";s:10:"Validation";s:53:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\validation.php";s:8:"Behavior";s:57:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behavior.php";s:17:"ConnectionManager";s:67:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\connection_manager.php";s:5:"Model";s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\model.php";s:9:"Component";s:63:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\component.php";s:6:"Helper";s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\helper.php";s:4:"View";s:52:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\view.php";s:10:"Controller";s:64:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\controller.php";s:4:"l10n";s:47:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\l10n.php";s:4:"i18n";s:47:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\i18n.php";}s:5:"Model";a:1:{s:8:"AppModel";s:51:"D:/Website/localhost/public_html\\\\pmgr\\\\app_model.php";}}
diff --git a/site/views/elements/email/html/default.ctp b/site/views/elements/email/html/default.ctp
new file mode 100644
index 0000000..a217c80
--- /dev/null
+++ b/site/views/elements/email/html/default.ctp
@@ -0,0 +1,31 @@
+
+ ' . $line . '
';
+endforeach;
+?>
\ No newline at end of file
diff --git a/site/views/elements/email/text/default.ctp b/site/views/elements/email/text/default.ctp
new file mode 100644
index 0000000..70e05eb
--- /dev/null
+++ b/site/views/elements/email/text/default.ctp
@@ -0,0 +1,25 @@
+
+
\ No newline at end of file
diff --git a/site/views/layouts/ajax.ctp b/site/views/layouts/ajax.ctp
new file mode 100644
index 0000000..4857f18
--- /dev/null
+++ b/site/views/layouts/ajax.ctp
@@ -0,0 +1,25 @@
+
+
\ No newline at end of file
diff --git a/site/views/layouts/default.ctp b/site/views/layouts/default.ctp
new file mode 100644
index 0000000..db4d2aa
--- /dev/null
+++ b/site/views/layouts/default.ctp
@@ -0,0 +1,64 @@
+
+
+
+
+ charset(); ?>
+
+
+
+
+ meta('icon');
+
+ echo $html->css('cake.generic');
+
+ echo $scripts_for_layout;
+ ?>
+
+
+
+
+
+
+ flash(); ?>
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/site/views/layouts/email/html/default.ctp b/site/views/layouts/email/html/default.ctp
new file mode 100644
index 0000000..72c5442
--- /dev/null
+++ b/site/views/layouts/email/html/default.ctp
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+ This email was sent using the CakePHP Framework
+
+
diff --git a/site/views/layouts/email/text/default.ctp b/site/views/layouts/email/text/default.ctp
new file mode 100644
index 0000000..4c87cf7
--- /dev/null
+++ b/site/views/layouts/email/text/default.ctp
@@ -0,0 +1,29 @@
+
+
+
+
+This email was sent using the CakePHP Framework, http://cakephp.org.
+
diff --git a/site/views/layouts/flash.ctp b/site/views/layouts/flash.ctp
new file mode 100644
index 0000000..a1b56d7
--- /dev/null
+++ b/site/views/layouts/flash.ctp
@@ -0,0 +1,44 @@
+
+
+
+
+charset(); ?>
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/site/views/layouts/js/default.ctp b/site/views/layouts/js/default.ctp
new file mode 100644
index 0000000..d94dc90
--- /dev/null
+++ b/site/views/layouts/js/default.ctp
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/site/views/layouts/rss/default.ctp b/site/views/layouts/rss/default.ctp
new file mode 100644
index 0000000..94067f2
--- /dev/null
+++ b/site/views/layouts/rss/default.ctp
@@ -0,0 +1,17 @@
+header();
+
+if (!isset($channel)) {
+ $channel = array();
+}
+if (!isset($channel['title'])) {
+ $channel['title'] = $title_for_layout;
+}
+
+echo $rss->document(
+ $rss->channel(
+ array(), $channel, $content_for_layout
+ )
+);
+
+?>
\ No newline at end of file
diff --git a/site/views/layouts/xml/default.ctp b/site/views/layouts/xml/default.ctp
new file mode 100644
index 0000000..c688702
--- /dev/null
+++ b/site/views/layouts/xml/default.ctp
@@ -0,0 +1,2 @@
+header()); ?>
+
\ No newline at end of file
diff --git a/site/views/pages/home.ctp b/site/views/pages/home.ctp
new file mode 100644
index 0000000..f19d628
--- /dev/null
+++ b/site/views/pages/home.ctp
@@ -0,0 +1,80 @@
+Sweet, "Pmgr" got Baked by CakePHP!
+
+ 0):
+ Debugger::checkSessionKey();
+endif;
+?>
+
+';
+ __('Your tmp directory is writable.');
+ echo '';
+ else:
+ echo '';
+ __('Your tmp directory is NOT writable.');
+ echo '';
+ endif;
+?>
+
+
+';
+ echo sprintf(__('The %s is being used for caching. To change the config edit APP/config/core.php ', true), ''. $settings['engine'] . 'Engine');
+ echo '';
+ else:
+ echo '';
+ __('Your cache is NOT working. Please check the settings in APP/config/core.php');
+ echo '';
+ endif;
+?>
+
+
+';
+ __('Your database configuration file is present.');
+ $filePresent = true;
+ echo '';
+ else:
+ echo '';
+ __('Your database configuration file is NOT present.');
+ echo '
';
+ __('Rename config/database.php.default to config/database.php');
+ echo '';
+ endif;
+?>
+
+getDataSource('default');
+?>
+
+isConnected()):
+ echo '';
+ __('Cake is able to connect to the database.');
+ echo '';
+ else:
+ echo '';
+ __('Cake is NOT able to connect to the database.');
+ echo '';
+ endif;
+?>
+
+
+
+
+', APP . 'views' . DS . 'layouts' . DS . 'default.ctp.
', APP . 'webroot' . DS . 'css');
+?>
+
diff --git a/site/webroot/.htaccess b/site/webroot/.htaccess
new file mode 100644
index 0000000..f9d8b93
--- /dev/null
+++ b/site/webroot/.htaccess
@@ -0,0 +1,6 @@
+
+ RewriteEngine On
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
+
\ No newline at end of file
diff --git a/site/webroot/css.php b/site/webroot/css.php
new file mode 100644
index 0000000..eb9be9f
--- /dev/null
+++ b/site/webroot/css.php
@@ -0,0 +1,102 @@
+compress($data);
+ $ratio = 100 - (round(strlen($output) / strlen($data), 3) * 100);
+ $output = " /* file: $name, ratio: $ratio% */ " . $output;
+ return $output;
+ }
+/**
+ * Enter description here...
+ *
+ * @param unknown_type $path
+ * @param unknown_type $content
+ * @return unknown
+ */
+ function write_css_cache($path, $content) {
+ if (!is_dir(dirname($path))) {
+ mkdir(dirname($path));
+ }
+ $cache = new File($path);
+ return $cache->write($content);
+ }
+
+ if (preg_match('|\.\.|', $url) || !preg_match('|^ccss/(.+)$|i', $url, $regs)) {
+ die('Wrong file name.');
+ }
+
+ $filename = 'css/' . $regs[1];
+ $filepath = CSS . $regs[1];
+ $cachepath = CACHE . 'css' . DS . str_replace(array('/','\\'), '-', $regs[1]);
+
+ if (!file_exists($filepath)) {
+ die('Wrong file name.');
+ }
+
+ if (file_exists($cachepath)) {
+ $templateModified = filemtime($filepath);
+ $cacheModified = filemtime($cachepath);
+
+ if ($templateModified > $cacheModified) {
+ $output = make_clean_css($filepath, $filename);
+ write_css_cache($cachepath, $output);
+ } else {
+ $output = file_get_contents($cachepath);
+ }
+ } else {
+ $output = make_clean_css($filepath, $filename);
+ write_css_cache($cachepath, $output);
+ $templateModified = time();
+ }
+
+ header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');
+ header("Content-Type: text/css");
+ header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
+ header("Cache-Control: max-age=86400, must-revalidate"); // HTTP/1.1
+ header("Pragma: cache"); // HTTP/1.0
+ print $output;
+?>
\ No newline at end of file
diff --git a/site/webroot/css/cake.generic.css b/site/webroot/css/cake.generic.css
new file mode 100644
index 0000000..50ee79a
--- /dev/null
+++ b/site/webroot/css/cake.generic.css
@@ -0,0 +1,480 @@
+/* SVN FILE: $Id: cake.generic.css 7945 2008-12-19 02:16:01Z gwoo $ */
+/**
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
+ * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+ * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.app.webroot.css
+ * @since CakePHP(tm)
+ * @version $Revision: 7945 $
+ * @modifiedby $LastChangedBy: gwoo $
+ * @lastmodified $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+
+
+* {
+ margin:0;
+ padding:0;
+}
+
+/* General Style Info */
+body {
+ background: #003d4c;
+ color: #fff;
+ font-family:'lucida grande',verdana,helvetica,arial,sans-serif;
+ font-size:90%;
+ margin: 0;
+}
+a {
+ background:#fff;
+ color: #003d4c;
+ text-decoration: underline;
+ font-weight: bold;
+}
+a:hover {
+ background:#fff;
+ color: #003d4c;
+ text-decoration:none;
+}
+a img {
+ border:none;
+}
+h1, h2, h3, h4 {
+ font-weight: normal;
+}
+h1 {
+ background:#fff;
+ color: #003d4c;
+ font-size: 100%;
+ margin: 0.1em 0;
+}
+h2 {
+ background:#fff;
+ color: #e32;
+ font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif;
+ font-size: 190%;
+ margin: 0.3em 0;
+ padding-top: 0.8em;
+}
+h3 {
+ color: #993;
+ font-family:'Gill Sans','lucida grande',helvetica, arial, sans-serif;
+ font-size: 165%;
+ padding-top: 1.5em;
+}
+h4 {
+ color: #993;
+ font-weight: normal;
+ padding-top: 0.5em;
+}
+ul, li {
+ margin: 0 12px;
+}
+
+/* Layout */
+#container {
+ text-align: left;
+}
+
+#header{
+ padding: 10px 20px;
+}
+#header h1 {
+ background: #003d4c url('../img/cake.icon.gif') no-repeat left;
+ color: #fff;
+ padding: 0px 30px;
+}
+#header h1 a {
+ color: #fff;
+ background: #003d4c;
+ font-weight: normal;
+ text-decoration: none;
+}
+#header h1 a:hover {
+ color: #fff;
+ background: #003d4c;
+ text-decoration: underline;
+}
+#content{
+ background: #fff;
+ clear: both;
+ color: #333;
+ padding: 10px 20px 40px 20px;
+ overflow: auto;
+}
+#footer {
+ clear: both;
+ padding: 6px 10px;
+ text-align: right;
+}
+
+/* Tables */
+table {
+ background: #fff;
+ border:1px solid #ccc;
+ border-right:0;
+ clear: both;
+ color: #333;
+ margin-bottom: 10px;
+ width: 100%;
+}
+th {
+ background: #f2f2f2;
+ border:1px solid #bbb;
+ border-top: 1px solid #fff;
+ border-left: 1px solid #fff;
+ text-align: center;
+}
+th a {
+ background:#f2f2f2;
+ display: block;
+ padding: 2px 4px;
+ text-decoration: none;
+}
+th a:hover {
+ background: #ccc;
+ color: #333;
+ text-decoration: none;
+}
+table tr td {
+ background: #fff;
+ border-right: 1px solid #ccc;
+ padding: 4px;
+ text-align: center;
+ vertical-align: top;
+}
+table tr.altrow td {
+ background: #f4f4f4;
+}
+td.actions {
+ text-align: center;
+ white-space: nowrap;
+}
+td.actions a {
+ margin: 0px 6px;
+}
+.cake-sql-log table {
+ background: #f4f4f4;
+}
+.cake-sql-log td {
+ padding: 4px 8px;
+ text-align: left;
+}
+
+/* Paging */
+div.paging {
+ background:#fff;
+ color: #ccc;
+ margin-bottom: 2em;
+}
+div.paging div.disabled {
+ color: #ddd;
+ display: inline;
+}
+div.paging span {
+}
+div.paging span.current {
+ color: #000;
+}
+div.paging span a {
+}
+
+/* Scaffold View */
+dl {
+ line-height: 2em;
+ margin: 0em 0em;
+ width: 60%;
+}
+dl.altrow {
+ background: #f4f4f4;
+}
+dt {
+ font-weight: bold;
+ padding-left: 4px;
+ vertical-align: top;
+}
+dd {
+ margin-left: 10em;
+ margin-top: -2em;
+ vertical-align: top;
+}
+
+/* Forms */
+form {
+ clear: both;
+ margin-right: 20px;
+ padding: 0;
+ width: 80%;
+}
+fieldset {
+ border: 1px solid #ccc;
+ margin-top: 30px;
+ padding: 16px 20px;
+}
+fieldset legend {
+ background:#fff;
+ color: #e32;
+ font-size: 160%;
+ font-weight: bold;
+}
+fieldset fieldset {
+ margin-top: 0px;
+ margin-bottom: 20px;
+ padding: 16px 10px;
+}
+fieldset fieldset legend {
+ font-size: 120%;
+ font-weight: normal;
+}
+fieldset fieldset div {
+ clear: left;
+ margin: 0 20px;
+}
+form div {
+ clear: both;
+ margin-bottom: 1em;
+ padding: .5em;
+ vertical-align: text-top;
+}
+form div.input {
+ color: #444;
+}
+form div.required {
+ color: #333;
+ font-weight: bold;
+}
+form div.submit {
+ border: 0;
+ clear: both;
+ margin-top: 10px;
+ margin-left: 140px;
+}
+label {
+ display: block;
+ font-size: 110%;
+ padding-right: 20px;
+}
+input, textarea {
+ clear: both;
+ font-size: 140%;
+ font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif;
+ padding: 2px;
+ width: 100%;
+}
+select {
+ clear: both;
+ font-size: 120%;
+ vertical-align: text-bottom;
+}
+select[multiple=multiple] {
+ width: 100%;
+}
+option {
+ font-size: 120%;
+ padding: 0 3px;
+}
+input[type=checkbox] {
+ clear: left;
+ float: left;
+ margin: 0px 6px 7px 2px;
+ width: auto;
+}
+input[type=radio] {
+ float:left;
+ width:auto;
+ margin: 0 3px 7px 0;
+}
+div.radio label {
+ margin: 0 0 6px 20px;
+}
+input[type=submit] {
+ display: inline;
+ font-size: 110%;
+ padding: 2px 5px;
+ width: auto;
+ vertical-align: bottom;
+}
+
+/* Notices and Errors */
+div.message {
+ clear: both;
+ color: #900;
+ font-size: 140%;
+ font-weight: bold;
+ margin: 1em 0;
+}
+div.error-message {
+ clear: both;
+ color: #900;
+ font-weight: bold;
+}
+p.error {
+ background-color: #e32;
+ color: #fff;
+ font-family: Courier, monospace;
+ font-size: 120%;
+ line-height: 140%;
+ padding: 0.8em;
+ margin: 1em 0;
+}
+p.error em {
+ color: #000;
+ font-weight: normal;
+ line-height: 140%;
+}
+.notice {
+ background: #ffcc00;
+ color: #000;
+ display: block;
+ font-family: Courier, monospace;
+ font-size: 120%;
+ line-height: 140%;
+ padding: 0.8em;
+ margin: 1em 0;
+}
+.success {
+ background: green;
+ color: #fff;
+}
+
+/* Actions */
+div.actions ul {
+ margin: 0px 0;
+ padding: 0;
+}
+div.actions li {
+ display: inline;
+ list-style-type: none;
+ line-height: 2em;
+ margin: 0 2em 0 0;
+ white-space: nowrap;
+}
+div.actions ul li a {
+ background:#fff;
+ color: #003d4c;
+ text-decoration: none;
+}
+div.actions ul li a:hover {
+ color: #333;
+ text-decoration: underline;
+}
+
+/* Related */
+div.related {
+ clear: both;
+ display: block;
+}
+
+/* Debugging */
+pre {
+ color: #000;
+ background: #f0f0f0;
+ padding: 1em;
+}
+pre.cake-debug {
+ background: #ffcc00;
+ font-size: 120%;
+ line-height: 140%;
+ margin-top: 1em;
+ overflow: auto;
+ position: relative;
+}
+div.cake-stack-trace {
+ background: #fff;
+ border: 4px dotted #ffcc00;
+ color: #333;
+ margin: 0px;
+ padding: 6px;
+ font-size: 120%;
+ line-height: 140%;
+ overflow: auto;
+ position: relative;
+}
+div.cake-code-dump pre {
+ position: relative;
+ overflow: auto;
+}
+div.cake-stack-trace pre, div.cake-code-dump pre {
+ color: #000;
+ background-color: #F0F0F0;
+ margin: 0px;
+ padding: 1em;
+ overflow: auto;
+}
+div.cake-code-dump pre, div.cake-code-dump pre code {
+ clear: both;
+ font-size: 12px;
+ line-height: 15px;
+ margin: 4px 2px;
+ padding: 4px;
+ overflow: auto;
+}
+div.cake-code-dump span.code-highlight {
+ background-color: #ff0;
+ padding: 4px;
+}
+div.code-coverage-results div.code-line {
+ padding-left:5px;
+ display:block;
+ margin-left:10px;
+}
+div.code-coverage-results div.uncovered span.content {
+ background:#ecc;
+}
+div.code-coverage-results div.covered span.content {
+ background:#cec;
+}
+div.code-coverage-results div.ignored span.content {
+ color:#aaa;
+}
+div.code-coverage-results span.line-num {
+ color:#666;
+ display:block;
+ float:left;
+ width:20px;
+ text-align:right;
+ margin-right:5px;
+}
+div.code-coverage-results span.line-num strong {
+ color:#666;
+}
+div.code-coverage-results div.start {
+ border:1px solid #aaa;
+ border-width:1px 1px 0px 1px;
+ margin-top:30px;
+ padding-top:5px;
+}
+div.code-coverage-results div.end {
+ border:1px solid #aaa;
+ border-width:0px 1px 1px 1px;
+ margin-bottom:30px;
+ padding-bottom:5px;
+}
+div.code-coverage-results div.realstart {
+ margin-top:0px;
+}
+div.code-coverage-results p.note {
+ color:#bbb;
+ padding:5px;
+ margin:5px 0 10px;
+ font-size:10px;
+}
+div.code-coverage-results span.result-bad {
+ color: #a00;
+}
+div.code-coverage-results span.result-ok {
+ color: #fa0;
+}
+div.code-coverage-results span.result-good {
+ color: #0a0;
+}
\ No newline at end of file
diff --git a/site/webroot/favicon.ico b/site/webroot/favicon.ico
new file mode 100644
index 0000000000000000000000000000000000000000..b36e81f2f35133dede48dc18f78d3e1a3353f7bc
GIT binary patch
literal 372
zcmV-)0gL{LP)Ce4&o}{bgKX)=r-B_#-Qs`WM)Da5Prgl
zsZ%T@FChJjuHh1`0m$SsVlk8KBKw^@522Z3S}fqzqUy4nLhVp$W)@MMy#WF!pk3U7
zB65kQi)kZ#rBYK5tRifZI?>XjFU4<@lsph9Z1>blC@{qW13mof`13?K&cOa
zOrfx~(a*Br=IF!2lMFyj!pzT(o0Foa
zdn-*>Om~4(V_pR~MF2EGA^8La000jFEC2ui02BZe000D*@X1N5t>>`K@|6NJ6h&YL
z1u`%~wUB3glC5+ga)976a!3oFOhFu(2DMubr5G5VhQ{x4NGt;hD1iW&9tgW!0iZB!
z6O)6HG-waF&;)>@C@r&FLW6?XF3Wfe6jmrIZUbdo27(g_16K`ZTZ}-3IRcmfa});+
jCL}5ZNSK%y0t-u|r5FwZRfnys7YD7i0<9mpxe)+6uKiOz
literal 0
HcmV?d00001
diff --git a/site/webroot/img/cake.power.gif b/site/webroot/img/cake.power.gif
new file mode 100644
index 0000000000000000000000000000000000000000..8f8d570a2e24d86f0ad7730ee8f2435fd49f152c
GIT binary patch
literal 201
zcmV;)05<&ZTq0L2I(c1A@d@rg`ENj#vn
zcl`yi#iKX*jb2F7vd0WQgUq5Tw}Jp}g+ZnCeBY3dYNI+m71%bHRfx4UCkD2th(Q*@
zmd5r+MJNYn7dispatch($url);
+ }
+ if (Configure::read() > 0) {
+ echo "";
+ }
+?>
\ No newline at end of file
diff --git a/site/webroot/js/vendors.php b/site/webroot/js/vendors.php
new file mode 100644
index 0000000..a6fcf32
--- /dev/null
+++ b/site/webroot/js/vendors.php
@@ -0,0 +1,42 @@
+
\ No newline at end of file
diff --git a/site/webroot/test.php b/site/webroot/test.php
new file mode 100644
index 0000000..485a68b
--- /dev/null
+++ b/site/webroot/test.php
@@ -0,0 +1,181 @@
+
+ * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+ *
+ * Licensed under The Open Group Test Suite License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @filesource
+ * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
+ * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
+ * @package cake
+ * @subpackage cake.cake.tests.libs
+ * @since CakePHP(tm) v 1.2.0.4433
+ * @version $Revision: 7945 $
+ * @modifiedby $LastChangedBy: gwoo $
+ * @lastmodified $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
+ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
+ */
+error_reporting(E_ALL);
+set_time_limit(0);
+ini_set('memory_limit','128M');
+ini_set('display_errors', 1);
+/**
+ * Use the DS to separate the directories in other defines
+ */
+ if (!defined('DS')) {
+ define('DS', DIRECTORY_SEPARATOR);
+ }
+/**
+ * These defines should only be edited if you have cake installed in
+ * a directory layout other than the way it is distributed.
+ * When using custom settings be sure to use the DS and do not add a trailing DS.
+ */
+
+/**
+ * The full path to the directory which holds "app", WITHOUT a trailing DS.
+ *
+ */
+ if (!defined('ROOT')) {
+ define('ROOT', dirname(dirname(dirname(__FILE__))));
+ }
+/**
+ * The actual directory name for the "app".
+ *
+ */
+ if (!defined('APP_DIR')) {
+ define('APP_DIR', basename(dirname(dirname(__FILE__))));
+ }
+/**
+ * The absolute path to the "cake" directory, WITHOUT a trailing DS.
+ *
+ */
+ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
+ define('CAKE_CORE_INCLUDE_PATH', 'D:\Website\localhost\CakePHP');
+ }
+
+/**
+ * Editing below this line should not be necessary.
+ * Change at your own risk.
+ *
+ */
+if (!defined('WEBROOT_DIR')) {
+ define('WEBROOT_DIR', basename(dirname(__FILE__)));
+}
+if (!defined('WWW_ROOT')) {
+ define('WWW_ROOT', dirname(__FILE__) . DS);
+}
+if (!defined('CORE_PATH')) {
+ if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) {
+ define('APP_PATH', null);
+ define('CORE_PATH', null);
+ } else {
+ define('APP_PATH', ROOT . DS . APP_DIR . DS);
+ define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
+ }
+}
+if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
+ trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
+}
+
+$corePath = Configure::corePaths('cake');
+if (isset($corePath[0])) {
+ define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
+} else {
+ define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
+}
+
+require_once CAKE_TESTS_LIB . 'test_manager.php';
+
+if (Configure::read('debug') < 1) {
+ die(__('Debug setting does not allow access to this url.', true));
+}
+
+if (!isset($_SERVER['SERVER_NAME'])) {
+ $_SERVER['SERVER_NAME'] = '';
+}
+if (empty( $_GET['output'])) {
+ $_GET['output'] = 'html';
+}
+/**
+ *
+ * Used to determine output to display
+ */
+define('CAKE_TEST_OUTPUT_HTML', 1);
+define('CAKE_TEST_OUTPUT_TEXT', 2);
+
+if (isset($_GET['output']) && $_GET['output'] == 'html') {
+ define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML);
+} else {
+ Debugger::output('txt');
+ define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT);
+}
+
+if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) {
+ CakePHPTestHeader();
+ include CAKE_TESTS_LIB . 'simpletest.php';
+ CakePHPTestSuiteFooter();
+ exit();
+}
+
+$analyzeCodeCoverage = false;
+if (isset($_GET['code_coverage'])) {
+ $analyzeCodeCoverage = true;
+ require_once CAKE_TESTS_LIB . 'code_coverage_manager.php';
+ if (!extension_loaded('xdebug')) {
+ CakePHPTestHeader();
+ include CAKE_TESTS_LIB . 'xdebug.php';
+ CakePHPTestSuiteFooter();
+ exit();
+ }
+}
+
+CakePHPTestHeader();
+CakePHPTestSuiteHeader();
+define('RUN_TEST_LINK', $_SERVER['PHP_SELF']);
+
+if (isset($_GET['group'])) {
+ if ('all' == $_GET['group']) {
+ TestManager::runAllTests(CakeTestsGetReporter());
+ } else {
+ if ($analyzeCodeCoverage) {
+ CodeCoverageManager::start($_GET['group'], CakeTestsGetReporter());
+ }
+ TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter());
+ if ($analyzeCodeCoverage) {
+ CodeCoverageManager::report();
+ }
+ }
+
+ CakePHPTestRunMore();
+ CakePHPTestAnalyzeCodeCoverage();
+} elseif (isset($_GET['case'])) {
+ if ($analyzeCodeCoverage) {
+ CodeCoverageManager::start($_GET['case'], CakeTestsGetReporter());
+ }
+
+ TestManager::runTestCase($_GET['case'], CakeTestsGetReporter());
+
+ if ($analyzeCodeCoverage) {
+ CodeCoverageManager::report();
+ }
+
+ CakePHPTestRunMore();
+ CakePHPTestAnalyzeCodeCoverage();
+} elseif (isset($_GET['show']) && $_GET['show'] == 'cases') {
+ CakePHPTestCaseList();
+} else {
+ CakePHPTestGroupTestList();
+}
+CakePHPTestSuiteFooter();
+$output = ob_get_clean();
+echo $output;
+?>
\ No newline at end of file
From 220284d20f1cb20523b22105e81562b9effe6abc Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 04:24:45 +0000
Subject: [PATCH 004/717] Added svn:ignore for all of the tmp directories
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@5 97e9348a-65ac-dc4b-aefc-98561f571b83
From c22be388cf249e7e473f1dc3d38fcc32012d3aa0 Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 04:35:43 +0000
Subject: [PATCH 005/717] Fixed the stupid svn:ignore properties, which all had
a trailing space (doh!)
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@6 97e9348a-65ac-dc4b-aefc-98561f571b83
From c5d5e2c6511a973db740dac709c243782e87e80e Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 19:23:05 +0000
Subject: [PATCH 006/717] Removed the cache files from the repository
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@7 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/tmp/cache/persistent/cake_core_core_paths | 2 --
site/tmp/cache/persistent/cake_core_default_en_us | 2 --
site/tmp/cache/persistent/cake_core_dir_map | 2 --
site/tmp/cache/persistent/cake_core_file_map | 2 --
4 files changed, 8 deletions(-)
delete mode 100644 site/tmp/cache/persistent/cake_core_core_paths
delete mode 100644 site/tmp/cache/persistent/cake_core_default_en_us
delete mode 100644 site/tmp/cache/persistent/cake_core_dir_map
delete mode 100644 site/tmp/cache/persistent/cake_core_file_map
diff --git a/site/tmp/cache/persistent/cake_core_core_paths b/site/tmp/cache/persistent/cake_core_core_paths
deleted file mode 100644
index f13836c..0000000
--- a/site/tmp/cache/persistent/cake_core_core_paths
+++ /dev/null
@@ -1,2 +0,0 @@
-1243395572
-a:10:{s:4:"libs";a:1:{i:0;s:39:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\";}s:5:"model";a:1:{i:0;s:45:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\";}s:8:"behavior";a:1:{i:0;s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behaviors\\\\";}s:10:"controller";a:1:{i:0;s:50:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\";}s:9:"component";a:1:{i:0;s:61:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\components\\\\";}s:4:"view";a:1:{i:0;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\";}s:6:"helper";a:1:{i:0;s:52:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\helpers\\\\";}s:4:"cake";a:1:{i:0;s:34:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\";}s:6:"vendor";a:1:{i:0;s:37:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\vendors\\\\";}s:5:"shell";a:1:{i:0;s:47:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\console\\\\libs\\\\";}}
diff --git a/site/tmp/cache/persistent/cake_core_default_en_us b/site/tmp/cache/persistent/cake_core_default_en_us
deleted file mode 100644
index 2c0aef8..0000000
--- a/site/tmp/cache/persistent/cake_core_default_en_us
+++ /dev/null
@@ -1,2 +0,0 @@
-1243395572
-a:1:{s:11:"LC_MESSAGES";a:1:{s:0:"";a:1:{s:7:"default";a:0:{}}}}
diff --git a/site/tmp/cache/persistent/cake_core_dir_map b/site/tmp/cache/persistent/cake_core_dir_map
deleted file mode 100644
index 1a91880..0000000
--- a/site/tmp/cache/persistent/cake_core_dir_map
+++ /dev/null
@@ -1,2 +0,0 @@
-1243395572
-a:3:{s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model";a:4:{i:0;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model";i:1;s:56:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources";i:2;s:60:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources\\\\dbo";i:3;s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behaviors";}s:38:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs";a:24:{i:0;s:38:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs";i:1;s:43:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view";i:2;s:53:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\scaffolds";i:3;s:49:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\pages";i:4;s:51:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts";i:5;s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\xml";i:6;s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\rss";i:7;s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\js";i:8;s:57:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\email";i:9;s:62:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\text";i:10;s:62:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\layouts\\\\email\\\\html";i:11;s:51:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\helpers";i:12;s:50:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\errors";i:13;s:52:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements";i:14;s:58:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements\\\\email";i:15;s:63:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\text";i:16;s:63:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\elements\\\\email\\\\html";i:17;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model";i:18;s:56:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources";i:19;s:60:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\datasources\\\\dbo";i:20;s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behaviors";i:21;s:49:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller";i:22;s:60:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\components";i:23;s:44:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\cache";}s:44:"D:/Website/localhost/public_html\\\\pmgr\\\\models";a:3:{i:0;s:44:"D:/Website/localhost/public_html\\\\pmgr\\\\models";i:1;s:56:"D:\\\\Website\\\\localhost\\\\public_html\\\\pmgr\\\\models\\\\datasources";i:2;s:54:"D:\\\\Website\\\\localhost\\\\public_html\\\\pmgr\\\\models\\\\behaviors";}}
diff --git a/site/tmp/cache/persistent/cake_core_file_map b/site/tmp/cache/persistent/cake_core_file_map
deleted file mode 100644
index e4a4928..0000000
--- a/site/tmp/cache/persistent/cake_core_file_map
+++ /dev/null
@@ -1,2 +0,0 @@
-1243395572
-a:2:{s:4:"Core";a:11:{s:12:"Overloadable";s:55:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\overloadable.php";s:10:"Validation";s:53:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\validation.php";s:8:"Behavior";s:57:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\behavior.php";s:17:"ConnectionManager";s:67:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\connection_manager.php";s:5:"Model";s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\model\\\\model.php";s:9:"Component";s:63:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\component.php";s:6:"Helper";s:54:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\helper.php";s:4:"View";s:52:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\view\\\\view.php";s:10:"Controller";s:64:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\controller\\\\controller.php";s:4:"l10n";s:47:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\l10n.php";s:4:"i18n";s:47:"D:\\\\Website\\\\localhost\\\\CakePHP\\\\cake\\\\libs\\\\i18n.php";}s:5:"Model";a:1:{s:8:"AppModel";s:51:"D:/Website/localhost/public_html\\\\pmgr\\\\app_model.php";}}
From 2665d012c2a38ceeab336f2be105ed3ed6554b3f Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 19:26:04 +0000
Subject: [PATCH 007/717] Added a scripts directory and the latest copy of our
sitelink conversion script. For the complete revision history of
sitelink2pmgr.pl, see branches/rent_manager_20090510 path of the 'domain'
repository
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@8 97e9348a-65ac-dc4b-aefc-98561f571b83
---
scripts/sitelink2rmgr.pl | 796 +++++++++++++++++++++++++++++++++++++++
1 file changed, 796 insertions(+)
create mode 100644 scripts/sitelink2rmgr.pl
diff --git a/scripts/sitelink2rmgr.pl b/scripts/sitelink2rmgr.pl
new file mode 100644
index 0000000..67b6863
--- /dev/null
+++ b/scripts/sitelink2rmgr.pl
@@ -0,0 +1,796 @@
+#perl -w
+use strict;
+use DBI;
+use Data::Dumper;
+use File::Copy;
+
+# 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', 'rentmgr', 'root', 'mysql97312519');
+my $db_handle = DBI->connect("DBI:mysql:database=$database;host=$hostname",
+ $user, $password,
+ {'RaiseError' => 1});
+
+
+my ($query, $result, $nrows, $row);
+my ($aicur_c_id, $aicur_ca_id, $aicur_cp_id, $aicur_ce_id) = (0, 0, 0, 0);
+my ($aicur_g_id, $aicur_gp_id, $aicur_user_id) = (0, 0, 0);
+my ($aicur_type_id, $aicur_size_id, $aicur_unit_id) = (0, 0, 0);
+my ($aicur_site_id, $aicur_area_id) = (0, 0);
+my ($aicur_lease_type_id, $aicur_lease_id) = (0, 0);
+my ($aicur_charge_id, $aicur_receipt_id, $aicur_payment_id) = (0, 0, 0);
+
+open(SCHEMA, "<$schema_file") || die ("Can't open schema ($!)\n");
+my $schema_query = "";
+while () {
+ next if /^\s*-- /;
+ $schema_query .= $_;
+ query($db_handle, $schema_query), $schema_query = ""
+ if /;\s*$/;
+}
+close(SCHEMA);
+
+++$aicur_c_id;
+$query = "INSERT INTO rmgr_contacts
+ (`id`, `first_name`, `middle_name`, `last_name`, `display_name`) VALUES
+ ($aicur_c_id, 'Abijah', 'M', 'Perkins', 'Perkins, Abijah')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_ca_id;
+$query = "INSERT INTO rmgr_contactAddresses
+ (`id`, `address`, `city`, `state`, `postcode`, `country`) VALUES
+ ($aicur_ca_id, '1324 N Liberty Lake Rd\nPMB 263', 'Liberty Lake', 'WA', '99019', 'USA')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'POST', $aicur_ca_id, 'MAIN', 'PRIMARY')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_ca_id;
+$query = "INSERT INTO rmgr_contactAddresses
+ (`id`, `address`, `city`, `state`, `postcode`, `country`) VALUES
+ ($aicur_ca_id, '5221 W Myrtlewood Ct', 'Spokane', 'WA', '99208', 'USA')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'POST', $aicur_ca_id, 'HOME', 'ALTERNATE')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_ca_id;
+$query = "INSERT INTO rmgr_contactAddresses
+ (`id`, `address`, `city`, `state`, `postcode`, `country`) VALUES
+ ($aicur_ca_id, 'PO Box 69', 'Granger', 'WA', '98932', 'USA')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'POST', $aicur_ca_id, 'HOME', 'ALTERNATE')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_cp_id;
+$query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`) VALUES
+ ($aicur_cp_id, 'MOBILE', '5098445573')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'PHONE', $aicur_cp_id, 'MAIN', 'PRIMARY')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_cp_id;
+$query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`) VALUES
+ ($aicur_cp_id, 'MOBILE', '5098445973')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'PHONE', $aicur_cp_id, 'MAIN', 'ALTERNATE')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_cp_id;
+$query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`) VALUES
+ ($aicur_cp_id, 'VIRTUAL', '5095901112')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'PHONE', $aicur_cp_id, 'BUSINESS', 'WORK')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_cp_id;
+$query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`) VALUES
+ ($aicur_cp_id, 'LANDLINE', '5098541491')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'PHONE', $aicur_cp_id, 'HOME', 'ALTERNATE')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_cp_id;
+$query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`) VALUES
+ ($aicur_cp_id, 'VIRTUAL', '8774488664')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'PHONE', $aicur_cp_id, 'BUSINESS', 'WORK')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_cp_id;
+$query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`) VALUES
+ ($aicur_cp_id, 'FAX', '8662960131')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'PHONE', $aicur_cp_id, 'BUSINESS', 'WORK')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_ce_id;
+$query = "INSERT INTO rmgr_contactEmails
+ (`id`, `email`) VALUES
+ ($aicur_ce_id, 'abijah\@PerkinsHouse.com')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'EMAIL', $aicur_ce_id, 'HOME', 'PRIMARY')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_ce_id;
+$query = "INSERT INTO rmgr_contactEmails
+ (`id`, `email`) VALUES
+ ($aicur_ce_id, 'abijah\@PerkinsREI.com')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'EMAIL', $aicur_ce_id, 'HOME', 'WORK')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_ce_id;
+$query = "INSERT INTO rmgr_contactEmails
+ (`id`, `email`) VALUES
+ ($aicur_ce_id, 'abijah\@ValleyStorage.com')";
+ query($db_handle, $query) || die("Unable to insert");
+$query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($aicur_c_id, 'EMAIL', $aicur_ce_id, 'BUSINESS', 'WORK')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_g_id;
+$query = "INSERT INTO rmgr_groups
+ (`id`, `code`, `name`)
+ VALUES
+ ($aicur_g_id, 'Owner', 'Owner Group')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_gp_id;
+$query = "INSERT INTO rmgr_groupPermissions
+ (`group_id`, `name`, `access`)
+ VALUES
+ ($aicur_gp_id, 'EVERYTHING', 'FORCED')";
+ query($db_handle, $query) || die("Unable to insert");
+
+
+++$aicur_user_id;
+$query = "INSERT INTO rmgr_users
+ (`id`, `code`, `login`, `contact_id`)
+ VALUES
+ ($aicur_user_id, 'AP', 'abijah', $aicur_c_id)";
+ query($db_handle, $query) || die("Unable to insert");
+
+
+++$aicur_site_id;
+$query = "INSERT INTO rmgr_sites
+ (`id`, `code`, `name`)
+ VALUES
+ ($aicur_site_id, 'VSS', 'Valley Storage')";
+ query($db_handle, $query) || die("Unable to insert");
+
+$query = "INSERT INTO rmgr_siteMemberships
+ (`site_id`, `user_id`, `group_id`)
+ VALUES
+ ($aicur_site_id, $aicur_user_id, $aicur_g_id)";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_area_id;
+$query = "INSERT INTO rmgr_siteAreas
+ (`id`, `site_id`, `code`, `name`)
+ VALUES
+ ($aicur_area_id, $aicur_site_id, 'Main', 'Main Facility Area')";
+ query($db_handle, $query) || die("Unable to insert");
+
+++$aicur_lease_type_id;
+$query = "INSERT INTO rmgr_leaseTypes
+ (`id`, `code`, `name`)
+ VALUES
+ ($aicur_lease_type_id, 'SL', 'Storage Lease')";
+ query($db_handle, $query) || die("Unable to insert");
+
+
+
+
+######################################################################
+######################################################################
+## query
+
+sub query {
+ my ($dbh, $sql) = @_;
+ #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);
+ }
+
+ #print("sth = " . Dumper($sth) . "\n");
+ #print("result = " . Dumper($result) . "\n");
+ return ($sth, $result);
+}
+
+
+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] : "");
+}
+
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+##
+## UNITS
+##
+
+
+######################################################################
+## Unit Types
+
+$query = "SELECT * FROM UnitType ORDER BY TypeID";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Unit Types\n");
+
+foreach $row (@$result) {
+ $query = "INSERT INTO rmgr_unitTypes
+ (`id`, `code`, `name`)
+ VALUES
+ ($row->{'TypeID'}, 'xxx', '$row->{'UnitType'}')";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+
+######################################################################
+## Unit Sizes
+
+$query = "SELECT * FROM UnitInfo WHERE UnitID <> 'POS\$' ORDER BY UnitID";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Units\n");
+
+my (%unit_size_map);
+foreach $row (@$result) {
+ my $sz = sizeCode($row->{'Width'}, $row->{'Depth'});
+ next if defined $unit_size_map{$sz};
+ $unit_size_map{$sz} = { 'id' => ++$aicur_size_id };
+ $unit_size_map{$sz}{'rent'} = $row->{'StdRent'};
+ $unit_size_map{$sz}{'dep'} = $row->{'StdSecDep'};
+ my $szid = $unit_size_map{$sz}{'id'};
+
+ $query = "INSERT INTO rmgr_unitSizes
+ (`id`, `type_id`, `code`, `name`, `width`, `depth`,
+ `deposit`, `amount`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($szid, $row->{'Type'}, $sz, $sz,
+ $internal_adjustment_factor * $row->{'Width'},
+ $internal_adjustment_factor * $row->{'Depth'},
+ $row->{'StdSecDep'}, $row->{'StdRent'})
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+
+######################################################################
+## Units
+
+my (%unit_map);
+foreach $row (@$result) {
+ my $sz = sizeCode($row->{'Width'}, $row->{'Depth'});
+ my $szid = $unit_size_map{$sz}{'id'};
+ $unit_map{$row->{'UnitID'}} = ++$aicur_unit_id;
+ my $uid = $unit_map{$row->{'UnitID'}};
+
+ $query = "INSERT INTO rmgr_units
+ (`id`, `size_id`, `code`, `name`,
+ `status`,
+ `sort_order`, `walk_order`, `deposit`, `amount`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($uid, $szid, $row->{'UnitID'}, $row->{'UnitID'},
+ $row->{'Rented'} ?'OCCUPIED' :($row->{'Rentable'} ?'VACANT' :'UNAVAILABLE'),
+ $uid, $uid, $row->{'StdSecDep'}, $row->{'StdRent'})
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+
+######################################################################
+## 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);
+
+$query =
+ "INSERT INTO rmgr_maps (id, site_id, area_id, width, depth) VALUES\n" .
+ " (1, $aicur_site_id, $aicur_area_id," .
+ ($info{'extents'}{'right'} - $info{'extents'}{'left'}) . ", " .
+ ($info{'extents'}{'bottom'} - $info{'extents'}{'top'}) . ")";
+query($db_handle, $query) || die("Unable to insert");
+
+# 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";
+$result = query($sdbh, $query);
+
+# Go through each one, calculating the map location
+foreach $row (@$result) {
+ my $uid = $unit_map{$row->{'UnitID'}};
+
+ $query = # pt_bottom, pt_right,
+ "INSERT INTO rmgr_mapUnits (map_id, unit_id,
+ pt_top, pt_left,
+ transpose) VALUES
+ (" . join(", ",
+ 1, $uid,
+ $internal_adjustment_factor * ($row->{'pt_t'}),
+ $internal_adjustment_factor * ($row->{'pt_l'}),
+ $row->{'reverseWL'}) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+##
+## TENANTS
+##
+
+
+######################################################################
+## Tenants
+
+$query = "SELECT * FROM TenantInfo WHERE FirstName <> 'POS' ORDER BY TenantID";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Tenants\n");
+
+my %stmap = ( 1=>'AK', 14=>'ID', 48=>'WA' );
+my (%tenant_map);
+foreach $row (@$result) {
+ $tenant_map{$row->{'TenantID'}} = { 'id' => ++$aicur_c_id };
+ my $cid = $tenant_map{$row->{'TenantID'}}{'id'};
+
+ $query = "INSERT INTO rmgr_contacts
+ (`id`, `first_name`, `middle_name`, `last_name`, `display_name`, `id_num`, `id_state`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($cid, $row->{'FirstName'}, $row->{'MiddleName'}, $row->{'LastName'},
+ "$row->{'LastName'}, $row->{'FirstName'}",
+ $row->{'IDNum'} || undef, $row->{'IDNum'} ? $stmap{$row->{'DLStateID'}} : undef)
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ if ($row->{'City'}) {
+ $query = "INSERT INTO rmgr_contactAddresses
+ (`id`, `address`, `city`, `state`, `postcode`, `country`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ (++$aicur_ca_id,
+ #$row->{'HomeAddress'}
+ $row->{'HomeAddress'} . ($row->{'HomeAddr2'} ? "\n".$row->{'HomeAddr2'} : "") || undef,
+ $row->{'City'}, $stmap{$row->{'StateID'}}, $row->{'Zip'} || undef, 'USA')
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($cid, 'POST', $aicur_ca_id, 'HOME', 'PRIMARY')";
+ query($db_handle, $query) || die("Unable to insert");
+ }
+
+ 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'}) {
+ $query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`, `ext`) VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ (++$aicur_cp_id, $_->{'type'}, $_->{'phone'}, $_->{'ext'})))
+ . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($cid, 'PHONE', $aicur_cp_id, 'MAIN', $_->{'preference'})))
+ . ")";
+ query($db_handle, $query) || die("Unable to insert");
+ }
+ }
+
+ if ($row->{'Email'}) {
+ $query = "INSERT INTO rmgr_contactEmails
+ (`id`, `email`) VALUES
+ (".++$aicur_ce_id.", '$row->{'Email'}')";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUE
+ ($cid, 'EMAIL', $aicur_ce_id, 'MAIN', 'PRIMARY')";
+ query($db_handle, $query) || die("Unable to insert");
+ }
+
+ next unless $row->{'AltFirstName'} || $row->{'AltLastName'} || $row->{'AltAddress'} || $row->{'AltPhone'};
+
+ $tenant_map{$row->{'TenantID'}}{'alt'} = ++$aicur_c_id;
+ $cid = $tenant_map{$row->{'TenantID'}}{'alt'};
+
+ $query = "INSERT INTO rmgr_contacts
+ (`id`, `first_name`, `middle_name`, `last_name`, `display_name`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($cid,
+ $row->{'AltFirstName'} || undef,
+ $row->{'AltMI'} || undef,
+ $row->{'AltLastName'} || undef,
+ ($row->{'AltLastName'} && $row->{'AltFirstName'}
+ ? "$row->{'AltLastName'}, $row->{'AltFirstName'}"
+ : ($row->{'AltLastName'} || $row->{'AltFirstName'} || '')))
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ if ($row->{'AltCity'}) {
+ $query = "INSERT INTO rmgr_contactAddresses
+ (`id`, `address`, `city`, `state`, `postcode`, `country`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ (++$aicur_ca_id,
+ $row->{'AltAddress'} . ($row->{'AltAddr2'} ? "\n".$row->{'AltAddr2'} : ""),
+ $row->{'AltCity'}, $stmap{$row->{'AltStateID'}}, $row->{'AltZip'}, 'USA')
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($cid, 'POST', $aicur_ca_id, 'MAIN', 'PRIMARY')";
+ query($db_handle, $query) || die("Unable to insert");
+ }
+
+ if ($row->{'AltPhone'}) {
+ $query = "INSERT INTO rmgr_contactPhones
+ (`id`, `type`, `phone`, `ext`) VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ (++$aicur_cp_id, 'LANDLINE', $row->{'AltPhone'}, undef)
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "INSERT INTO rmgr_contactMethods
+ (`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
+ ($cid, 'PHONE', $aicur_cp_id, 'MAIN', 'PRIMARY')";
+ query($db_handle, $query) || die("Unable to insert");
+ }
+}
+
+
+######################################################################
+## Tenant Leases
+
+$query = "SELECT L.*, A.TenantID FROM TenantLedger L LEFT JOIN `Access` A ON A.LedgerID = L.LedgerID WHERE L.UnitID <> 'POS\$' ORDER BY L.LedgerID";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Tenant Ledgers\n");
+my (%ledger_map);
+foreach $row (@$result) {
+ $ledger_map{$row->{'LedgerID'}} = ++$aicur_lease_id;
+ my $cid = $tenant_map{$row->{'TenantID'}}{'id'};
+ my $uid = $unit_map{$row->{'UnitID'}};
+ my $lid = $ledger_map{$row->{'LedgerID'}};
+
+ $query = "INSERT INTO rmgr_leases
+ (`id`, `number`, `lease_type_id`, `unit_id`,
+ `lease_date`, `movein_date`,
+ `moveout_date`, `close_date`,
+ `amount`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($lid, $row->{'LedgerID'}, $aicur_lease_type_id, $uid,
+ datefmt($row->{'DateIn'}), datefmt($row->{'DateIn'}),
+ datefmt($row->{'DateOut'}), datefmt($row->{'DateClosed'}),
+ $row->{'Rent'})
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "INSERT INTO rmgr_leaseContacts
+ (`lease_id`, `contact_id`, `type`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($lid, $cid, 'TENANT')
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $cid = $tenant_map{$row->{'TenantID'}}{'alt'};
+ next unless $cid;
+
+ $query = "INSERT INTO rmgr_leaseContacts
+ (`lease_id`, `contact_id`, `type`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($lid, $cid, 'ALTERNATE')
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+
+######################################################################
+## Security Deposits
+
+$query = "SELECT L.LedgerID, L.UnitID, C.ChargeAmount FROM TenantLedger L INNER JOIN Charges C ON C.LedgerID = L.LedgerID WHERE L.UnitID <> 'POS\$' AND C.ChargeDescription = 'Security Deposit' ORDER BY UnitID";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Security Deposits\n");
+
+foreach $row (@$result) {
+ my $uid = $unit_map{$row->{'UnitID'}};
+ $query = "UPDATE rmgr_leases
+ SET deposit = $row->{'ChargeAmount'}
+ WHERE `number` = '$row->{'LedgerID'}'";
+ query($db_handle, $query) || die("Unable to update");
+}
+
+
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+######################################################################
+##
+## TRANSACTIONS
+##
+
+######################################################################
+## Charges
+
+$query = "SELECT * FROM Charges ORDER BY ChargeID";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Charges\n");
+
+my %charge_type_map = ('Rent' => 2, 'Security Deposit' => 1, 'Late Fee' => 3);
+my %charge_map;
+foreach $row (@$result) {
+ $charge_map{$row->{'ChargeID'}} = ++$aicur_charge_id;
+ my $lid = $ledger_map{$row->{'LedgerID'}};
+ my $chid = $charge_map{$row->{'ChargeID'}};
+
+ $query = "INSERT INTO rmgr_transactionCharges
+ (`id`, `type_id`, `lease_id`,
+ `charge_date`, `charge_to_date`,
+ `amount`, `tax`, `total`, `comment`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($chid, $charge_type_map{$row->{'ChargeDescription'}}, $lid,
+ datefmt($row->{'ChargeDate'}), datefmt($row->{'EndDate'}),
+ $row->{'ChargeAmount'}, $row->{'TaxAmount'},
+ $row->{'ChargeAmount'} + $row->{'TaxAmount'},
+ "ChargeID #".$row->{'ChargeID'})
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "UPDATE rmgr_transactionCharges";
+ $query .= " SET due_date = DATE_ADD(charge_date, INTERVAL IF(type_id=2,10,0) DAY)";
+ query($db_handle, $query) || die("Unable to update");
+}
+
+
+######################################################################
+## Receipts
+
+$query = "SELECT * FROM Receipts ORDER BY ReceiptNum";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Receipts\n");
+
+my %receipt_map;
+foreach $row (@$result) {
+ $receipt_map{$row->{'ReceiptNum'}} = ++$aicur_receipt_id;
+ my $lid = $ledger_map{$row->{'LedgerID'}};
+ my $rid = $receipt_map{$row->{'ReceiptNum'}};
+
+ $query = "INSERT INTO rmgr_transactionReceipts
+ (`id`, `stamp`, `comment`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($rid, datefmt($row->{'ReceiptDate'}),
+ "ReceiptNum #".$row->{'ReceiptNum'})
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+# $query = "SELECT * FROM Receipts R INNER JOIN Payments P ON P.ReceiptNum = R.ReceiptNum" .
+# " WHERE P.PaymentDate <> R.ReceiptDate";
+# $result = query($sdbh, $query);
+# $nrows = @$result;
+# print(" $nrows Mismatches\n");
+
+# foreach $row (@$result) {
+# my @keys = qw(PaymentID P.ReceiptNum PaymentDate ReceiptDate);
+# print("Payment Date Mismatch:\n");
+# print(" ",
+# join("\n ", map({sprintf("%-12s => %s", $_, $row->{$_})} @keys)),
+# "\n");
+# }
+
+######################################################################
+## Payments
+
+$query = "SELECT * FROM Payments ORDER BY PaymentID";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Payments\n");
+
+my %payment_map;
+foreach $row (@$result) {
+ $payment_map{$row->{'PaymentID'}} = ++$aicur_payment_id;
+ my $pid = $payment_map{$row->{'PaymentID'}};
+ my $rid = $receipt_map{$row->{'ReceiptNum'}};
+ my $chid = $charge_map{$row->{'ChargeID'}};
+
+ $query = "INSERT INTO rmgr_transactionPayments
+ (`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($pid, $rid,
+ $row->{'PaymentDate'} =~ m%3/25/2009% ? 8 : $row->{'PaymentType'},
+ $row->{'PaymentAmount'},
+ "PaymentID #".$row->{'PaymentID'} . ($row->{'Memo'} ? "; ".$row->{'Memo'} : ""))
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+
+ $query = "INSERT INTO rmgr_transactionReconciliations
+ (`charge_id`, `receipt_id`, `amount`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($chid, $rid, $row->{'PaymentAmount'})
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+__END__
+
+######################################################################
+## Reconciliations
+
+# $query = "SELECT ReceiptNum, SUM(PaymentAmount) AS 'rTot'";
+# $query .= " FROM Payments GROUP BY ReceiptNum, ORDER BY ReceiptNum";
+$query = "SELECT ChargeID, ReceiptNum";
+$query .= " FROM Payments GROUP BY ChargeID, ReceiptNum ORDER BY ChargeID, ReceiptNum";
+$result = query($sdbh, $query);
+$nrows = @$result;
+print(" $nrows Reconciliations\n");
+
+foreach $row (@$result) {
+ my $chid = $charge_map{$row->{'ChargeID'}};
+ my $rid = $receipt_map{$row->{'ReceiptNum'}};
+
+ $query = "INSERT INTO rmgr_transactionReconciliations
+ (`charge_id`, `receipt_id`, `amount`)
+ VALUES (" .
+ join(", ", map({defined $_ ? "'$_'" : "NULL"}
+ ($chid, $rid, 0)
+ )) . ")";
+ query($db_handle, $query) || die("Unable to insert");
+}
+
+$query ="UPDATE rmgr_transactionReconciliations R
+ JOIN (SELECT P.receipt_id AS rid,
+ IF(COALESCE(Ch.total, 0)disconnect();
+
From 0da1080b86437973717f53b462cb808a3b15be15 Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 19:47:48 +0000
Subject: [PATCH 008/717] Added database schema file. For the complete revision
history of schema.sql, see branches/rent_manager_20090510/db path of the
'domain' repository
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@9 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 985 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 985 insertions(+)
create mode 100644 db/schema.sql
diff --git a/db/schema.sql b/db/schema.sql
new file mode 100644
index 0000000..f38e1d9
--- /dev/null
+++ b/db/schema.sql
@@ -0,0 +1,985 @@
+--
+-- Database 'rentmgr'
+
+-- REVISIT : 20090511
+-- Perhaps "Rent Master" instead of "Rent Manager" ?
+-- Perhaps "Property Master" ?
+-- Perhaps better to market under several names:
+-- "Self Storage Master", "Apartment Master", etc.
+
+
+-- AP:
+-- Originally authored for MySQL.
+-- However, requirements to consider / keep in mind:
+-- PostgreSQL: Don't want to be tied to ONLY MySQL.
+-- SQLite: Will likely require a standalone option.
+
+-- REVISIT : 20090511
+-- I would like timestamps to note when things change, but
+-- I don't think we can rely on the magic of MySQL to update
+-- them, since we may be required to use other engines.
+-- At the moment, I'll keep the MySQL statements, but we
+-- may have to move this logic into the application :-/
+
+
+DROP DATABASE IF EXISTS `rentmgr`;
+CREATE DATABASE `rentmgr`;
+USE `rentmgr`;
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## SOFTWARE CONFIGURATION
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_configSystem
+
+DROP TABLE IF EXISTS `rmgr_configSystem`;
+CREATE TABLE `rmgr_configSystem` (
+ `version_id` INT(10) UNSIGNED NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+LOCK TABLES `rmgr_configSystem` WRITE;
+INSERT INTO `rmgr_configSystem` (`version_id`)
+ VALUES
+ (1);
+UNLOCK TABLES;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_configVersions
+
+DROP TABLE IF EXISTS `rmgr_configVersions`;
+CREATE TABLE `rmgr_configVersions` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `schema` INT UNSIGNED NOT NULL DEFAULT 1, -- DB REVISION
+ `major` INT UNSIGNED NOT NULL,
+ `minor` INT UNSIGNED NOT NULL,
+ `bugfix` INT UNSIGNED NOT NULL DEFAULT 0,
+
+ -- REVISIT : 20090511
+ -- Should we just use the 'notes' table instead?
+ `comment` VARCHAR(255) DEFAULT NULL,
+ `stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+LOCK TABLES `rmgr_configVersions` WRITE;
+INSERT INTO `rmgr_configVersions` (`id`, `schema`, `major`, `minor`, `bugfix`, `stamp`, `comment`)
+ VALUES
+ (1, 1, 0, 1, 0, '2009-05-11 06:00', 'First revision');
+UNLOCK TABLES;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_configOptions
+
+DROP TABLE IF EXISTS `rmgr_configOptions`;
+CREATE TABLE `rmgr_configOptions` (
+ `name` VARCHAR(50) NOT NULL,
+ `value` VARCHAR(255) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`name`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## CONTACTS (PEOPLE and COMPANIES)
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_contacts
+
+DROP TABLE IF EXISTS `rmgr_contacts`;
+CREATE TABLE `rmgr_contacts` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `first_name` VARCHAR(255) DEFAULT NULL,
+ `middle_name` VARCHAR(255) DEFAULT NULL,
+ `last_name` VARCHAR(255) DEFAULT NULL,
+ `company_name` VARCHAR(255) DEFAULT NULL,
+ `display_name` VARCHAR(512) NOT NULL,
+
+ -- FEDERAL ID, e.g. SSN or EIN
+ `id_federal` VARCHAR(16) DEFAULT NULL,
+
+ -- STATE ID, e.g. drivers license
+ `id_num` VARCHAR(16) DEFAULT NULL,
+ `id_state` CHAR(2) DEFAULT NULL,
+ `id_exp` DATE DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_contactAddress
+
+DROP TABLE IF EXISTS `rmgr_contactAddresses`;
+CREATE TABLE `rmgr_contactAddresses` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `address` VARCHAR(255) DEFAULT NULL,
+ `city` VARCHAR(255) DEFAULT NULL,
+ `state` CHAR(2) DEFAULT NULL, -- REVISIT : Convert to ENUM
+ `postcode` VARCHAR(12) DEFAULT NULL,
+ `country` VARCHAR(128) DEFAULT NULL, -- REVISIT : Convert to ENUM
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_contactPhones
+
+DROP TABLE IF EXISTS `rmgr_contactPhones`;
+CREATE TABLE `rmgr_contactPhones` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `type` ENUM('LANDLINE',
+ 'MOBILE',
+ 'VIRTUAL',
+ 'PAGER',
+ 'FAX')
+ NOT NULL DEFAULT 'LANDLINE',
+ `phone` VARCHAR(18) NOT NULL,
+ `ext` VARCHAR(6) DEFAULT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ KEY `number_key` (`phone`),
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_contactEmails
+
+DROP TABLE IF EXISTS `rmgr_contactEmails`;
+CREATE TABLE `rmgr_contactEmails` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `email` VARCHAR(128) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ KEY `email_key` (`email`),
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_contactMethods
+
+DROP TABLE IF EXISTS `rmgr_contactMethods`;
+CREATE TABLE `rmgr_contactMethods` (
+ `contact_id` INT(10) UNSIGNED NOT NULL,
+ `method` ENUM('POST',
+ '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',
+-- `position` TINYINT UNSIGNED NOT NULL DEFAULT 1,
+
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`contact_id`, `method`, `method_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## GROUPS
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_groups
+
+DROP TABLE IF EXISTS `rmgr_groups`;
+CREATE TABLE `rmgr_groups` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ -- REVISIT : 20090511
+ -- code may not be userful
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_groupOptions
+
+DROP TABLE IF EXISTS `rmgr_groupOptions`;
+CREATE TABLE `rmgr_groupOptions` (
+ `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 rmgr_groupPermissions
+
+DROP TABLE IF EXISTS `rmgr_groupPermissions`;
+CREATE TABLE `rmgr_groupPermissions` (
+ `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
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_users
+
+DROP TABLE IF EXISTS `rmgr_users`;
+CREATE TABLE `rmgr_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,
+
+ -- Contact information for this user
+ `contact_id` INT(10) UNSIGNED NOT NULL,
+
+ -- Specific comments
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_userOptions
+
+DROP TABLE IF EXISTS `rmgr_userOptions`;
+CREATE TABLE `rmgr_userOptions` (
+ `user_id` INT(10) UNSIGNED NOT NULL,
+ `name` VARCHAR(50) NOT NULL,
+ `value` VARCHAR(255) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`user_id`, `name`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## SITES
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_sites
+
+DROP TABLE IF EXISTS `rmgr_sites`;
+CREATE TABLE `rmgr_sites` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ UNIQUE KEY `site_code` (`code`),
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_siteOptions
+
+DROP TABLE IF EXISTS `rmgr_siteOptions`;
+CREATE TABLE `rmgr_siteOptions` (
+ `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 rmgr_siteMemberships
+--
+-- 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 rmgr_users U
+-- LEFT JOIN rmgr_siteMembership M ON M.user_id = U.id
+-- LEFT JOIN rmgr_groups G ON G.id = M.group_id
+-- LEFT JOIN rmgr_groupPermissions P ON P.group_id = G.id
+-- GROUP BY U.id, P.name
+
+DROP TABLE IF EXISTS `rmgr_siteMemberships`;
+CREATE TABLE `rmgr_siteMemberships` (
+ `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 rmgr_siteAreas
+
+DROP TABLE IF EXISTS `rmgr_siteAreas`;
+CREATE TABLE `rmgr_siteAreas` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `site_id` INT(10) UNSIGNED NOT NULL,
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## UNITS
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_unitTypes
+
+DROP TABLE IF EXISTS `rmgr_unitTypes`;
+CREATE TABLE `rmgr_unitTypes` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_unitSizes
+
+DROP TABLE IF EXISTS `rmgr_unitSizes`;
+CREATE TABLE `rmgr_unitSizes` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `type_id` INT(10) UNSIGNED NOT NULL,
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+ `name` VARCHAR(80) NOT NULL,
+ `width` SMALLINT UNSIGNED NOT NULL, -- inches
+ `depth` SMALLINT UNSIGNED NOT NULL, -- inches
+ `height` SMALLINT UNSIGNED DEFAULT NULL, -- inches
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ `deposit` FLOAT(12,2) DEFAULT NULL,
+ `amount` FLOAT(12,2) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_units
+
+
+DROP TABLE IF EXISTS `rmgr_units`;
+CREATE TABLE `rmgr_units` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `size_id` INT(10) UNSIGNED NOT NULL,
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+ `name` VARCHAR(80) NOT NULL,
+
+ `status` ENUM('DELETED',
+ 'DAMAGED',
+ 'COMPANY',
+ 'UNAVAILABLE',
+ 'RESERVED',
+ 'DIRTY',
+ 'VACANT',
+ 'OCCUPIED',
+ 'LATE', -- NOT SURE
+ 'LOCKED',
+ 'LIENED')
+ NOT NULL DEFAULT 'VACANT',
+
+ `sort_order` MEDIUMINT UNSIGNED NOT NULL,
+ `walk_order` MEDIUMINT UNSIGNED NOT NULL,
+
+ `deposit` FLOAT(12,2) DEFAULT NULL,
+ `amount` FLOAT(12,2) DEFAULT NULL,
+
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## ACTIONS
+-- ##
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_actions
+
+DROP TABLE IF EXISTS `rmgr_actions`;
+CREATE TABLE `rmgr_actions` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `action` ENUM('LETTER',
+ 'GATELOCK',
+ 'OVERLOCK',
+ 'LIEN',
+ 'AUCTION')
+ NOT NULL,
+
+ -- Which letter, or other specific action?
+ -- REVISIT : Are there other specific actions?
+ `item_id` INT(10) UNSIGNED DEFAULT NULL,
+
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_lateSchedules
+
+DROP TABLE IF EXISTS `rmgr_lateSchedules`;
+CREATE TABLE `rmgr_lateSchedules` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_lateScheduleActions
+
+DROP TABLE IF EXISTS `rmgr_lateScheduleActions`;
+CREATE TABLE `rmgr_lateScheduleActions` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `late_schedule_id` INT(10) UNSIGNED DEFAULT NULL,
+ `days_past_due` SMALLINT NOT NULL,
+ `recurring` TINYINT DEFAULT 0,
+ `action_id` INT(10) UNSIGNED DEFAULT NULL,
+-- REVISIT : 20090513
+-- Should we have a specific fee list, or just use account
+-- `fee_id` INT(10) UNSIGNED DEFAULT NULL,
+ `account_id` INT(10) UNSIGNED DEFAULT NULL,
+ `amount` FLOAT(12,2) DEFAULT NULL,
+ `tax` FLOAT(12,2) DEFAULT NULL,
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## LEASES
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_leaseTypes
+
+DROP TABLE IF EXISTS `rmgr_leaseTypes`;
+CREATE TABLE `rmgr_leaseTypes` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `code` VARCHAR(12) NOT NULL, -- User style "id"
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_leases
+
+DROP TABLE IF EXISTS `rmgr_leases`;
+CREATE TABLE `rmgr_leases` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ -- Allow user to specify their own lease numbers
+ -- If NULL, `id` will be used
+ `number` VARCHAR(20) DEFAULT NULL,
+
+ `lease_type_id` INT(10) UNSIGNED NOT NULL,
+ `unit_id` INT(10) UNSIGNED NOT NULL,
+ `late_schedule_id` INT(10) UNSIGNED DEFAULT NULL,
+
+ `lease_date` DATE NOT NULL,
+ `movein_planed_date` DATE DEFAULT NULL,
+ `movein_date` DATE DEFAULT NULL,
+ `moveout_date` DATE DEFAULT NULL,
+ `moveout_planed_date` DATE DEFAULT NULL,
+ `notice_given_date` DATE DEFAULT NULL,
+ `notice_received_date` DATE DEFAULT NULL,
+ `close_date` DATE DEFAULT NULL,
+
+ `deposit` FLOAT(12,2) DEFAULT NULL,
+ `amount` FLOAT(12,2) DEFAULT NULL,
+
+ `next_amount` FLOAT(12,2) DEFAULT NULL,
+ `next_amount_date` DATE DEFAULT NULL,
+
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_leaseAltContacts
+
+DROP TABLE IF EXISTS `rmgr_leaseContacts`;
+CREATE TABLE `rmgr_leaseContacts` (
+ `lease_id` INT(10) UNSIGNED NOT NULL,
+ `contact_id` INT(10) UNSIGNED NOT NULL,
+
+ -- What type of contact is this for the lease?
+ `type` ENUM('TENANT', -- PRIMARY TENANT
+ 'COTENANT', -- ADDITIONAL TENANT
+ 'ALTERNATE') -- ALTERNATE CONTACT ONLY
+ NOT NULL DEFAULT 'TENANT',
+
+ -- If the tenant is removed as part of the lease
+ `active` TINYINT DEFAULT 1,
+
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`lease_id`, `contact_id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## TRANSACTIONS
+-- ##
+
+-- # Charge
+-- # - Issued against customer lease
+-- # - associated with account (i.e. QuickBooks account / category)
+-- # Receipt
+-- # - Collections of payments paid at one time
+-- # Payment
+-- # - Credited towards customer (or lease?)
+-- # - may be more than customer owes
+-- # - cash/check/charge/ach/etc
+-- # Reconciliation
+-- # - Associates a payment with the charge
+-- # - Indicates amount of credit towards charge
+-- # - Payments may cover several charges
+-- # - Several payments may cover the same charge
+
+
+-- Which charges haven not been paid?
+-- SELECT C.id AS cid, C.total AS total, COALESCE(SUM(R.amount),0) AS paid
+-- FROM rmgr_transactionCharges C
+-- LEFT JOIN rmgr_transactionReconciliations R ON R.charge_id = C.id
+-- GROUP BY C.id
+-- HAVING paid < C.total
+
+-- SELECT ChL.lid AS lid, U.name, C.display_name,
+-- SUM(ChL.total) AS total, SUM(ChL.paid) AS paid,
+-- SUM(ChL.total) - SUM(ChL.paid) AS owing
+-- FROM (SELECT Ch.lease_id AS lid, Ch.total AS total, COALESCE(SUM(R.amount),0) AS paid
+-- FROM rmgr_transactionCharges Ch
+-- LEFT JOIN rmgr_transactionReconciliations R ON R.charge_id = Ch.id
+-- WHERE Ch.due_date < NOW()
+-- GROUP BY Ch.id
+-- HAVING paid < Ch.total) ChL
+-- LEFT JOIN rmgr_leases L ON L.id = ChL.lid
+-- LEFT JOIN rmgr_leaseContacts Lc ON Lc.lease_id = L.id AND Lc.type = 'TENANT'
+-- LEFT JOIN rmgr_contacts C ON C.id = Lc.contact_id
+-- LEFT JOIN rmgr_units U ON U.id = L.unit_id
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_chargeTypes
+
+DROP TABLE IF EXISTS `rmgr_chargeTypes`;
+CREATE TABLE `rmgr_chargeTypes` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+ `account_id` INT(10) UNSIGNED NOT NULL, -- quickbooks tracking
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+LOCK TABLES `rmgr_chargeTypes` WRITE;
+INSERT INTO `rmgr_chargeTypes` (`id`, `name`, `account_id`)
+ VALUES
+ (1, 'Security Deposit', 0),
+ (2, 'Rent', 0),
+ (3, 'Late Charge', 0);
+UNLOCK TABLES;
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_paymentTypes
+
+DROP TABLE IF EXISTS `rmgr_paymentTypes`;
+CREATE TABLE `rmgr_paymentTypes` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+ `tillable` TINYINT(1) NOT NULL DEFAULT 1, -- Does manager collect by hand?
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+LOCK TABLES `rmgr_paymentTypes` WRITE;
+INSERT INTO `rmgr_paymentTypes` (`id`, `name`, `tillable`)
+ VALUES
+ (1, 'Cash', 1),
+ (2, 'Check', 1),
+ (3, 'Money Order', 1),
+ (4, 'ACH', 0),
+ (5, 'Debit Card', 0),
+ (6, 'Credit Card', 0),
+ (7, 'Other Tillable', 1),
+ (8, 'Other Non-Tillable', 0);
+UNLOCK TABLES;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_transactionCharges
+
+DROP TABLE IF EXISTS `rmgr_transactionCharges`;
+CREATE TABLE `rmgr_transactionCharges` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `type_id` INT(10) UNSIGNED NOT NULL,
+ `lease_id` INT(10) UNSIGNED NOT NULL,
+ `charge_date` DATE NOT NULL,
+ `charge_to_date` DATE NOT NULL,
+ `due_date` DATE DEFAULT NULL,
+ `amount` FLOAT(12,2) NOT NULL,
+ `tax` FLOAT(12,2) NOT NULL,
+ `total` FLOAT(12,2) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_transactionReceipts
+
+DROP TABLE IF EXISTS `rmgr_transactionReceipts`;
+CREATE TABLE `rmgr_transactionReceipts` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_transactionPayments
+
+DROP TABLE IF EXISTS `rmgr_transactionPayments`;
+CREATE TABLE `rmgr_transactionPayments` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `receipt_id` INT(10) UNSIGNED NOT NULL,
+ `payment_type_id` INT(10) UNSIGNED NOT NULL,
+ `amount` FLOAT(12,2) NOT NULL,
+
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_transactionReconciliations
+
+DROP TABLE IF EXISTS `rmgr_transactionReconciliations`;
+CREATE TABLE `rmgr_transactionReconciliations` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `charge_id` INT(10) UNSIGNED NOT NULL,
+ -- REVISIT : 20090514
+ -- THIS SHOULD BE RECEIPT_ID, NOT PAYMENT_ID, RIGHT??
+ `receipt_id` INT(10) UNSIGNED NOT NULL,
+ `amount` FLOAT(12,2) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## SITE MAPS
+-- ##
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_maps
+
+
+DROP TABLE IF EXISTS `rmgr_maps`;
+CREATE TABLE `rmgr_maps` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `site_id` INT(10) UNSIGNED NOT NULL,
+ `area_id` INT(10) UNSIGNED NOT NULL,
+ `name` VARCHAR(80) DEFAULT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ `width` SMALLINT UNSIGNED NOT NULL, -- inches
+ `depth` SMALLINT UNSIGNED NOT NULL, -- inches
+
+ UNIQUE KEY `map_key` (`site_id`, `area_id`),
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_mapUnits
+
+
+DROP TABLE IF EXISTS `rmgr_mapUnits`;
+CREATE TABLE `rmgr_mapUnits` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `map_id` INT(10) UNSIGNED NOT NULL,
+ `unit_id` INT(10) UNSIGNED NOT NULL,
+ `pt_top` SMALLINT UNSIGNED NOT NULL, -- inches
+ `pt_left` SMALLINT UNSIGNED NOT NULL, -- inches
+-- `pt_bottom` SMALLINT UNSIGNED NOT NULL, -- inches
+-- `pt_right` SMALLINT UNSIGNED NOT NULL, -- inches
+ `transpose` SMALLINT UNSIGNED NOT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## NOTES
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE rmgr_notes
+
+DROP TABLE IF EXISTS `rmgr_notes`;
+CREATE TABLE `rmgr_notes` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ -- HISTORY is a note created by the system, when the
+ -- user changes a setting or field that has been
+ -- flagged for tracking.
+ -- USER is a manually entered note.
+ `type` ENUM('HISTORY',
+ 'USER')
+ NOT NULL DEFAULT 'USER',
+
+ -- `item` references the object type, and `item_id` denotes
+ -- the specific object to which this note is attached
+ `item_id` INT(10) UNSIGNED NOT NULL,
+ `item` ENUM('OPTION',
+ 'UNIT_TYPE',
+ 'UNIT_SIZE',
+ 'UNIT',
+ 'CUSTOMER',
+ 'SITE',
+ 'SITE_AREA',
+ 'USER') -- etc, etc
+ NOT NULL,
+
+ -- Text of the recorded note
+ `note` TEXT,
+
+ -- User that made this note, or if HISTORY, made the change
+ `user_id` INT(10) UNSIGNED NOT NULL,
+ `stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
From 2d9a85ad82b163363eee8ab2dd97f4b8979ebdc4 Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 20:25:00 +0000
Subject: [PATCH 009/717] Changed table naming convention
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@10 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 258 +++++++++++++++++++++++++-------------------------
1 file changed, 129 insertions(+), 129 deletions(-)
diff --git a/db/schema.sql b/db/schema.sql
index f38e1d9..f51eac3 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -1,5 +1,5 @@
--
--- Database 'rentmgr'
+-- Database 'property_manager'
-- REVISIT : 20090511
-- Perhaps "Rent Master" instead of "Rent Manager" ?
@@ -22,9 +22,9 @@
-- may have to move this logic into the application :-/
-DROP DATABASE IF EXISTS `rentmgr`;
-CREATE DATABASE `rentmgr`;
-USE `rentmgr`;
+DROP DATABASE IF EXISTS `property_manager`;
+CREATE DATABASE `property_manager`;
+USE `property_manager`;
-- ######################################################################
@@ -43,16 +43,16 @@ USE `rentmgr`;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_configSystem
+-- TABLE pmgr_config_system
-DROP TABLE IF EXISTS `rmgr_configSystem`;
-CREATE TABLE `rmgr_configSystem` (
+DROP TABLE IF EXISTS `pmgr_config_system`;
+CREATE TABLE `pmgr_config_system` (
`version_id` INT(10) UNSIGNED NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-LOCK TABLES `rmgr_configSystem` WRITE;
-INSERT INTO `rmgr_configSystem` (`version_id`)
+LOCK TABLES `pmgr_config_system` WRITE;
+INSERT INTO `pmgr_config_system` (`version_id`)
VALUES
(1);
UNLOCK TABLES;
@@ -60,10 +60,10 @@ UNLOCK TABLES;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_configVersions
+-- TABLE pmgr_config_versions
-DROP TABLE IF EXISTS `rmgr_configVersions`;
-CREATE TABLE `rmgr_configVersions` (
+DROP TABLE IF EXISTS `pmgr_config_versions`;
+CREATE TABLE `pmgr_config_versions` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`schema` INT UNSIGNED NOT NULL DEFAULT 1, -- DB REVISION
`major` INT UNSIGNED NOT NULL,
@@ -79,8 +79,8 @@ CREATE TABLE `rmgr_configVersions` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-LOCK TABLES `rmgr_configVersions` WRITE;
-INSERT INTO `rmgr_configVersions` (`id`, `schema`, `major`, `minor`, `bugfix`, `stamp`, `comment`)
+LOCK TABLES `pmgr_config_versions` WRITE;
+INSERT INTO `pmgr_config_versions` (`id`, `schema`, `major`, `minor`, `bugfix`, `stamp`, `comment`)
VALUES
(1, 1, 0, 1, 0, '2009-05-11 06:00', 'First revision');
UNLOCK TABLES;
@@ -88,10 +88,10 @@ UNLOCK TABLES;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_configOptions
+-- TABLE pmgr_config_options
-DROP TABLE IF EXISTS `rmgr_configOptions`;
-CREATE TABLE `rmgr_configOptions` (
+DROP TABLE IF EXISTS `pmgr_config_options`;
+CREATE TABLE `pmgr_config_options` (
`name` VARCHAR(50) NOT NULL,
`value` VARCHAR(255) NOT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
@@ -118,10 +118,10 @@ CREATE TABLE `rmgr_configOptions` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_contacts
+-- TABLE pmgr_contacts
-DROP TABLE IF EXISTS `rmgr_contacts`;
-CREATE TABLE `rmgr_contacts` (
+DROP TABLE IF EXISTS `pmgr_contacts`;
+CREATE TABLE `pmgr_contacts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`first_name` VARCHAR(255) DEFAULT NULL,
`middle_name` VARCHAR(255) DEFAULT NULL,
@@ -143,10 +143,10 @@ CREATE TABLE `rmgr_contacts` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_contactAddress
+-- TABLE pmgr_contact_addresses
-DROP TABLE IF EXISTS `rmgr_contactAddresses`;
-CREATE TABLE `rmgr_contactAddresses` (
+DROP TABLE IF EXISTS `pmgr_contact_addresses`;
+CREATE TABLE `pmgr_contact_addresses` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`address` VARCHAR(255) DEFAULT NULL,
`city` VARCHAR(255) DEFAULT NULL,
@@ -160,10 +160,10 @@ CREATE TABLE `rmgr_contactAddresses` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_contactPhones
+-- TABLE pmgr_contact_phones
-DROP TABLE IF EXISTS `rmgr_contactPhones`;
-CREATE TABLE `rmgr_contactPhones` (
+DROP TABLE IF EXISTS `pmgr_contact_phones`;
+CREATE TABLE `pmgr_contact_phones` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`type` ENUM('LANDLINE',
'MOBILE',
@@ -182,10 +182,10 @@ CREATE TABLE `rmgr_contactPhones` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_contactEmails
+-- TABLE pmgr_contact_emails
-DROP TABLE IF EXISTS `rmgr_contactEmails`;
-CREATE TABLE `rmgr_contactEmails` (
+DROP TABLE IF EXISTS `pmgr_contact_emails`;
+CREATE TABLE `pmgr_contact_emails` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`email` VARCHAR(128) NOT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
@@ -197,10 +197,10 @@ CREATE TABLE `rmgr_contactEmails` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_contactMethods
+-- TABLE pmgr_contact_methods
-DROP TABLE IF EXISTS `rmgr_contactMethods`;
-CREATE TABLE `rmgr_contactMethods` (
+DROP TABLE IF EXISTS `pmgr_contact_methods`;
+CREATE TABLE `pmgr_contact_methods` (
`contact_id` INT(10) UNSIGNED NOT NULL,
`method` ENUM('POST',
'PHONE',
@@ -242,10 +242,10 @@ CREATE TABLE `rmgr_contactMethods` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_groups
+-- TABLE pmgr_groups
-DROP TABLE IF EXISTS `rmgr_groups`;
-CREATE TABLE `rmgr_groups` (
+DROP TABLE IF EXISTS `pmgr_groups`;
+CREATE TABLE `pmgr_groups` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-- REVISIT : 20090511
-- code may not be userful
@@ -259,10 +259,10 @@ CREATE TABLE `rmgr_groups` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_groupOptions
+-- TABLE pmgr_group_options
-DROP TABLE IF EXISTS `rmgr_groupOptions`;
-CREATE TABLE `rmgr_groupOptions` (
+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,
@@ -274,10 +274,10 @@ CREATE TABLE `rmgr_groupOptions` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_groupPermissions
+-- TABLE pmgr_group_permissions
-DROP TABLE IF EXISTS `rmgr_groupPermissions`;
-CREATE TABLE `rmgr_groupPermissions` (
+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',
@@ -307,10 +307,10 @@ CREATE TABLE `rmgr_groupPermissions` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_users
+-- TABLE pmgr_users
-DROP TABLE IF EXISTS `rmgr_users`;
-CREATE TABLE `rmgr_users` (
+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"
@@ -331,10 +331,10 @@ CREATE TABLE `rmgr_users` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_userOptions
+-- TABLE pmgr_user_options
-DROP TABLE IF EXISTS `rmgr_userOptions`;
-CREATE TABLE `rmgr_userOptions` (
+DROP TABLE IF EXISTS `pmgr_user_options`;
+CREATE TABLE `pmgr_user_options` (
`user_id` INT(10) UNSIGNED NOT NULL,
`name` VARCHAR(50) NOT NULL,
`value` VARCHAR(255) NOT NULL,
@@ -361,10 +361,10 @@ CREATE TABLE `rmgr_userOptions` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_sites
+-- TABLE pmgr_sites
-DROP TABLE IF EXISTS `rmgr_sites`;
-CREATE TABLE `rmgr_sites` (
+DROP TABLE IF EXISTS `pmgr_sites`;
+CREATE TABLE `pmgr_sites` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`code` VARCHAR(12) NOT NULL, -- User style "id"
`name` VARCHAR(80) NOT NULL,
@@ -377,10 +377,10 @@ CREATE TABLE `rmgr_sites` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_siteOptions
+-- TABLE pmgr_site_options
-DROP TABLE IF EXISTS `rmgr_siteOptions`;
-CREATE TABLE `rmgr_siteOptions` (
+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,
@@ -392,20 +392,20 @@ CREATE TABLE `rmgr_siteOptions` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_siteMemberships
+-- 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 rmgr_users U
--- LEFT JOIN rmgr_siteMembership M ON M.user_id = U.id
--- LEFT JOIN rmgr_groups G ON G.id = M.group_id
--- LEFT JOIN rmgr_groupPermissions P ON P.group_id = G.id
+-- 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 `rmgr_siteMemberships`;
-CREATE TABLE `rmgr_siteMemberships` (
+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,
@@ -417,10 +417,10 @@ CREATE TABLE `rmgr_siteMemberships` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_siteAreas
+-- TABLE pmgr_site_areas
-DROP TABLE IF EXISTS `rmgr_siteAreas`;
-CREATE TABLE `rmgr_siteAreas` (
+DROP TABLE IF EXISTS `pmgr_site_areas`;
+CREATE TABLE `pmgr_site_areas` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`site_id` INT(10) UNSIGNED NOT NULL,
`code` VARCHAR(12) NOT NULL, -- User style "id"
@@ -448,10 +448,10 @@ CREATE TABLE `rmgr_siteAreas` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_unitTypes
+-- TABLE pmgr_unit_types
-DROP TABLE IF EXISTS `rmgr_unitTypes`;
-CREATE TABLE `rmgr_unitTypes` (
+DROP TABLE IF EXISTS `pmgr_unit_types`;
+CREATE TABLE `pmgr_unit_types` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`code` VARCHAR(12) NOT NULL, -- User style "id"
`name` VARCHAR(80) NOT NULL,
@@ -464,10 +464,10 @@ CREATE TABLE `rmgr_unitTypes` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_unitSizes
+-- TABLE pmgr_unit_sizes
-DROP TABLE IF EXISTS `rmgr_unitSizes`;
-CREATE TABLE `rmgr_unitSizes` (
+DROP TABLE IF EXISTS `pmgr_unit_sizes`;
+CREATE TABLE `pmgr_unit_sizes` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`type_id` INT(10) UNSIGNED NOT NULL,
`code` VARCHAR(12) NOT NULL, -- User style "id"
@@ -486,11 +486,11 @@ CREATE TABLE `rmgr_unitSizes` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_units
+-- TABLE pmgr_units
-DROP TABLE IF EXISTS `rmgr_units`;
-CREATE TABLE `rmgr_units` (
+DROP TABLE IF EXISTS `pmgr_units`;
+CREATE TABLE `pmgr_units` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`size_id` INT(10) UNSIGNED NOT NULL,
`code` VARCHAR(12) NOT NULL, -- User style "id"
@@ -537,10 +537,10 @@ CREATE TABLE `rmgr_units` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_actions
+-- TABLE pmgr_actions
-DROP TABLE IF EXISTS `rmgr_actions`;
-CREATE TABLE `rmgr_actions` (
+DROP TABLE IF EXISTS `pmgr_actions`;
+CREATE TABLE `pmgr_actions` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`action` ENUM('LETTER',
@@ -563,10 +563,10 @@ CREATE TABLE `rmgr_actions` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_lateSchedules
+-- TABLE pmgr_late_schedules
-DROP TABLE IF EXISTS `rmgr_lateSchedules`;
-CREATE TABLE `rmgr_lateSchedules` (
+DROP TABLE IF EXISTS `pmgr_late_schedules`;
+CREATE TABLE `pmgr_late_schedules` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`code` VARCHAR(12) NOT NULL, -- User style "id"
@@ -581,10 +581,10 @@ CREATE TABLE `rmgr_lateSchedules` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_lateScheduleActions
+-- TABLE pmgr_late_schedule_actions
-DROP TABLE IF EXISTS `rmgr_lateScheduleActions`;
-CREATE TABLE `rmgr_lateScheduleActions` (
+DROP TABLE IF EXISTS `pmgr_late_schedule_actions`;
+CREATE TABLE `pmgr_late_schedule_actions` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`late_schedule_id` INT(10) UNSIGNED DEFAULT NULL,
@@ -621,10 +621,10 @@ CREATE TABLE `rmgr_lateScheduleActions` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_leaseTypes
+-- TABLE pmgr_lease_types
-DROP TABLE IF EXISTS `rmgr_leaseTypes`;
-CREATE TABLE `rmgr_leaseTypes` (
+DROP TABLE IF EXISTS `pmgr_lease_types`;
+CREATE TABLE `pmgr_lease_types` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`code` VARCHAR(12) NOT NULL, -- User style "id"
`name` VARCHAR(80) NOT NULL,
@@ -636,10 +636,10 @@ CREATE TABLE `rmgr_leaseTypes` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_leases
+-- TABLE pmgr_leases
-DROP TABLE IF EXISTS `rmgr_leases`;
-CREATE TABLE `rmgr_leases` (
+DROP TABLE IF EXISTS `pmgr_leases`;
+CREATE TABLE `pmgr_leases` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-- Allow user to specify their own lease numbers
@@ -673,10 +673,10 @@ CREATE TABLE `rmgr_leases` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_leaseAltContacts
+-- TABLE pmgr_lease_contacts
-DROP TABLE IF EXISTS `rmgr_leaseContacts`;
-CREATE TABLE `rmgr_leaseContacts` (
+DROP TABLE IF EXISTS `pmgr_lease_contacts`;
+CREATE TABLE `pmgr_lease_contacts` (
`lease_id` INT(10) UNSIGNED NOT NULL,
`contact_id` INT(10) UNSIGNED NOT NULL,
@@ -727,8 +727,8 @@ CREATE TABLE `rmgr_leaseContacts` (
-- Which charges haven not been paid?
-- SELECT C.id AS cid, C.total AS total, COALESCE(SUM(R.amount),0) AS paid
--- FROM rmgr_transactionCharges C
--- LEFT JOIN rmgr_transactionReconciliations R ON R.charge_id = C.id
+-- FROM pmgr_transaction_charges C
+-- LEFT JOIN pmgr_transaction_reconciliations R ON R.charge_id = C.id
-- GROUP BY C.id
-- HAVING paid < C.total
@@ -736,23 +736,23 @@ CREATE TABLE `rmgr_leaseContacts` (
-- SUM(ChL.total) AS total, SUM(ChL.paid) AS paid,
-- SUM(ChL.total) - SUM(ChL.paid) AS owing
-- FROM (SELECT Ch.lease_id AS lid, Ch.total AS total, COALESCE(SUM(R.amount),0) AS paid
--- FROM rmgr_transactionCharges Ch
--- LEFT JOIN rmgr_transactionReconciliations R ON R.charge_id = Ch.id
+-- FROM pmgr_transaction_charges Ch
+-- LEFT JOIN pmgr_transaction_reconciliations R ON R.charge_id = Ch.id
-- WHERE Ch.due_date < NOW()
-- GROUP BY Ch.id
-- HAVING paid < Ch.total) ChL
--- LEFT JOIN rmgr_leases L ON L.id = ChL.lid
--- LEFT JOIN rmgr_leaseContacts Lc ON Lc.lease_id = L.id AND Lc.type = 'TENANT'
--- LEFT JOIN rmgr_contacts C ON C.id = Lc.contact_id
--- LEFT JOIN rmgr_units U ON U.id = L.unit_id
+-- LEFT JOIN pmgr_leases L ON L.id = ChL.lid
+-- LEFT JOIN pmgr_lease_contacts Lc ON Lc.lease_id = L.id AND Lc.type = 'TENANT'
+-- LEFT JOIN pmgr_contacts C ON C.id = Lc.contact_id
+-- LEFT JOIN pmgr_units U ON U.id = L.unit_id
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_chargeTypes
+-- TABLE pmgr_charge_types
-DROP TABLE IF EXISTS `rmgr_chargeTypes`;
-CREATE TABLE `rmgr_chargeTypes` (
+DROP TABLE IF EXISTS `pmgr_charge_types`;
+CREATE TABLE `pmgr_charge_types` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) NOT NULL,
@@ -762,8 +762,8 @@ CREATE TABLE `rmgr_chargeTypes` (
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-LOCK TABLES `rmgr_chargeTypes` WRITE;
-INSERT INTO `rmgr_chargeTypes` (`id`, `name`, `account_id`)
+LOCK TABLES `pmgr_charge_types` WRITE;
+INSERT INTO `pmgr_charge_types` (`id`, `name`, `account_id`)
VALUES
(1, 'Security Deposit', 0),
(2, 'Rent', 0),
@@ -772,10 +772,10 @@ UNLOCK TABLES;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_paymentTypes
+-- TABLE pmgr_payment_types
-DROP TABLE IF EXISTS `rmgr_paymentTypes`;
-CREATE TABLE `rmgr_paymentTypes` (
+DROP TABLE IF EXISTS `pmgr_payment_types`;
+CREATE TABLE `pmgr_payment_types` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) NOT NULL,
@@ -785,8 +785,8 @@ CREATE TABLE `rmgr_paymentTypes` (
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-LOCK TABLES `rmgr_paymentTypes` WRITE;
-INSERT INTO `rmgr_paymentTypes` (`id`, `name`, `tillable`)
+LOCK TABLES `pmgr_payment_types` WRITE;
+INSERT INTO `pmgr_payment_types` (`id`, `name`, `tillable`)
VALUES
(1, 'Cash', 1),
(2, 'Check', 1),
@@ -801,10 +801,10 @@ UNLOCK TABLES;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_transactionCharges
+-- TABLE pmgr_transaction_charges
-DROP TABLE IF EXISTS `rmgr_transactionCharges`;
-CREATE TABLE `rmgr_transactionCharges` (
+DROP TABLE IF EXISTS `pmgr_transaction_charges`;
+CREATE TABLE `pmgr_transaction_charges` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`type_id` INT(10) UNSIGNED NOT NULL,
@@ -823,10 +823,10 @@ CREATE TABLE `rmgr_transactionCharges` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_transactionReceipts
+-- TABLE pmgr_transaction_receipts
-DROP TABLE IF EXISTS `rmgr_transactionReceipts`;
-CREATE TABLE `rmgr_transactionReceipts` (
+DROP TABLE IF EXISTS `pmgr_transaction_receipts`;
+CREATE TABLE `pmgr_transaction_receipts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -839,10 +839,10 @@ CREATE TABLE `rmgr_transactionReceipts` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_transactionPayments
+-- TABLE pmgr_transaction_payments
-DROP TABLE IF EXISTS `rmgr_transactionPayments`;
-CREATE TABLE `rmgr_transactionPayments` (
+DROP TABLE IF EXISTS `pmgr_transaction_payments`;
+CREATE TABLE `pmgr_transaction_payments` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`receipt_id` INT(10) UNSIGNED NOT NULL,
@@ -857,10 +857,10 @@ CREATE TABLE `rmgr_transactionPayments` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_transactionReconciliations
+-- TABLE pmgr_transaction_reconciliations
-DROP TABLE IF EXISTS `rmgr_transactionReconciliations`;
-CREATE TABLE `rmgr_transactionReconciliations` (
+DROP TABLE IF EXISTS `pmgr_transaction_reconciliations`;
+CREATE TABLE `pmgr_transaction_reconciliations` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`charge_id` INT(10) UNSIGNED NOT NULL,
-- REVISIT : 20090514
@@ -887,11 +887,11 @@ CREATE TABLE `rmgr_transactionReconciliations` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_maps
+-- TABLE pmgr_maps
-DROP TABLE IF EXISTS `rmgr_maps`;
-CREATE TABLE `rmgr_maps` (
+DROP TABLE IF EXISTS `pmgr_maps`;
+CREATE TABLE `pmgr_maps` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`site_id` INT(10) UNSIGNED NOT NULL,
`area_id` INT(10) UNSIGNED NOT NULL,
@@ -908,11 +908,11 @@ CREATE TABLE `rmgr_maps` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_mapUnits
+-- TABLE pmgr_map_units
-DROP TABLE IF EXISTS `rmgr_mapUnits`;
-CREATE TABLE `rmgr_mapUnits` (
+DROP TABLE IF EXISTS `pmgr_map_units`;
+CREATE TABLE `pmgr_map_units` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`map_id` INT(10) UNSIGNED NOT NULL,
`unit_id` INT(10) UNSIGNED NOT NULL,
@@ -944,10 +944,10 @@ CREATE TABLE `rmgr_mapUnits` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE rmgr_notes
+-- TABLE pmgr_notes
-DROP TABLE IF EXISTS `rmgr_notes`;
-CREATE TABLE `rmgr_notes` (
+DROP TABLE IF EXISTS `pmgr_notes`;
+CREATE TABLE `pmgr_notes` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-- HISTORY is a note created by the system, when the
From eeb87758208738d09720587ad0559ff3d537238e Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 20:32:31 +0000
Subject: [PATCH 010/717] Further changes to the table naming conventions to
match expectations of CakePHP
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@11 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 58 +++++++++++++++++++++++++--------------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/db/schema.sql b/db/schema.sql
index f51eac3..1a636dd 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -197,10 +197,10 @@ CREATE TABLE `pmgr_contact_emails` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_contact_methods
+-- TABLE pmgr_contacts_methods
-DROP TABLE IF EXISTS `pmgr_contact_methods`;
-CREATE TABLE `pmgr_contact_methods` (
+DROP TABLE IF EXISTS `pmgr_contacts_methods`;
+CREATE TABLE `pmgr_contacts_methods` (
`contact_id` INT(10) UNSIGNED NOT NULL,
`method` ENUM('POST',
'PHONE',
@@ -400,7 +400,7 @@ CREATE TABLE `pmgr_site_options` (
-- 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_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
@@ -581,10 +581,10 @@ CREATE TABLE `pmgr_late_schedules` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_late_schedule_actions
+-- TABLE pmgr_actions_late_schedules
-DROP TABLE IF EXISTS `pmgr_late_schedule_actions`;
-CREATE TABLE `pmgr_late_schedule_actions` (
+DROP TABLE IF EXISTS `pmgr_actions_late_schedules`;
+CREATE TABLE `pmgr_actions_late_schedules` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`late_schedule_id` INT(10) UNSIGNED DEFAULT NULL,
@@ -673,10 +673,10 @@ CREATE TABLE `pmgr_leases` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_lease_contacts
+-- TABLE pmgr_contacts_leases
-DROP TABLE IF EXISTS `pmgr_lease_contacts`;
-CREATE TABLE `pmgr_lease_contacts` (
+DROP TABLE IF EXISTS `pmgr_contacts_leases`;
+CREATE TABLE `pmgr_contacts_leases` (
`lease_id` INT(10) UNSIGNED NOT NULL,
`contact_id` INT(10) UNSIGNED NOT NULL,
@@ -727,8 +727,8 @@ CREATE TABLE `pmgr_lease_contacts` (
-- Which charges haven not been paid?
-- SELECT C.id AS cid, C.total AS total, COALESCE(SUM(R.amount),0) AS paid
--- FROM pmgr_transaction_charges C
--- LEFT JOIN pmgr_transaction_reconciliations R ON R.charge_id = C.id
+-- FROM pmgr_charges C
+-- LEFT JOIN pmgr_charges_receipts R ON R.charge_id = C.id
-- GROUP BY C.id
-- HAVING paid < C.total
@@ -736,8 +736,8 @@ CREATE TABLE `pmgr_lease_contacts` (
-- SUM(ChL.total) AS total, SUM(ChL.paid) AS paid,
-- SUM(ChL.total) - SUM(ChL.paid) AS owing
-- FROM (SELECT Ch.lease_id AS lid, Ch.total AS total, COALESCE(SUM(R.amount),0) AS paid
--- FROM pmgr_transaction_charges Ch
--- LEFT JOIN pmgr_transaction_reconciliations R ON R.charge_id = Ch.id
+-- FROM pmgr_charges Ch
+-- LEFT JOIN pmgr_charges_receipts R ON R.charge_id = Ch.id
-- WHERE Ch.due_date < NOW()
-- GROUP BY Ch.id
-- HAVING paid < Ch.total) ChL
@@ -801,10 +801,10 @@ UNLOCK TABLES;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_transaction_charges
+-- TABLE pmgr_charges
-DROP TABLE IF EXISTS `pmgr_transaction_charges`;
-CREATE TABLE `pmgr_transaction_charges` (
+DROP TABLE IF EXISTS `pmgr_charges`;
+CREATE TABLE `pmgr_charges` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`type_id` INT(10) UNSIGNED NOT NULL,
@@ -823,10 +823,10 @@ CREATE TABLE `pmgr_transaction_charges` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_transaction_receipts
+-- TABLE pmgr_receipts
-DROP TABLE IF EXISTS `pmgr_transaction_receipts`;
-CREATE TABLE `pmgr_transaction_receipts` (
+DROP TABLE IF EXISTS `pmgr_receipts`;
+CREATE TABLE `pmgr_receipts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -839,10 +839,10 @@ CREATE TABLE `pmgr_transaction_receipts` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_transaction_payments
+-- TABLE pmgr_payments
-DROP TABLE IF EXISTS `pmgr_transaction_payments`;
-CREATE TABLE `pmgr_transaction_payments` (
+DROP TABLE IF EXISTS `pmgr_payments`;
+CREATE TABLE `pmgr_payments` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`receipt_id` INT(10) UNSIGNED NOT NULL,
@@ -857,10 +857,10 @@ CREATE TABLE `pmgr_transaction_payments` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_transaction_reconciliations
+-- TABLE pmgr_charges_receipts
-DROP TABLE IF EXISTS `pmgr_transaction_reconciliations`;
-CREATE TABLE `pmgr_transaction_reconciliations` (
+DROP TABLE IF EXISTS `pmgr_charges_receipts`;
+CREATE TABLE `pmgr_charges_receipts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`charge_id` INT(10) UNSIGNED NOT NULL,
-- REVISIT : 20090514
@@ -908,11 +908,11 @@ CREATE TABLE `pmgr_maps` (
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
--- TABLE pmgr_map_units
+-- TABLE pmgr_maps_units
-DROP TABLE IF EXISTS `pmgr_map_units`;
-CREATE TABLE `pmgr_map_units` (
+DROP TABLE IF EXISTS `pmgr_maps_units`;
+CREATE TABLE `pmgr_maps_units` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`map_id` INT(10) UNSIGNED NOT NULL,
`unit_id` INT(10) UNSIGNED NOT NULL,
From 76a06d165511470ab6b8de40397ef98afe43af00 Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 20:49:54 +0000
Subject: [PATCH 011/717] Further naming conventions to match CakePHP
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@12 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/db/schema.sql b/db/schema.sql
index 1a636dd..75fecfc 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -47,7 +47,7 @@ USE `property_manager`;
DROP TABLE IF EXISTS `pmgr_config_system`;
CREATE TABLE `pmgr_config_system` (
- `version_id` INT(10) UNSIGNED NOT NULL
+ `config_version_id` INT(10) UNSIGNED NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@@ -469,7 +469,7 @@ CREATE TABLE `pmgr_unit_types` (
DROP TABLE IF EXISTS `pmgr_unit_sizes`;
CREATE TABLE `pmgr_unit_sizes` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
- `type_id` INT(10) UNSIGNED NOT NULL,
+ `unit_type_id` INT(10) UNSIGNED NOT NULL,
`code` VARCHAR(12) NOT NULL, -- User style "id"
`name` VARCHAR(80) NOT NULL,
`width` SMALLINT UNSIGNED NOT NULL, -- inches
@@ -492,7 +492,7 @@ CREATE TABLE `pmgr_unit_sizes` (
DROP TABLE IF EXISTS `pmgr_units`;
CREATE TABLE `pmgr_units` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
- `size_id` INT(10) UNSIGNED NOT NULL,
+ `unit_size_id` INT(10) UNSIGNED NOT NULL,
`code` VARCHAR(12) NOT NULL, -- User style "id"
`name` VARCHAR(80) NOT NULL,
@@ -807,7 +807,7 @@ DROP TABLE IF EXISTS `pmgr_charges`;
CREATE TABLE `pmgr_charges` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
- `type_id` INT(10) UNSIGNED NOT NULL,
+ `charge_type_id` INT(10) UNSIGNED NOT NULL,
`lease_id` INT(10) UNSIGNED NOT NULL,
`charge_date` DATE NOT NULL,
`charge_to_date` DATE NOT NULL,
@@ -894,14 +894,14 @@ DROP TABLE IF EXISTS `pmgr_maps`;
CREATE TABLE `pmgr_maps` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`site_id` INT(10) UNSIGNED NOT NULL,
- `area_id` INT(10) UNSIGNED NOT NULL,
+ `site_area_id` INT(10) UNSIGNED NOT NULL,
`name` VARCHAR(80) DEFAULT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
`width` SMALLINT UNSIGNED NOT NULL, -- inches
`depth` SMALLINT UNSIGNED NOT NULL, -- inches
- UNIQUE KEY `map_key` (`site_id`, `area_id`),
+ UNIQUE KEY `map_key` (`site_id`, `site_area_id`),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
From 6b53d8a25aa0079f12645fbb045e9cce95c447fe Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 20:52:32 +0000
Subject: [PATCH 012/717] Omission bug on last checkin
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@13 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/db/schema.sql b/db/schema.sql
index 75fecfc..3b710be 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -52,7 +52,7 @@ CREATE TABLE `pmgr_config_system` (
LOCK TABLES `pmgr_config_system` WRITE;
-INSERT INTO `pmgr_config_system` (`version_id`)
+INSERT INTO `pmgr_config_system` (`config_version_id`)
VALUES
(1);
UNLOCK TABLES;
From f4007a026957b6cf5c737c9938719489f12964a4 Mon Sep 17 00:00:00 2001
From: abijah
Date: Wed, 27 May 2009 20:54:14 +0000
Subject: [PATCH 013/717] Adjusted database details and sitelink conversion
script to go along with new schema naming convention changes
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@14 97e9348a-65ac-dc4b-aefc-98561f571b83
---
.../{sitelink2rmgr.pl => sitelink2pmgr.pl} | 152 +++++++++---------
site/config/database.php | 2 +-
2 files changed, 78 insertions(+), 76 deletions(-)
rename scripts/{sitelink2rmgr.pl => sitelink2pmgr.pl} (86%)
diff --git a/scripts/sitelink2rmgr.pl b/scripts/sitelink2pmgr.pl
similarity index 86%
rename from scripts/sitelink2rmgr.pl
rename to scripts/sitelink2pmgr.pl
index 67b6863..0a435a1 100644
--- a/scripts/sitelink2rmgr.pl
+++ b/scripts/sitelink2pmgr.pl
@@ -21,7 +21,9 @@ my $sdbh = DBI->connect("dbi:ADO:$sdsn", undef, undef, {PrintError => 1,
RaiseError => 1});
# Connect to the database.
-my($hostname, $database, $user, $password) = ('localhost', 'rentmgr', 'root', 'mysql97312519');
+my($hostname, $database, $user, $password) = ('localhost',
+ 'property_manager',
+ 'pmgr', 'pmgruser');
my $db_handle = DBI->connect("DBI:mysql:database=$database;host=$hostname",
$user, $password,
{'RaiseError' => 1});
@@ -46,140 +48,140 @@ while () {
close(SCHEMA);
++$aicur_c_id;
-$query = "INSERT INTO rmgr_contacts
+$query = "INSERT INTO pmgr_contacts
(`id`, `first_name`, `middle_name`, `last_name`, `display_name`) VALUES
($aicur_c_id, 'Abijah', 'M', 'Perkins', 'Perkins, Abijah')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_ca_id;
-$query = "INSERT INTO rmgr_contactAddresses
+$query = "INSERT INTO pmgr_contact_addresses
(`id`, `address`, `city`, `state`, `postcode`, `country`) VALUES
($aicur_ca_id, '1324 N Liberty Lake Rd\nPMB 263', 'Liberty Lake', 'WA', '99019', 'USA')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'POST', $aicur_ca_id, 'MAIN', 'PRIMARY')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_ca_id;
-$query = "INSERT INTO rmgr_contactAddresses
+$query = "INSERT INTO pmgr_contact_addresses
(`id`, `address`, `city`, `state`, `postcode`, `country`) VALUES
($aicur_ca_id, '5221 W Myrtlewood Ct', 'Spokane', 'WA', '99208', 'USA')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'POST', $aicur_ca_id, 'HOME', 'ALTERNATE')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_ca_id;
-$query = "INSERT INTO rmgr_contactAddresses
+$query = "INSERT INTO pmgr_contact_addresses
(`id`, `address`, `city`, `state`, `postcode`, `country`) VALUES
($aicur_ca_id, 'PO Box 69', 'Granger', 'WA', '98932', 'USA')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'POST', $aicur_ca_id, 'HOME', 'ALTERNATE')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_cp_id;
-$query = "INSERT INTO rmgr_contactPhones
+$query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`) VALUES
($aicur_cp_id, 'MOBILE', '5098445573')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'PHONE', $aicur_cp_id, 'MAIN', 'PRIMARY')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_cp_id;
-$query = "INSERT INTO rmgr_contactPhones
+$query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`) VALUES
($aicur_cp_id, 'MOBILE', '5098445973')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'PHONE', $aicur_cp_id, 'MAIN', 'ALTERNATE')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_cp_id;
-$query = "INSERT INTO rmgr_contactPhones
+$query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`) VALUES
($aicur_cp_id, 'VIRTUAL', '5095901112')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'PHONE', $aicur_cp_id, 'BUSINESS', 'WORK')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_cp_id;
-$query = "INSERT INTO rmgr_contactPhones
+$query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`) VALUES
($aicur_cp_id, 'LANDLINE', '5098541491')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'PHONE', $aicur_cp_id, 'HOME', 'ALTERNATE')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_cp_id;
-$query = "INSERT INTO rmgr_contactPhones
+$query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`) VALUES
($aicur_cp_id, 'VIRTUAL', '8774488664')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'PHONE', $aicur_cp_id, 'BUSINESS', 'WORK')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_cp_id;
-$query = "INSERT INTO rmgr_contactPhones
+$query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`) VALUES
($aicur_cp_id, 'FAX', '8662960131')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'PHONE', $aicur_cp_id, 'BUSINESS', 'WORK')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_ce_id;
-$query = "INSERT INTO rmgr_contactEmails
+$query = "INSERT INTO pmgr_contact_emails
(`id`, `email`) VALUES
($aicur_ce_id, 'abijah\@PerkinsHouse.com')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'EMAIL', $aicur_ce_id, 'HOME', 'PRIMARY')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_ce_id;
-$query = "INSERT INTO rmgr_contactEmails
+$query = "INSERT INTO pmgr_contact_emails
(`id`, `email`) VALUES
($aicur_ce_id, 'abijah\@PerkinsREI.com')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'EMAIL', $aicur_ce_id, 'HOME', 'WORK')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_ce_id;
-$query = "INSERT INTO rmgr_contactEmails
+$query = "INSERT INTO pmgr_contact_emails
(`id`, `email`) VALUES
($aicur_ce_id, 'abijah\@ValleyStorage.com')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_contactMethods
+$query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($aicur_c_id, 'EMAIL', $aicur_ce_id, 'BUSINESS', 'WORK')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_g_id;
-$query = "INSERT INTO rmgr_groups
+$query = "INSERT INTO pmgr_groups
(`id`, `code`, `name`)
VALUES
($aicur_g_id, 'Owner', 'Owner Group')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_gp_id;
-$query = "INSERT INTO rmgr_groupPermissions
+$query = "INSERT INTO pmgr_group_permissions
(`group_id`, `name`, `access`)
VALUES
($aicur_gp_id, 'EVERYTHING', 'FORCED')";
@@ -187,7 +189,7 @@ $query = "INSERT INTO rmgr_groupPermissions
++$aicur_user_id;
-$query = "INSERT INTO rmgr_users
+$query = "INSERT INTO pmgr_users
(`id`, `code`, `login`, `contact_id`)
VALUES
($aicur_user_id, 'AP', 'abijah', $aicur_c_id)";
@@ -195,27 +197,27 @@ $query = "INSERT INTO rmgr_users
++$aicur_site_id;
-$query = "INSERT INTO rmgr_sites
+$query = "INSERT INTO pmgr_sites
(`id`, `code`, `name`)
VALUES
($aicur_site_id, 'VSS', 'Valley Storage')";
query($db_handle, $query) || die("Unable to insert");
-$query = "INSERT INTO rmgr_siteMemberships
+$query = "INSERT INTO pmgr_site_memberships
(`site_id`, `user_id`, `group_id`)
VALUES
($aicur_site_id, $aicur_user_id, $aicur_g_id)";
query($db_handle, $query) || die("Unable to insert");
++$aicur_area_id;
-$query = "INSERT INTO rmgr_siteAreas
+$query = "INSERT INTO pmgr_site_areas
(`id`, `site_id`, `code`, `name`)
VALUES
($aicur_area_id, $aicur_site_id, 'Main', 'Main Facility Area')";
query($db_handle, $query) || die("Unable to insert");
++$aicur_lease_type_id;
-$query = "INSERT INTO rmgr_leaseTypes
+$query = "INSERT INTO pmgr_lease_types
(`id`, `code`, `name`)
VALUES
($aicur_lease_type_id, 'SL', 'Storage Lease')";
@@ -286,7 +288,7 @@ $nrows = @$result;
print(" $nrows Unit Types\n");
foreach $row (@$result) {
- $query = "INSERT INTO rmgr_unitTypes
+ $query = "INSERT INTO pmgr_unit_types
(`id`, `code`, `name`)
VALUES
($row->{'TypeID'}, 'xxx', '$row->{'UnitType'}')";
@@ -311,8 +313,8 @@ foreach $row (@$result) {
$unit_size_map{$sz}{'dep'} = $row->{'StdSecDep'};
my $szid = $unit_size_map{$sz}{'id'};
- $query = "INSERT INTO rmgr_unitSizes
- (`id`, `type_id`, `code`, `name`, `width`, `depth`,
+ $query = "INSERT INTO pmgr_unit_sizes
+ (`id`, `unit_type_id`, `code`, `name`, `width`, `depth`,
`deposit`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -335,8 +337,8 @@ foreach $row (@$result) {
$unit_map{$row->{'UnitID'}} = ++$aicur_unit_id;
my $uid = $unit_map{$row->{'UnitID'}};
- $query = "INSERT INTO rmgr_units
- (`id`, `size_id`, `code`, `name`,
+ $query = "INSERT INTO pmgr_units
+ (`id`, `unit_size_id`, `code`, `name`,
`status`,
`sort_order`, `walk_order`, `deposit`, `amount`)
VALUES (" .
@@ -374,7 +376,7 @@ $info{'extents'}{'bottom'} = $internal_adjustment_factor * ($top_adjustment + $
$info{'extents'}{'right'} = $internal_adjustment_factor * ($left_adjustment + $row->{'rgt'} + 0);
$query =
- "INSERT INTO rmgr_maps (id, site_id, area_id, width, depth) VALUES\n" .
+ "INSERT INTO pmgr_maps (id, site_id, site_area_id, width, depth) VALUES\n" .
" (1, $aicur_site_id, $aicur_area_id," .
($info{'extents'}{'right'} - $info{'extents'}{'left'}) . ", " .
($info{'extents'}{'bottom'} - $info{'extents'}{'top'}) . ")";
@@ -395,9 +397,9 @@ foreach $row (@$result) {
my $uid = $unit_map{$row->{'UnitID'}};
$query = # pt_bottom, pt_right,
- "INSERT INTO rmgr_mapUnits (map_id, unit_id,
- pt_top, pt_left,
- transpose) VALUES
+ "INSERT INTO pmgr_maps_units (map_id, unit_id,
+ pt_top, pt_left,
+ transpose) VALUES
(" . join(", ",
1, $uid,
$internal_adjustment_factor * ($row->{'pt_t'}),
@@ -432,7 +434,7 @@ foreach $row (@$result) {
$tenant_map{$row->{'TenantID'}} = { 'id' => ++$aicur_c_id };
my $cid = $tenant_map{$row->{'TenantID'}}{'id'};
- $query = "INSERT INTO rmgr_contacts
+ $query = "INSERT INTO pmgr_contacts
(`id`, `first_name`, `middle_name`, `last_name`, `display_name`, `id_num`, `id_state`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -443,7 +445,7 @@ foreach $row (@$result) {
query($db_handle, $query) || die("Unable to insert");
if ($row->{'City'}) {
- $query = "INSERT INTO rmgr_contactAddresses
+ $query = "INSERT INTO pmgr_contact_addresses
(`id`, `address`, `city`, `state`, `postcode`, `country`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -454,7 +456,7 @@ foreach $row (@$result) {
)) . ")";
query($db_handle, $query) || die("Unable to insert");
- $query = "INSERT INTO rmgr_contactMethods
+ $query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($cid, 'POST', $aicur_ca_id, 'HOME', 'PRIMARY')";
query($db_handle, $query) || die("Unable to insert");
@@ -468,14 +470,14 @@ foreach $row (@$result) {
{'type' => 'MOBILE', 'preference' => 'ALTERNATE', 'phone' => $row->{'CellPhone'}})
{
if ($_->{'phone'}) {
- $query = "INSERT INTO rmgr_contactPhones
+ $query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`, `ext`) VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(++$aicur_cp_id, $_->{'type'}, $_->{'phone'}, $_->{'ext'})))
. ")";
query($db_handle, $query) || die("Unable to insert");
- $query = "INSERT INTO rmgr_contactMethods
+ $query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
($cid, 'PHONE', $aicur_cp_id, 'MAIN', $_->{'preference'})))
@@ -485,12 +487,12 @@ foreach $row (@$result) {
}
if ($row->{'Email'}) {
- $query = "INSERT INTO rmgr_contactEmails
+ $query = "INSERT INTO pmgr_contact_emails
(`id`, `email`) VALUES
(".++$aicur_ce_id.", '$row->{'Email'}')";
query($db_handle, $query) || die("Unable to insert");
- $query = "INSERT INTO rmgr_contactMethods
+ $query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUE
($cid, 'EMAIL', $aicur_ce_id, 'MAIN', 'PRIMARY')";
query($db_handle, $query) || die("Unable to insert");
@@ -501,7 +503,7 @@ foreach $row (@$result) {
$tenant_map{$row->{'TenantID'}}{'alt'} = ++$aicur_c_id;
$cid = $tenant_map{$row->{'TenantID'}}{'alt'};
- $query = "INSERT INTO rmgr_contacts
+ $query = "INSERT INTO pmgr_contacts
(`id`, `first_name`, `middle_name`, `last_name`, `display_name`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -516,7 +518,7 @@ foreach $row (@$result) {
query($db_handle, $query) || die("Unable to insert");
if ($row->{'AltCity'}) {
- $query = "INSERT INTO rmgr_contactAddresses
+ $query = "INSERT INTO pmgr_contact_addresses
(`id`, `address`, `city`, `state`, `postcode`, `country`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -526,21 +528,21 @@ foreach $row (@$result) {
)) . ")";
query($db_handle, $query) || die("Unable to insert");
- $query = "INSERT INTO rmgr_contactMethods
+ $query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($cid, 'POST', $aicur_ca_id, 'MAIN', 'PRIMARY')";
query($db_handle, $query) || die("Unable to insert");
}
if ($row->{'AltPhone'}) {
- $query = "INSERT INTO rmgr_contactPhones
+ $query = "INSERT INTO pmgr_contact_phones
(`id`, `type`, `phone`, `ext`) VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
(++$aicur_cp_id, 'LANDLINE', $row->{'AltPhone'}, undef)
)) . ")";
query($db_handle, $query) || die("Unable to insert");
- $query = "INSERT INTO rmgr_contactMethods
+ $query = "INSERT INTO pmgr_contacts_methods
(`contact_id`, `method`, `method_id`, `type`, `preference`) VALUES
($cid, 'PHONE', $aicur_cp_id, 'MAIN', 'PRIMARY')";
query($db_handle, $query) || die("Unable to insert");
@@ -562,7 +564,7 @@ foreach $row (@$result) {
my $uid = $unit_map{$row->{'UnitID'}};
my $lid = $ledger_map{$row->{'LedgerID'}};
- $query = "INSERT INTO rmgr_leases
+ $query = "INSERT INTO pmgr_leases
(`id`, `number`, `lease_type_id`, `unit_id`,
`lease_date`, `movein_date`,
`moveout_date`, `close_date`,
@@ -576,7 +578,7 @@ foreach $row (@$result) {
)) . ")";
query($db_handle, $query) || die("Unable to insert");
- $query = "INSERT INTO rmgr_leaseContacts
+ $query = "INSERT INTO pmgr_contacts_leases
(`lease_id`, `contact_id`, `type`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -587,7 +589,7 @@ foreach $row (@$result) {
$cid = $tenant_map{$row->{'TenantID'}}{'alt'};
next unless $cid;
- $query = "INSERT INTO rmgr_leaseContacts
+ $query = "INSERT INTO pmgr_contacts_leases
(`lease_id`, `contact_id`, `type`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -607,7 +609,7 @@ print(" $nrows Security Deposits\n");
foreach $row (@$result) {
my $uid = $unit_map{$row->{'UnitID'}};
- $query = "UPDATE rmgr_leases
+ $query = "UPDATE pmgr_leases
SET deposit = $row->{'ChargeAmount'}
WHERE `number` = '$row->{'LedgerID'}'";
query($db_handle, $query) || die("Unable to update");
@@ -639,8 +641,8 @@ foreach $row (@$result) {
my $lid = $ledger_map{$row->{'LedgerID'}};
my $chid = $charge_map{$row->{'ChargeID'}};
- $query = "INSERT INTO rmgr_transactionCharges
- (`id`, `type_id`, `lease_id`,
+ $query = "INSERT INTO pmgr_charges
+ (`id`, `charge_type_id`, `lease_id`,
`charge_date`, `charge_to_date`,
`amount`, `tax`, `total`, `comment`)
VALUES (" .
@@ -653,8 +655,8 @@ foreach $row (@$result) {
)) . ")";
query($db_handle, $query) || die("Unable to insert");
- $query = "UPDATE rmgr_transactionCharges";
- $query .= " SET due_date = DATE_ADD(charge_date, INTERVAL IF(type_id=2,10,0) DAY)";
+ $query = "UPDATE pmgr_charges";
+ $query .= " SET due_date = DATE_ADD(charge_date, INTERVAL IF(charge_type_id=2,10,0) DAY)";
query($db_handle, $query) || die("Unable to update");
}
@@ -673,7 +675,7 @@ foreach $row (@$result) {
my $lid = $ledger_map{$row->{'LedgerID'}};
my $rid = $receipt_map{$row->{'ReceiptNum'}};
- $query = "INSERT INTO rmgr_transactionReceipts
+ $query = "INSERT INTO pmgr_receipts
(`id`, `stamp`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -712,7 +714,7 @@ foreach $row (@$result) {
my $rid = $receipt_map{$row->{'ReceiptNum'}};
my $chid = $charge_map{$row->{'ChargeID'}};
- $query = "INSERT INTO rmgr_transactionPayments
+ $query = "INSERT INTO pmgr_payments
(`id`, `receipt_id`, `payment_type_id`, `amount`, `comment`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -723,7 +725,7 @@ foreach $row (@$result) {
)) . ")";
query($db_handle, $query) || die("Unable to insert");
- $query = "INSERT INTO rmgr_transactionReconciliations
+ $query = "INSERT INTO pmgr_charges_receipts
(`charge_id`, `receipt_id`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -749,7 +751,7 @@ foreach $row (@$result) {
my $chid = $charge_map{$row->{'ChargeID'}};
my $rid = $receipt_map{$row->{'ReceiptNum'}};
- $query = "INSERT INTO rmgr_transactionReconciliations
+ $query = "INSERT INTO pmgr_charges_receipts
(`charge_id`, `receipt_id`, `amount`)
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
@@ -758,22 +760,22 @@ foreach $row (@$result) {
query($db_handle, $query) || die("Unable to insert");
}
-$query ="UPDATE rmgr_transactionReconciliations R
+$query ="UPDATE pmgr_charges_receipts R
JOIN (SELECT P.receipt_id AS rid,
IF(COALESCE(Ch.total, 0) 'localhost',
'login' => 'pmgr',
'password' => 'pmgruser',
- 'database' => 'pmgr',
+ 'database' => 'property_manager',
'prefix' => 'pmgr_',
);
}
From df846f99638d6b375448cde87219e1e5e7f45eed Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 05:49:03 +0000
Subject: [PATCH 014/717] Very, very early snapshot. Some models are working,
and I have a controller for testing. Everything is subject to change. I
_do_ have a working tenant ledger though, so it's worth a snapshot.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@15 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/transactions_controller.php | 36 +++++++++
site/models/charge.php | 53 ++++++++++++
site/models/charge_type.php | 39 +++++++++
site/models/contact.php | 46 +++++++++++
site/models/contact_email.php | 30 +++++++
site/models/lease.php | 85 ++++++++++++++++++++
site/models/lease_type.php | 28 +++++++
site/models/payment.php | 31 +++++++
site/models/payment_type.php | 29 +++++++
site/models/receipt.php | 46 +++++++++++
site/views/transactions/contact.ctp | 66 +++++++++++++++
site/views/transactions/ledger.ctp | 53 ++++++++++++
site/views/transactions/ledger_1.ctp | 58 +++++++++++++
13 files changed, 600 insertions(+)
create mode 100644 site/controllers/transactions_controller.php
create mode 100644 site/models/charge.php
create mode 100644 site/models/charge_type.php
create mode 100644 site/models/contact.php
create mode 100644 site/models/contact_email.php
create mode 100644 site/models/lease.php
create mode 100644 site/models/lease_type.php
create mode 100644 site/models/payment.php
create mode 100644 site/models/payment_type.php
create mode 100644 site/models/receipt.php
create mode 100644 site/views/transactions/contact.ctp
create mode 100644 site/views/transactions/ledger.ctp
create mode 100644 site/views/transactions/ledger_1.ctp
diff --git a/site/controllers/transactions_controller.php b/site/controllers/transactions_controller.php
new file mode 100644
index 0000000..f4501ef
--- /dev/null
+++ b/site/controllers/transactions_controller.php
@@ -0,0 +1,36 @@
+Session->setFlash(__('Invalid Item.', true));
+ $this->redirect(array('action'=>''));
+ }
+ $this->Charge->recursive = 0;
+ //$ledgers = array($this->Charge->read(null, $id));
+ $this->set('ledgers', $this->Charge->find('all'));
+ //$this->set(compact('ledgers', 'tables'));
+ }
+
+ function contact($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid Item.', true));
+ $this->redirect(array('action'=>''));
+ }
+ $this->Contact->recursive = 4;
+ $this->Contact->Lease->LeaseType->unbindModel(array('hasMany' => array('Lease')));
+ $this->Contact->Lease->Charge->unbindModel(array('belongsTo' => array('Lease')));
+ $this->Contact->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge')));
+ $this->Contact->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt')));
+
+ //$ledgers = array($this->Charge->read(null, $id));
+ //$this->set('ledgers', $this->Contact->Lease->Charge->find('all'));
+ //$this->set(compact('ledgers', 'tables'));
+ $this->set('tenant', $this->Contact->read(null, $id));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/site/models/charge.php b/site/models/charge.php
new file mode 100644
index 0000000..e37a8e9
--- /dev/null
+++ b/site/models/charge.php
@@ -0,0 +1,53 @@
+ array('numeric'),
+ 'charge_type_id' => array('numeric'),
+ 'lease_id' => array('numeric'),
+ 'charge_date' => array('date'),
+ 'charge_to_date' => array('date'),
+ 'due_date' => array('date'),
+ 'amount' => array('money'),
+ 'tax' => array('money'),
+ 'total' => array('money')
+ );
+
+ var $belongsTo = array(
+ 'ChargeType' => array(
+ 'className' => 'ChargeType',
+ 'foreignKey' => 'charge_type_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'Lease' => array(
+ 'className' => 'Lease',
+ 'foreignKey' => 'lease_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+ var $hasAndBelongsToMany = array(
+ 'Receipt' => array(
+ 'className' => 'Receipt',
+ 'joinTable' => 'charges_receipts',
+ 'foreignKey' => 'charge_id',
+ 'associationForeignKey' => 'receipt_id',
+ 'unique' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/charge_type.php b/site/models/charge_type.php
new file mode 100644
index 0000000..fe42c68
--- /dev/null
+++ b/site/models/charge_type.php
@@ -0,0 +1,39 @@
+ array('numeric'),
+ 'name' => array('notempty'),
+ 'account_id' => array('numeric')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+/* var $belongsTo = array( */
+/* 'Account' => array( */
+/* 'className' => 'Account', */
+/* 'foreignKey' => 'account_id', */
+/* 'conditions' => '', */
+/* 'fields' => '', */
+/* 'order' => '' */
+/* ) */
+/* ); */
+
+ var $hasMany = array(
+ 'Charge' => array(
+ 'className' => 'Charge',
+ 'foreignKey' => 'charge_type_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/contact.php b/site/models/contact.php
new file mode 100644
index 0000000..2584571
--- /dev/null
+++ b/site/models/contact.php
@@ -0,0 +1,46 @@
+ array('numeric'),
+ 'display_name' => array('notempty'),
+ 'id_federal' => array('ssn'),
+ 'id_exp' => array('date')
+ );
+
+ var $hasAndBelongsToMany = array(
+ 'Lease' => array(
+ 'className' => 'Lease',
+ 'joinTable' => 'contacts_leases',
+ 'foreignKey' => 'contact_id',
+ 'associationForeignKey' => 'lease_id',
+ 'unique' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ ),
+ 'ContactEmail' => array(
+ 'className' => 'ContactEmail',
+ 'joinTable' => 'contacts_methods',
+ 'foreignKey' => 'contact_id',
+ 'associationForeignKey' => 'method_id',
+ 'unique' => true,
+ 'conditions' => "ContactsMethod.method = 'EMAIL'",
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/contact_email.php b/site/models/contact_email.php
new file mode 100644
index 0000000..3f4a7e9
--- /dev/null
+++ b/site/models/contact_email.php
@@ -0,0 +1,30 @@
+ array('numeric'),
+ 'email' => array('email')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $hasAndBelongsToMany = array(
+ 'Contact' => array(
+ 'className' => 'Contact',
+ 'joinTable' => 'contacts_methods',
+ 'foreignKey' => 'method_id',
+ 'associationForeignKey' => 'contact_id',
+ 'unique' => true,
+ 'conditions' => "ContactsMethod.method = 'EMAIL'",
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/lease.php b/site/models/lease.php
new file mode 100644
index 0000000..509b333
--- /dev/null
+++ b/site/models/lease.php
@@ -0,0 +1,85 @@
+ array('numeric'),
+ 'number' => array('alphanumeric'),
+ 'lease_type_id' => array('numeric'),
+ 'unit_id' => array('numeric'),
+ 'late_schedule_id' => array('numeric'),
+ 'lease_date' => array('date'),
+ 'movein_planed_date' => array('date'),
+ 'movein_date' => array('date'),
+ 'moveout_date' => array('date'),
+ 'moveout_planed_date' => array('date'),
+ 'notice_given_date' => array('date'),
+ 'notice_received_date' => array('date'),
+ 'close_date' => array('date'),
+ 'deposit' => array('money'),
+ 'amount' => array('money'),
+ 'next_amount' => array('money'),
+ 'next_amount_date' => array('date')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $belongsTo = array(
+ 'LeaseType' => array(
+ 'className' => 'LeaseType',
+ 'foreignKey' => 'lease_type_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'Unit' => array(
+ 'className' => 'Unit',
+ 'foreignKey' => 'unit_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'LateSchedule' => array(
+ 'className' => 'LateSchedule',
+ 'foreignKey' => 'late_schedule_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+ var $hasMany = array(
+ 'Charge' => array(
+ 'className' => 'Charge',
+ 'foreignKey' => 'lease_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+ var $hasAndBelongsToMany = array(
+ 'Contact' => array(
+ 'className' => 'Contact',
+ 'joinTable' => 'contacts_leases',
+ 'foreignKey' => 'lease_id',
+ 'associationForeignKey' => 'contact_id',
+ 'unique' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/lease_type.php b/site/models/lease_type.php
new file mode 100644
index 0000000..f4a5208
--- /dev/null
+++ b/site/models/lease_type.php
@@ -0,0 +1,28 @@
+ array('numeric'),
+ 'name' => array('notempty')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $hasMany = array(
+ 'Lease' => array(
+ 'className' => 'Lease',
+ 'foreignKey' => 'lease_type_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/payment.php b/site/models/payment.php
new file mode 100644
index 0000000..e3b2fc8
--- /dev/null
+++ b/site/models/payment.php
@@ -0,0 +1,31 @@
+ array('numeric'),
+ 'receipt_id' => array('numeric'),
+ 'payment_type_id' => array('numeric'),
+ 'amount' => array('money')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $belongsTo = array(
+ 'Receipt' => array(
+ 'className' => 'Receipt',
+ 'foreignKey' => 'receipt_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+ 'PaymentType' => array(
+ 'className' => 'PaymentType',
+ 'foreignKey' => 'payment_type_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/payment_type.php b/site/models/payment_type.php
new file mode 100644
index 0000000..45f5881
--- /dev/null
+++ b/site/models/payment_type.php
@@ -0,0 +1,29 @@
+ array('numeric'),
+ 'name' => array('notempty'),
+ 'tillable' => array('boolean')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $hasMany = array(
+ 'Payment' => array(
+ 'className' => 'Payment',
+ 'foreignKey' => 'payment_type_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/receipt.php b/site/models/receipt.php
new file mode 100644
index 0000000..66a2164
--- /dev/null
+++ b/site/models/receipt.php
@@ -0,0 +1,46 @@
+ array('numeric'),
+ 'stamp' => array('time')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $hasMany = array(
+ 'Payment' => array(
+ 'className' => 'Payment',
+ 'foreignKey' => 'receipt_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+ var $hasAndBelongsToMany = array(
+ 'Charge' => array(
+ 'className' => 'Charge',
+ 'joinTable' => 'charges_receipts',
+ 'foreignKey' => 'receipt_id',
+ 'associationForeignKey' => 'charge_id',
+ 'unique' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/views/transactions/contact.ctp b/site/views/transactions/contact.ctp
new file mode 100644
index 0000000..18d6021
--- /dev/null
+++ b/site/views/transactions/contact.ctp
@@ -0,0 +1,66 @@
+
+
+
diff --git a/site/views/transactions/ledger.ctp b/site/views/transactions/ledger.ctp
new file mode 100644
index 0000000..fd59df5
--- /dev/null
+++ b/site/views/transactions/ledger.ctp
@@ -0,0 +1,53 @@
+
+
+
+
+
+ $table) {
+
+ if (array_key_exists(0, $table)) {
+ // Horizontal table (multiple items)
+ $headers = array_keys($table[0]);
+
+ //$rows = array_map('array_values', $table);
+ $rows = array();
+ //echo("
table:\n"); print_r($table); echo("\n");
+ foreach ($table as $row) {
+ //echo("
row:\n"); print_r($row); echo("\n");
+ $rows[] = array_values($row);
+ }
+ }
+ else {
+ // Vertical table (one item)
+ $headers = array('Field', 'Value');
+
+ $rows = array();
+ foreach ($table as $col => $val) {
+ $rows[] = array($col, $val);
+ }
+ }
+
+ foreach($rows AS &$row) {
+ foreach ($row AS &$cell) {
+ if (is_array($cell))
+ $cell = "<ARRAY>";
+ }
+ }
+ //echo("
headers:\n"); print_r($headers); echo("\n");
+ //echo("
rows:\n"); print_r($rows); echo("\n");
+ ?>
+
+
+ tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"));
+ ?>
+
+
+
+
\ No newline at end of file
diff --git a/site/views/transactions/ledger_1.ctp b/site/views/transactions/ledger_1.ctp
new file mode 100644
index 0000000..316e24a
--- /dev/null
+++ b/site/views/transactions/ledger_1.ctp
@@ -0,0 +1,58 @@
+
+
+
+
+counter(array(
+ 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
+
+ $cells = array($paginator->sort('id'),
+ $paginator->sort('charge_type_id'),
+ $paginator->sort('lease_id'),
+ $paginator->sort('charge_date'),
+ $paginator->sort('charge_to_date'),
+ $paginator->sort('due_date'),
+ $paginator->sort('amount'),
+ $paginator->sort('tax'),
+ $paginator->sort('total'),
+ $paginator->sort('comment'));
+} else {
+ $cells = array('Id', 'Type', 'Lease', 'Date', 'Through', 'Due', 'Amount', 'Tax', 'Total', 'Comment');
+}
+echo $html->tableHeaders($cells);
+
+$cells = array();
+foreach ($ledgers as $ledger) {
+ $cells[] = array($html->link($ledger['Charge']['id'],
+ array('controller' => 'transactions',
+ 'action' => 'view',
+ $ledger['Charge']['id'])),
+ $ledger['Charge']['charge_type_id'],
+ $ledger['Charge']['lease_id'],
+ $ledger['Charge']['charge_date'],
+ $ledger['Charge']['charge_to_date'],
+ $ledger['Charge']['due_date'],
+ $ledger['Charge']['amount'],
+ $ledger['Charge']['tax'],
+ $ledger['Charge']['total'],
+ $ledger['Charge']['comment']);
+}
+echo $html->tableCells($cells, null, array('class' => "altrow"));
+?>
+
+
+' . "\n");
+ echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
+ echo(' | ');
+ echo $paginator->numbers();
+ echo(' | ');
+ echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
+ echo('
' . "\n");
+ }
+?>
+
+
+
\ No newline at end of file
From 28bf192853bba8571e508e19c322b6b7b09c036f Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 06:31:07 +0000
Subject: [PATCH 015/717] Added phone and address models as well as outputing
them to the view.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@16 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/models/contact.php | 32 +++++++-
site/models/contact_address.php | 28 +++++++
site/models/contact_email.php | 1 -
site/models/contact_phone.php | 31 ++++++++
site/views/transactions/contact.ctp | 114 +++++++++++++++++++++++++---
5 files changed, 194 insertions(+), 12 deletions(-)
create mode 100644 site/models/contact_address.php
create mode 100644 site/models/contact_phone.php
diff --git a/site/models/contact.php b/site/models/contact.php
index 2584571..5aab7f3 100644
--- a/site/models/contact.php
+++ b/site/models/contact.php
@@ -25,6 +25,36 @@ class Contact extends AppModel {
'deleteQuery' => '',
'insertQuery' => ''
),
+ 'ContactAddress' => array(
+ 'className' => 'ContactAddress',
+ 'joinTable' => 'contacts_methods',
+ 'foreignKey' => 'contact_id',
+ 'associationForeignKey' => 'method_id',
+ 'unique' => true,
+ 'conditions' => "ContactsMethod.method = 'POST'",
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ ),
+ 'ContactPhone' => array(
+ 'className' => 'ContactPhone',
+ 'joinTable' => 'contacts_methods',
+ 'foreignKey' => 'contact_id',
+ 'associationForeignKey' => 'method_id',
+ 'unique' => true,
+ 'conditions' => "ContactsMethod.method = 'PHONE'",
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ ),
'ContactEmail' => array(
'className' => 'ContactEmail',
'joinTable' => 'contacts_methods',
@@ -39,7 +69,7 @@ class Contact extends AppModel {
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
- )
+ ),
);
}
diff --git a/site/models/contact_address.php b/site/models/contact_address.php
new file mode 100644
index 0000000..d808b41
--- /dev/null
+++ b/site/models/contact_address.php
@@ -0,0 +1,28 @@
+ array('numeric'),
+ 'postcode' => array('postal')
+ );
+
+ var $hasAndBelongsToMany = array(
+ 'Contact' => array(
+ 'className' => 'Contact',
+ 'joinTable' => 'contacts_methods',
+ 'foreignKey' => 'method_id',
+ 'associationForeignKey' => 'contact_id',
+ 'unique' => true,
+ 'conditions' => "ContactsMethod.method = 'POST'",
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+}
+?>
\ No newline at end of file
diff --git a/site/models/contact_email.php b/site/models/contact_email.php
index 3f4a7e9..c9b59dd 100644
--- a/site/models/contact_email.php
+++ b/site/models/contact_email.php
@@ -7,7 +7,6 @@ class ContactEmail extends AppModel {
'email' => array('email')
);
- //The Associations below have been created with all possible keys, those that are not needed can be removed
var $hasAndBelongsToMany = array(
'Contact' => array(
'className' => 'Contact',
diff --git a/site/models/contact_phone.php b/site/models/contact_phone.php
new file mode 100644
index 0000000..79b9807
--- /dev/null
+++ b/site/models/contact_phone.php
@@ -0,0 +1,31 @@
+ array('numeric'),
+ //'type' => array('inlist'),
+ 'phone' => array('phone'),
+ 'ext' => array('numeric')
+ );
+
+ var $hasAndBelongsToMany = array(
+ 'Contact' => array(
+ 'className' => 'Contact',
+ 'joinTable' => 'contacts_methods',
+ 'foreignKey' => 'method_id',
+ 'associationForeignKey' => 'contact_id',
+ 'unique' => true,
+ 'conditions' => "ContactsMethod.method = 'PHONE'",
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/views/transactions/contact.ctp b/site/views/transactions/contact.ctp
index 18d6021..8ea105c 100644
--- a/site/views/transactions/contact.ctp
+++ b/site/views/transactions/contact.ctp
@@ -5,23 +5,117 @@
$val) {
$rows[] = array(array($col, 'width=1%'), $val);
}
+
echo('' . "\n");
echo(' Tenant Info' . "\n");
-echo $html->tableCells($rows, null, array('class' => "altrow"));
+echo $html->tableCells(array(array('Name', $tenant['Contact']['display_name']),
+ array('Company', $tenant['Contact']['company_name']),
+ array('SSN', $tenant['Contact']['id_federal']),
+ array('ID', $tenant['Contact']['id_num']
+ . ($tenant['Contact']['id_state']
+ ? " - ".$tenant['Contact']['id_state']
+ : ""))),
+ null, array('class' => "altrow"), false, false);
echo('
' . "\n");
+
+/**********************************************************************
+ * Phones
+ */
+$headers = array('Location', 'Preference', 'Type', 'Phone', 'Extension', 'Comment');
+$rows = array();
+foreach($tenant['ContactPhone'] AS $phone) {
+ $rows[] = array($phone['ContactsMethod']['type'],
+ $phone['ContactsMethod']['preference'],
+ $phone['type'],
+ phone($phone['phone']),
+ $phone['ext'],
+ $phone['comment']);
+}
+
+if (count($rows)) {
+ echo('' . "\n");
+ echo(' Phone' . "\n");
+ echo $html->tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ echo('
' . "\n");
+}
+
+
+/**********************************************************************
+ * Emails
+ */
+$headers = array('Location', 'Preference', 'Email', 'Comment');
+$rows = array();
+foreach($tenant['ContactEmail'] AS $email) {
+ $rows[] = array($email['ContactsMethod']['type'],
+ $email['ContactsMethod']['preference'],
+ $email['email'],
+ $email['comment']);
+}
+
+if (count($rows)) {
+ echo('' . "\n");
+ echo(' Email' . "\n");
+ echo $html->tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ echo('
' . "\n");
+}
+
+
+/**********************************************************************
+ * Addresses
+ */
+$headers = array('Location', 'Preference', 'Address', 'City', 'State', 'Zip', 'Country', 'Comment');
+$rows = array();
+foreach($tenant['ContactAddress'] AS $address) {
+ $rows[] = array($address['ContactsMethod']['type'],
+ $address['ContactsMethod']['preference'],
+ $address['address'],
+ $address['city'],
+ $address['state'],
+ $address['postcode'],
+ $address['country'],
+ $address['comment']);
+}
+
+if (count($rows)) {
+ echo('' . "\n");
+ echo(' Address' . "\n");
+ echo $html->tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ echo('
' . "\n");
+}
+
+
+/**********************************************************************
+ * Ledger History
+ */
$grand_total = 0;
foreach($tenant['Lease'] AS $lease) {
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
@@ -31,8 +125,8 @@ foreach($tenant['Lease'] AS $lease) {
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
- $rows[] = array(date_format(date_create($charge['charge_date']), 'm-d-Y') . ' - ' .
- date_format(date_create($charge['charge_to_date']), 'm-d-Y'),
+ $rows[] = array(date_format(date_create($charge['charge_date']), $date_fmt) . ' - ' .
+ date_format(date_create($charge['charge_to_date']), $date_fmt),
'#'.$charge['id'],
$charge['ChargeType']['name'],
$charge['comment'],
@@ -42,10 +136,10 @@ foreach($tenant['Lease'] AS $lease) {
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
- $rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), 'm-d-Y'),
+ $rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), $date_fmt),
//null,
'#'.$receipt['id'],
- 'Receipt',
+ 'Payment/Receipt',
$receipt['comment'],
currency($amount),
currency($running_total));
@@ -56,11 +150,11 @@ foreach($tenant['Lease'] AS $lease) {
echo('' . "\n");
echo(' Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')' . "\n");
echo $html->tableHeaders($headers);
- echo $html->tableCells($rows, null, array('class' => "altrow"));
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('
' . "\n");
}
?>
-Grand Total:
+Outstanding Balance:
From 0ef51ee30fa9fb9e00302bf587f6c073794a1821 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 06:40:40 +0000
Subject: [PATCH 016/717] Added a Financial Accounts table, for allowing
transactions to be exported to financial software (definition is presently
incomplete). Rearranged the table definitions a bit as well.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@17 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 248 +++++++++++++++++++++++++++++++-------------------
1 file changed, 155 insertions(+), 93 deletions(-)
diff --git a/db/schema.sql b/db/schema.sql
index 3b710be..a014c03 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -706,7 +706,161 @@ CREATE TABLE `pmgr_contacts_leases` (
-- ######################################################################
-- ######################################################################
-- ##
--- ## TRANSACTIONS
+-- ## FINANCIAL ACCOUNTS
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE pmgr_accounts
+
+DROP TABLE IF EXISTS `pmgr_accounts`;
+CREATE TABLE `pmgr_accounts` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `name` VARCHAR(80) NOT NULL,
+ `external_name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## CHARGES
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE pmgr_charge_types
+
+DROP TABLE IF EXISTS `pmgr_charge_types`;
+CREATE TABLE `pmgr_charge_types` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+ `account_id` INT(10) UNSIGNED NOT NULL, -- quickbooks tracking
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+LOCK TABLES `pmgr_charge_types` WRITE;
+INSERT INTO `pmgr_charge_types` (`id`, `name`, `account_id`)
+ VALUES
+ (1, 'Security Deposit', 0),
+ (2, 'Rent', 0),
+ (3, 'Late Charge', 0);
+UNLOCK TABLES;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE pmgr_charges
+
+DROP TABLE IF EXISTS `pmgr_charges`;
+CREATE TABLE `pmgr_charges` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `charge_type_id` INT(10) UNSIGNED NOT NULL,
+ `lease_id` INT(10) UNSIGNED NOT NULL,
+ `charge_date` DATE NOT NULL,
+ `charge_to_date` DATE NOT NULL,
+ `due_date` DATE DEFAULT NULL,
+ `amount` FLOAT(12,2) NOT NULL,
+ `tax` FLOAT(12,2) NOT NULL,
+ `total` FLOAT(12,2) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## PAYMENTS
+-- ##
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE pmgr_payment_types
+
+DROP TABLE IF EXISTS `pmgr_payment_types`;
+CREATE TABLE `pmgr_payment_types` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `name` VARCHAR(80) NOT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+ `tillable` TINYINT(1) NOT NULL DEFAULT 1, -- Does manager collect by hand?
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+LOCK TABLES `pmgr_payment_types` WRITE;
+INSERT INTO `pmgr_payment_types` (`id`, `name`, `tillable`)
+ VALUES
+ (1, 'Cash', 1),
+ (2, 'Check', 1),
+ (3, 'Money Order', 1),
+ (4, 'ACH', 0),
+ (5, 'Debit Card', 0),
+ (6, 'Credit Card', 0),
+ (7, 'Other Tillable', 1),
+ (8, 'Other Non-Tillable', 0);
+UNLOCK TABLES;
+
+
+-- ----------------------------------------------------------------------
+-- ----------------------------------------------------------------------
+-- TABLE pmgr_payments
+
+DROP TABLE IF EXISTS `pmgr_payments`;
+CREATE TABLE `pmgr_payments` (
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+
+ `receipt_id` INT(10) UNSIGNED NOT NULL,
+ `payment_type_id` INT(10) UNSIGNED NOT NULL,
+ `amount` FLOAT(12,2) NOT NULL,
+
+ `comment` VARCHAR(255) DEFAULT NULL,
+
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+
+
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ######################################################################
+-- ##
+-- ## RECEIPTS
-- ##
-- # Charge
@@ -747,80 +901,6 @@ CREATE TABLE `pmgr_contacts_leases` (
-- LEFT JOIN pmgr_units U ON U.id = L.unit_id
--- ----------------------------------------------------------------------
--- ----------------------------------------------------------------------
--- TABLE pmgr_charge_types
-
-DROP TABLE IF EXISTS `pmgr_charge_types`;
-CREATE TABLE `pmgr_charge_types` (
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-
- `name` VARCHAR(80) NOT NULL,
- `comment` VARCHAR(255) DEFAULT NULL,
- `account_id` INT(10) UNSIGNED NOT NULL, -- quickbooks tracking
-
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
-LOCK TABLES `pmgr_charge_types` WRITE;
-INSERT INTO `pmgr_charge_types` (`id`, `name`, `account_id`)
- VALUES
- (1, 'Security Deposit', 0),
- (2, 'Rent', 0),
- (3, 'Late Charge', 0);
-UNLOCK TABLES;
-
--- ----------------------------------------------------------------------
--- ----------------------------------------------------------------------
--- TABLE pmgr_payment_types
-
-DROP TABLE IF EXISTS `pmgr_payment_types`;
-CREATE TABLE `pmgr_payment_types` (
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-
- `name` VARCHAR(80) NOT NULL,
- `comment` VARCHAR(255) DEFAULT NULL,
- `tillable` TINYINT(1) NOT NULL DEFAULT 1, -- Does manager collect by hand?
-
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
-LOCK TABLES `pmgr_payment_types` WRITE;
-INSERT INTO `pmgr_payment_types` (`id`, `name`, `tillable`)
- VALUES
- (1, 'Cash', 1),
- (2, 'Check', 1),
- (3, 'Money Order', 1),
- (4, 'ACH', 0),
- (5, 'Debit Card', 0),
- (6, 'Credit Card', 0),
- (7, 'Other Tillable', 1),
- (8, 'Other Non-Tillable', 0);
-UNLOCK TABLES;
-
-
--- ----------------------------------------------------------------------
--- ----------------------------------------------------------------------
--- TABLE pmgr_charges
-
-DROP TABLE IF EXISTS `pmgr_charges`;
-CREATE TABLE `pmgr_charges` (
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-
- `charge_type_id` INT(10) UNSIGNED NOT NULL,
- `lease_id` INT(10) UNSIGNED NOT NULL,
- `charge_date` DATE NOT NULL,
- `charge_to_date` DATE NOT NULL,
- `due_date` DATE DEFAULT NULL,
- `amount` FLOAT(12,2) NOT NULL,
- `tax` FLOAT(12,2) NOT NULL,
- `total` FLOAT(12,2) NOT NULL,
- `comment` VARCHAR(255) DEFAULT NULL,
-
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
-
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
-- TABLE pmgr_receipts
@@ -837,24 +917,6 @@ CREATE TABLE `pmgr_receipts` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--- ----------------------------------------------------------------------
--- ----------------------------------------------------------------------
--- TABLE pmgr_payments
-
-DROP TABLE IF EXISTS `pmgr_payments`;
-CREATE TABLE `pmgr_payments` (
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
-
- `receipt_id` INT(10) UNSIGNED NOT NULL,
- `payment_type_id` INT(10) UNSIGNED NOT NULL,
- `amount` FLOAT(12,2) NOT NULL,
-
- `comment` VARCHAR(255) DEFAULT NULL,
-
- PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
-
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
-- TABLE pmgr_charges_receipts
From 0021eb176843a9c3a12d009d0925d80a7cfb54c4 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 06:42:20 +0000
Subject: [PATCH 017/717] Changed the charge/receipt comments slightly to help
clarify the intent.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@18 97e9348a-65ac-dc4b-aefc-98561f571b83
---
scripts/sitelink2pmgr.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl
index 0a435a1..5d95b4f 100644
--- a/scripts/sitelink2pmgr.pl
+++ b/scripts/sitelink2pmgr.pl
@@ -651,7 +651,7 @@ foreach $row (@$result) {
datefmt($row->{'ChargeDate'}), datefmt($row->{'EndDate'}),
$row->{'ChargeAmount'}, $row->{'TaxAmount'},
$row->{'ChargeAmount'} + $row->{'TaxAmount'},
- "ChargeID #".$row->{'ChargeID'})
+ "SiteLink Charges.ChargeID #".$row->{'ChargeID'})
)) . ")";
query($db_handle, $query) || die("Unable to insert");
@@ -680,7 +680,7 @@ foreach $row (@$result) {
VALUES (" .
join(", ", map({defined $_ ? "'$_'" : "NULL"}
($rid, datefmt($row->{'ReceiptDate'}),
- "ReceiptNum #".$row->{'ReceiptNum'})
+ "SiteLink Receipts.ReceiptNum #".$row->{'ReceiptNum'})
)) . ")";
query($db_handle, $query) || die("Unable to insert");
}
From ffe04ed6fdc67538b2fe49ed805918b119524c4b Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 07:05:05 +0000
Subject: [PATCH 018/717] Added Lease History and security deposit tracking.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@19 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/views/transactions/contact.ctp | 45 +++++++++++++++++++++++++----
1 file changed, 39 insertions(+), 6 deletions(-)
diff --git a/site/views/transactions/contact.ctp b/site/views/transactions/contact.ctp
index 8ea105c..631e709 100644
--- a/site/views/transactions/contact.ctp
+++ b/site/views/transactions/contact.ctp
@@ -5,7 +5,6 @@
' . "\n");
+echo(' Lease History' . "\n");
+echo $html->tableHeaders($headers);
+echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+echo('' . "\n");
+
+
/**********************************************************************
* Ledger History
*/
+$security_deposit = 0;
$grand_total = 0;
foreach($tenant['Lease'] AS $lease) {
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
@@ -125,8 +155,7 @@ foreach($tenant['Lease'] AS $lease) {
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
- $rows[] = array(date_format(date_create($charge['charge_date']), $date_fmt) . ' - ' .
- date_format(date_create($charge['charge_to_date']), $date_fmt),
+ $rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
'#'.$charge['id'],
$charge['ChargeType']['name'],
$charge['comment'],
@@ -136,8 +165,11 @@ foreach($tenant['Lease'] AS $lease) {
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
- $rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), $date_fmt),
- //null,
+ // REVISIT 20090527:
+ // Using hardcoded value for security deposit... can't be good!
+ if ($charge['charge_type_id'] == 1)
+ $security_deposit += $receipt['ChargesReceipt']['amount'];
+ $rows[] = array(' -- ' . datefmt($receipt['stamp']),
'#'.$receipt['id'],
'Payment/Receipt',
$receipt['comment'],
@@ -148,7 +180,7 @@ foreach($tenant['Lease'] AS $lease) {
$grand_total += $running_total;
echo('' . "\n");
- echo(' Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')' . "\n");
+ echo(' Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')' . "\n");
echo $html->tableHeaders($headers);
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('
' . "\n");
@@ -156,5 +188,6 @@ foreach($tenant['Lease'] AS $lease) {
}
?>
+Total Security Deposit:
Outstanding Balance:
From 49237122380ebd8469731799a36d784e70db35b4 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 07:12:32 +0000
Subject: [PATCH 019/717] Moved the contact info into the contacts controller.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@20 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/contacts_controller.php | 21 ++
site/controllers/transactions_controller.php | 36 ----
site/views/contacts/view.ctp | 66 +++++++
site/views/transactions/contact.ctp | 193 -------------------
site/views/transactions/ledger.ctp | 53 -----
site/views/transactions/ledger_1.ctp | 58 ------
6 files changed, 87 insertions(+), 340 deletions(-)
create mode 100644 site/controllers/contacts_controller.php
delete mode 100644 site/controllers/transactions_controller.php
create mode 100644 site/views/contacts/view.ctp
delete mode 100644 site/views/transactions/contact.ctp
delete mode 100644 site/views/transactions/ledger.ctp
delete mode 100644 site/views/transactions/ledger_1.ctp
diff --git a/site/controllers/contacts_controller.php b/site/controllers/contacts_controller.php
new file mode 100644
index 0000000..f372274
--- /dev/null
+++ b/site/controllers/contacts_controller.php
@@ -0,0 +1,21 @@
+Session->setFlash(__('Invalid Item.', true));
+ $this->redirect(array('action'=>''));
+ }
+ $this->Contact->recursive = 4;
+ $this->Contact->Lease->LeaseType->unbindModel(array('hasMany' => array('Lease')));
+ $this->Contact->Lease->Charge->unbindModel(array('belongsTo' => array('Lease')));
+ $this->Contact->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge')));
+ $this->Contact->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt')));
+
+ $this->set('tenant', $this->Contact->read(null, $id));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/site/controllers/transactions_controller.php b/site/controllers/transactions_controller.php
deleted file mode 100644
index f4501ef..0000000
--- a/site/controllers/transactions_controller.php
+++ /dev/null
@@ -1,36 +0,0 @@
-Session->setFlash(__('Invalid Item.', true));
- $this->redirect(array('action'=>''));
- }
- $this->Charge->recursive = 0;
- //$ledgers = array($this->Charge->read(null, $id));
- $this->set('ledgers', $this->Charge->find('all'));
- //$this->set(compact('ledgers', 'tables'));
- }
-
- function contact($id = null) {
- if (!$id) {
- $this->Session->setFlash(__('Invalid Item.', true));
- $this->redirect(array('action'=>''));
- }
- $this->Contact->recursive = 4;
- $this->Contact->Lease->LeaseType->unbindModel(array('hasMany' => array('Lease')));
- $this->Contact->Lease->Charge->unbindModel(array('belongsTo' => array('Lease')));
- $this->Contact->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge')));
- $this->Contact->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt')));
-
- //$ledgers = array($this->Charge->read(null, $id));
- //$this->set('ledgers', $this->Contact->Lease->Charge->find('all'));
- //$this->set(compact('ledgers', 'tables'));
- $this->set('tenant', $this->Contact->read(null, $id));
- }
-}
-
-?>
\ No newline at end of file
diff --git a/site/views/contacts/view.ctp b/site/views/contacts/view.ctp
new file mode 100644
index 0000000..18d6021
--- /dev/null
+++ b/site/views/contacts/view.ctp
@@ -0,0 +1,66 @@
+
+
+
diff --git a/site/views/transactions/contact.ctp b/site/views/transactions/contact.ctp
deleted file mode 100644
index 631e709..0000000
--- a/site/views/transactions/contact.ctp
+++ /dev/null
@@ -1,193 +0,0 @@
-
-
-
-
-
- $val) {
- $rows[] = array(array($col, 'width=1%'), $val);
-}
-
-echo('
' . "\n");
-echo(' Tenant Info' . "\n");
-echo $html->tableCells(array(array('Name', $tenant['Contact']['display_name']),
- array('Company', $tenant['Contact']['company_name']),
- array('SSN', $tenant['Contact']['id_federal']),
- array('ID', $tenant['Contact']['id_num']
- . ($tenant['Contact']['id_state']
- ? " - ".$tenant['Contact']['id_state']
- : ""))),
- null, array('class' => "altrow"), false, false);
-echo('
' . "\n");
-
-
-/**********************************************************************
- * Phones
- */
-$headers = array('Location', 'Preference', 'Type', 'Phone', 'Extension', 'Comment');
-$rows = array();
-foreach($tenant['ContactPhone'] AS $phone) {
- $rows[] = array($phone['ContactsMethod']['type'],
- $phone['ContactsMethod']['preference'],
- $phone['type'],
- phone($phone['phone']),
- $phone['ext'],
- $phone['comment']);
-}
-
-if (count($rows)) {
- echo('
' . "\n");
- echo(' Phone' . "\n");
- echo $html->tableHeaders($headers);
- echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
- echo('
' . "\n");
-}
-
-
-/**********************************************************************
- * Emails
- */
-$headers = array('Location', 'Preference', 'Email', 'Comment');
-$rows = array();
-foreach($tenant['ContactEmail'] AS $email) {
- $rows[] = array($email['ContactsMethod']['type'],
- $email['ContactsMethod']['preference'],
- $email['email'],
- $email['comment']);
-}
-
-if (count($rows)) {
- echo('
' . "\n");
- echo(' Email' . "\n");
- echo $html->tableHeaders($headers);
- echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
- echo('
' . "\n");
-}
-
-
-/**********************************************************************
- * Addresses
- */
-$headers = array('Location', 'Preference', 'Address', 'City', 'State', 'Zip', 'Country', 'Comment');
-$rows = array();
-foreach($tenant['ContactAddress'] AS $address) {
- $rows[] = array($address['ContactsMethod']['type'],
- $address['ContactsMethod']['preference'],
- $address['address'],
- $address['city'],
- $address['state'],
- $address['postcode'],
- $address['country'],
- $address['comment']);
-}
-
-if (count($rows)) {
- echo('
' . "\n");
- echo(' Address' . "\n");
- echo $html->tableHeaders($headers);
- echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
- echo('
' . "\n");
-}
-
-
-/**********************************************************************
- * Lease History
- */
-$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
-$rows = array();
-foreach($tenant['Lease'] AS $lease) {
- $rows[] = array('#'.$lease['id'],
- $lease['Unit']['name'],
- datefmt($lease['lease_date']),
- datefmt($lease['movein_date']),
- datefmt($lease['moveout_date']),
- $lease['amount'],
- $lease['deposit'],
- $lease['comment']);
-}
-
-echo('
' . "\n");
-echo(' Lease History' . "\n");
-echo $html->tableHeaders($headers);
-echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
-echo('
' . "\n");
-
-
-/**********************************************************************
- * Ledger History
- */
-$security_deposit = 0;
-$grand_total = 0;
-foreach($tenant['Lease'] AS $lease) {
- $headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
-
- $rows = array();
- $running_total = 0;
- foreach($lease['Charge'] AS $charge) {
- $amount = $charge['total'];
- $running_total += $amount;
- $rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
- '#'.$charge['id'],
- $charge['ChargeType']['name'],
- $charge['comment'],
- currency($amount),
- currency($running_total));
-
- foreach ($charge['Receipt'] AS $receipt) {
- $amount = -1 * $receipt['ChargesReceipt']['amount'];
- $running_total += $amount;
- // REVISIT
20090527:
- // Using hardcoded value for security deposit... can't be good!
- if ($charge['charge_type_id'] == 1)
- $security_deposit += $receipt['ChargesReceipt']['amount'];
- $rows[] = array(' -- ' . datefmt($receipt['stamp']),
- '#'.$receipt['id'],
- 'Payment/Receipt',
- $receipt['comment'],
- currency($amount),
- currency($running_total));
- }
- }
- $grand_total += $running_total;
-
- echo('' . "\n");
- echo(' Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')' . "\n");
- echo $html->tableHeaders($headers);
- echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
- echo('
' . "\n");
-
-}
-?>
-
-Total Security Deposit:
-Outstanding Balance:
-
diff --git a/site/views/transactions/ledger.ctp b/site/views/transactions/ledger.ctp
deleted file mode 100644
index fd59df5..0000000
--- a/site/views/transactions/ledger.ctp
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
- $table) {
-
- if (array_key_exists(0, $table)) {
- // Horizontal table (multiple items)
- $headers = array_keys($table[0]);
-
- //$rows = array_map('array_values', $table);
- $rows = array();
- //echo("
table:\n"); print_r($table); echo("\n");
- foreach ($table as $row) {
- //echo("
row:\n"); print_r($row); echo("\n");
- $rows[] = array_values($row);
- }
- }
- else {
- // Vertical table (one item)
- $headers = array('Field', 'Value');
-
- $rows = array();
- foreach ($table as $col => $val) {
- $rows[] = array($col, $val);
- }
- }
-
- foreach($rows AS &$row) {
- foreach ($row AS &$cell) {
- if (is_array($cell))
- $cell = "<ARRAY>";
- }
- }
- //echo("
headers:\n"); print_r($headers); echo("\n");
- //echo("
rows:\n"); print_r($rows); echo("\n");
- ?>
-
-
- tableHeaders($headers);
- echo $html->tableCells($rows, null, array('class' => "altrow"));
- ?>
-
-
-
-
\ No newline at end of file
diff --git a/site/views/transactions/ledger_1.ctp b/site/views/transactions/ledger_1.ctp
deleted file mode 100644
index 316e24a..0000000
--- a/site/views/transactions/ledger_1.ctp
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-counter(array(
- 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
-
- $cells = array($paginator->sort('id'),
- $paginator->sort('charge_type_id'),
- $paginator->sort('lease_id'),
- $paginator->sort('charge_date'),
- $paginator->sort('charge_to_date'),
- $paginator->sort('due_date'),
- $paginator->sort('amount'),
- $paginator->sort('tax'),
- $paginator->sort('total'),
- $paginator->sort('comment'));
-} else {
- $cells = array('Id', 'Type', 'Lease', 'Date', 'Through', 'Due', 'Amount', 'Tax', 'Total', 'Comment');
-}
-echo $html->tableHeaders($cells);
-
-$cells = array();
-foreach ($ledgers as $ledger) {
- $cells[] = array($html->link($ledger['Charge']['id'],
- array('controller' => 'transactions',
- 'action' => 'view',
- $ledger['Charge']['id'])),
- $ledger['Charge']['charge_type_id'],
- $ledger['Charge']['lease_id'],
- $ledger['Charge']['charge_date'],
- $ledger['Charge']['charge_to_date'],
- $ledger['Charge']['due_date'],
- $ledger['Charge']['amount'],
- $ledger['Charge']['tax'],
- $ledger['Charge']['total'],
- $ledger['Charge']['comment']);
-}
-echo $html->tableCells($cells, null, array('class' => "altrow"));
-?>
-
-
-' . "\n");
- echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
- echo(' | ');
- echo $paginator->numbers();
- echo(' | ');
- echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
- echo('
' . "\n");
- }
-?>
-
-
-
\ No newline at end of file
From ed04f81dda882563016a1aad357f7034425c8cc1 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 08:03:12 +0000
Subject: [PATCH 020/717] Modified to allow the display_name to be NULL
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@21 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 4 +++-
scripts/sitelink2pmgr.pl | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/db/schema.sql b/db/schema.sql
index a014c03..fb9cc13 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -127,7 +127,7 @@ CREATE TABLE `pmgr_contacts` (
`middle_name` VARCHAR(255) DEFAULT NULL,
`last_name` VARCHAR(255) DEFAULT NULL,
`company_name` VARCHAR(255) DEFAULT NULL,
- `display_name` VARCHAR(512) NOT NULL,
+ `display_name` VARCHAR(512) DEFAULT NULL,
-- FEDERAL ID, e.g. SSN or EIN
`id_federal` VARCHAR(16) DEFAULT NULL,
@@ -137,6 +137,8 @@ CREATE TABLE `pmgr_contacts` (
`id_state` CHAR(2) DEFAULT NULL,
`id_exp` DATE DEFAULT NULL,
+ `comment` VARCHAR(255) DEFAULT NULL,
+
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl
index 5d95b4f..dd3ce4c 100644
--- a/scripts/sitelink2pmgr.pl
+++ b/scripts/sitelink2pmgr.pl
@@ -513,7 +513,7 @@ foreach $row (@$result) {
$row->{'AltLastName'} || undef,
($row->{'AltLastName'} && $row->{'AltFirstName'}
? "$row->{'AltLastName'}, $row->{'AltFirstName'}"
- : ($row->{'AltLastName'} || $row->{'AltFirstName'} || '')))
+ : ($row->{'AltLastName'} || $row->{'AltFirstName'} || undef)))
)) . ")";
query($db_handle, $query) || die("Unable to insert");
From 839340344325a33f88c99c2abe0437b0f201026e Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 08:04:22 +0000
Subject: [PATCH 021/717] First pass at listing the customers. Need to figure
out how to paginate based on a HABTM relationship.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@22 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/contacts_controller.php | 26 ++++++++-
site/views/contacts/index.ctp | 3 +
site/views/elements/contacts.ctp | 74 ++++++++++++++++++++++++
3 files changed, 102 insertions(+), 1 deletion(-)
create mode 100644 site/views/contacts/index.ctp
create mode 100644 site/views/elements/contacts.ctp
diff --git a/site/controllers/contacts_controller.php b/site/controllers/contacts_controller.php
index f372274..a8e789a 100644
--- a/site/controllers/contacts_controller.php
+++ b/site/controllers/contacts_controller.php
@@ -2,7 +2,31 @@
class ContactsController extends AppController {
var $helpers = array('Html');
-
+
+ var $paginate = array('limit' => 100,
+ 'order' => array('Contact.last_name' => 'ASC',
+ 'Contact.first_name' => 'ASC'));
+
+ function index() {
+ $this->all();
+ }
+
+ function current() {
+ $this->Contact->recursive = 0;
+ $this->set('contacts', $this->paginate(array('Lease.closed_date IS NULL',
+ //'Contact.'
+ )));
+ $this->render('index');
+ }
+
+ function all() {
+ $this->Contact->recursive = 2;
+
+ //$contacts = $this->paginate();
+ $this->set('contacts', $this->paginate());
+ $this->render('index');
+ }
+
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
diff --git a/site/views/contacts/index.ctp b/site/views/contacts/index.ctp
new file mode 100644
index 0000000..15d92e7
--- /dev/null
+++ b/site/views/contacts/index.ctp
@@ -0,0 +1,3 @@
+
+element('contacts') ?>
+
diff --git a/site/views/elements/contacts.ctp b/site/views/elements/contacts.ctp
new file mode 100644
index 0000000..041d428
--- /dev/null
+++ b/site/views/elements/contacts.ctp
@@ -0,0 +1,74 @@
+
+
+
+'.__('Contacts',true).'';
+?>
+
+
+
+
+ counter(array(
+ 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
+
+ $rows = array($paginator->sort('id'),
+ $paginator->sort('last_name'),
+ $paginator->sort('first_name'),
+ $paginator->sort('company_name'),
+ //$paginator->sort('unit_id'),
+ $paginator->sort('comment'));
+ } else {
+ $rows = array('Id', 'Last Name', 'First Name', 'Company', 'Comment');
+ }
+ echo $html->tableHeaders($rows);
+
+ $rows = array();
+ foreach ($contacts as $contact) {
+/* // REVISIT 20090528: */
+/* // The controller really should handle this, but at the moment */
+/* // it's not clear how. So, let's just cheat. */
+/* $primary = 0; */
+/* foreach ($contact['Lease'] AS $lease) { */
+/* if ($lease['ContactsLease']['type'] != 'ALTERNATE') */
+/* $primary = 1; */
+/* } */
+/* if (!$primary) */
+/* continue; */
+
+ $rows[] = array($html->link($contact['Contact']['id'],
+ array('controller' => 'contacts',
+ 'action' => 'view',
+ $contact['Contact']['id'])),
+ $html->link($contact['Contact']['last_name'],
+ array('controller' => 'contacts',
+ 'action' => 'view',
+ $contact['Contact']['id'])),
+ $html->link($contact['Contact']['first_name'],
+ array('controller' => 'contacts',
+ 'action' => 'view',
+ $contact['Contact']['id'])),
+ $contact['Contact']['company_name'],
+ $contact['Contact']['comment']);
+ }
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ }
+?>
+
+
+' . "\n");
+ echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
+ echo(' | ');
+ echo $paginator->numbers();
+ echo(' | ');
+ echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
+ echo('' . "\n");
+ }
+?>
From 7433e6868c6053412fa389a75d74e50647b8958e Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 09:07:53 +0000
Subject: [PATCH 022/717] Fixed duplicate row entries and other paginate
issues. The fix might be a hack, but it works for now.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@23 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/contacts_controller.php | 21 ++++++++++++++-------
site/models/contact.php | 13 +++++++++++++
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/site/controllers/contacts_controller.php b/site/controllers/contacts_controller.php
index a8e789a..eaf90df 100644
--- a/site/controllers/contacts_controller.php
+++ b/site/controllers/contacts_controller.php
@@ -13,17 +13,24 @@ class ContactsController extends AppController {
function current() {
$this->Contact->recursive = 0;
- $this->set('contacts', $this->paginate(array('Lease.closed_date IS NULL',
- //'Contact.'
- )));
+ $this->Contact->bindModel(array('hasOne' => array('ContactsLease',
+ 'Lease' => array(
+ 'foreignKey' => false,
+ 'conditions' => array('Lease.id = ContactsLease.lease_id')
+ ))),
+ false);
+
+ $this->set('contacts', $this->paginate(array('Lease.close_date IS NULL',
+ 'ContactsLease.type != "ALTERNATE"')));
$this->render('index');
}
function all() {
- $this->Contact->recursive = 2;
-
- //$contacts = $this->paginate();
- $this->set('contacts', $this->paginate());
+ $this->Contact->recursive = 0;
+ $this->Contact->bindModel(array('hasOne' => array('ContactsLease')),
+ false);
+
+ $this->set('contacts', $this->paginate(array('ContactsLease.type != "ALTERNATE"')));
$this->render('index');
}
diff --git a/site/models/contact.php b/site/models/contact.php
index 5aab7f3..96d12bb 100644
--- a/site/models/contact.php
+++ b/site/models/contact.php
@@ -72,5 +72,18 @@ class Contact extends AppModel {
),
);
+ // Overriding pagination, since the controller using HABTM joins that
+ // result in duplicate rows. This may not be the best way to handle
+ // things (especially if the query return a really large number of rows,
+ // but it does seem to work.
+ function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null) {
+ $conditions[] ="1=1 GROUP BY Contact.id";
+ return $this->findAll($conditions, $fields, $order, $limit, $page, $recursive);
+ }
+ function paginateCount($conditions = null, $recursive = 0) {
+ $rows = $this->paginate($conditions, null, null, null, null, $recursive);
+ return count($rows);
+ }
+
}
?>
\ No newline at end of file
From aed2c6912cbd9425cf3309fe395d69cd332a62fa Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 09:27:29 +0000
Subject: [PATCH 023/717] Added more models
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@24 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/models/account.php | 29 +++++++++++++++++++++++
site/models/map.php | 44 +++++++++++++++++++++++++++++++++++
site/models/maps_unit.php | 15 ++++++++++++
site/models/site.php | 41 ++++++++++++++++++++++++++++++++
site/models/site_area.php | 34 +++++++++++++++++++++++++++
site/models/unit.php | 49 +++++++++++++++++++++++++++++++++++++++
site/models/unit_size.php | 44 +++++++++++++++++++++++++++++++++++
site/models/unit_type.php | 29 +++++++++++++++++++++++
8 files changed, 285 insertions(+)
create mode 100644 site/models/account.php
create mode 100644 site/models/map.php
create mode 100644 site/models/maps_unit.php
create mode 100644 site/models/site.php
create mode 100644 site/models/site_area.php
create mode 100644 site/models/unit.php
create mode 100644 site/models/unit_size.php
create mode 100644 site/models/unit_type.php
diff --git a/site/models/account.php b/site/models/account.php
new file mode 100644
index 0000000..35eeca0
--- /dev/null
+++ b/site/models/account.php
@@ -0,0 +1,29 @@
+ array('numeric'),
+ 'name' => array('notempty'),
+ 'external_name' => array('notempty')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $hasMany = array(
+ 'ChargeType' => array(
+ 'className' => 'ChargeType',
+ 'foreignKey' => 'account_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/map.php b/site/models/map.php
new file mode 100644
index 0000000..c9c2c2e
--- /dev/null
+++ b/site/models/map.php
@@ -0,0 +1,44 @@
+ array('numeric'),
+ 'site_id' => array('numeric'),
+ 'site_area_id' => array('numeric'),
+ 'name' => array('notempty'),
+ 'width' => array('numeric'),
+ 'depth' => array('numeric')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $belongsTo = array(
+ 'SiteArea' => array(
+ 'className' => 'SiteArea',
+ 'foreignKey' => 'site_area_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+ var $hasAndBelongsToMany = array(
+ 'Unit' => array(
+ 'className' => 'Unit',
+ 'joinTable' => 'maps_units',
+ 'foreignKey' => 'map_id',
+ 'associationForeignKey' => 'unit_id',
+ 'unique' => true,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'finderQuery' => '',
+ 'deleteQuery' => '',
+ 'insertQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/maps_unit.php b/site/models/maps_unit.php
new file mode 100644
index 0000000..4486e27
--- /dev/null
+++ b/site/models/maps_unit.php
@@ -0,0 +1,15 @@
+ array('numeric'),
+ 'map_id' => array('numeric'),
+ 'unit_id' => array('numeric'),
+ 'pt_top' => array('numeric'),
+ 'pt_left' => array('numeric'),
+ 'transpose' => array('boolean')
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/site.php b/site/models/site.php
new file mode 100644
index 0000000..d2882df
--- /dev/null
+++ b/site/models/site.php
@@ -0,0 +1,41 @@
+ array('numeric'),
+ 'name' => array('notempty')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $hasMany = array(
+ 'SiteArea' => array(
+ 'className' => 'SiteArea',
+ 'foreignKey' => 'site_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ ),
+ 'SiteOption' => array(
+ 'className' => 'SiteOption',
+ 'foreignKey' => 'site_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/site_area.php b/site/models/site_area.php
new file mode 100644
index 0000000..1aec59f
--- /dev/null
+++ b/site/models/site_area.php
@@ -0,0 +1,34 @@
+ array('numeric'),
+ 'site_id' => array('numeric'),
+ 'name' => array('notempty')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $belongsTo = array(
+ 'Site' => array(
+ 'className' => 'Site',
+ 'foreignKey' => 'site_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+ var $hasOne = array(
+ 'Map' => array(
+ 'className' => 'Map',
+ 'foreignKey' => 'site_area_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/unit.php b/site/models/unit.php
new file mode 100644
index 0000000..643065a
--- /dev/null
+++ b/site/models/unit.php
@@ -0,0 +1,49 @@
+ array('numeric'),
+ 'unit_size_id' => array('numeric'),
+ 'name' => array('notempty'),
+ 'sort_order' => array('numeric'),
+ 'walk_order' => array('numeric'),
+ 'deposit' => array('money'),
+ 'amount' => array('money')
+ );
+
+ var $belongsTo = array(
+ 'UnitSize' => array(
+ 'className' => 'UnitSize',
+ 'foreignKey' => 'unit_size_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ ),
+/* 'Map' => array( */
+/* 'className' => 'MapsUnit', */
+/* 'foreignKey' => 'unit_id', */
+/* 'conditions' => '', */
+/* 'fields' => '', */
+/* 'order' => '' */
+/* ) */
+ );
+
+ var $hasMany = array(
+ 'Lease' => array(
+ 'className' => 'Lease',
+ 'foreignKey' => 'unit_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/unit_size.php b/site/models/unit_size.php
new file mode 100644
index 0000000..5bb39f8
--- /dev/null
+++ b/site/models/unit_size.php
@@ -0,0 +1,44 @@
+ 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')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $belongsTo = array(
+ 'UnitType' => array(
+ 'className' => 'UnitType',
+ 'foreignKey' => 'unit_type_id',
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => ''
+ )
+ );
+
+ var $hasMany = array(
+ 'Unit' => array(
+ 'className' => 'Unit',
+ 'foreignKey' => 'unit_size_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
diff --git a/site/models/unit_type.php b/site/models/unit_type.php
new file mode 100644
index 0000000..06f59e4
--- /dev/null
+++ b/site/models/unit_type.php
@@ -0,0 +1,29 @@
+ array('numeric'),
+ 'code' => array('notempty'),
+ 'name' => array('notempty')
+ );
+
+ //The Associations below have been created with all possible keys, those that are not needed can be removed
+ var $hasMany = array(
+ 'UnitSize' => array(
+ 'className' => 'UnitSize',
+ 'foreignKey' => 'unit_type_id',
+ 'dependent' => false,
+ 'conditions' => '',
+ 'fields' => '',
+ 'order' => '',
+ 'limit' => '',
+ 'offset' => '',
+ 'exclusive' => '',
+ 'finderQuery' => '',
+ 'counterQuery' => ''
+ )
+ );
+
+}
+?>
\ No newline at end of file
From e38e99c94e95c0e3e486a839b300c66a52a5d070 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 09:36:58 +0000
Subject: [PATCH 024/717] Removed the revisit code, as use of it would only
screw up pagination anyway.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@25 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/views/elements/contacts.ctp | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/site/views/elements/contacts.ctp b/site/views/elements/contacts.ctp
index 041d428..f28baa3 100644
--- a/site/views/elements/contacts.ctp
+++ b/site/views/elements/contacts.ctp
@@ -30,17 +30,6 @@
$rows = array();
foreach ($contacts as $contact) {
-/* // REVISIT 20090528: */
-/* // The controller really should handle this, but at the moment */
-/* // it's not clear how. So, let's just cheat. */
-/* $primary = 0; */
-/* foreach ($contact['Lease'] AS $lease) { */
-/* if ($lease['ContactsLease']['type'] != 'ALTERNATE') */
-/* $primary = 1; */
-/* } */
-/* if (!$primary) */
-/* continue; */
-
$rows[] = array($html->link($contact['Contact']['id'],
array('controller' => 'contacts',
'action' => 'view',
From ec3d986c783b9e8001a793f4d3e873a262cab39a Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 11:09:19 +0000
Subject: [PATCH 025/717] Removed site_id from the maps table, since the it
already references site_area_id which fully qualifies the site anyway.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@26 97e9348a-65ac-dc4b-aefc-98561f571b83
---
db/schema.sql | 2 --
1 file changed, 2 deletions(-)
diff --git a/db/schema.sql b/db/schema.sql
index fb9cc13..d78adee 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -957,7 +957,6 @@ CREATE TABLE `pmgr_charges_receipts` (
DROP TABLE IF EXISTS `pmgr_maps`;
CREATE TABLE `pmgr_maps` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
- `site_id` INT(10) UNSIGNED NOT NULL,
`site_area_id` INT(10) UNSIGNED NOT NULL,
`name` VARCHAR(80) DEFAULT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
@@ -965,7 +964,6 @@ CREATE TABLE `pmgr_maps` (
`width` SMALLINT UNSIGNED NOT NULL, -- inches
`depth` SMALLINT UNSIGNED NOT NULL, -- inches
- UNIQUE KEY `map_key` (`site_id`, `site_area_id`),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
From 4a86d3dda0e58014dfc1cd992794fd5618da586d Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 11:09:56 +0000
Subject: [PATCH 026/717] Removal of site_id from the maps table, corresponding
with the last checkin
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@27 97e9348a-65ac-dc4b-aefc-98561f571b83
---
scripts/sitelink2pmgr.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl
index dd3ce4c..63ef777 100644
--- a/scripts/sitelink2pmgr.pl
+++ b/scripts/sitelink2pmgr.pl
@@ -376,8 +376,8 @@ $info{'extents'}{'bottom'} = $internal_adjustment_factor * ($top_adjustment + $
$info{'extents'}{'right'} = $internal_adjustment_factor * ($left_adjustment + $row->{'rgt'} + 0);
$query =
- "INSERT INTO pmgr_maps (id, site_id, site_area_id, width, depth) VALUES\n" .
- " (1, $aicur_site_id, $aicur_area_id," .
+ "INSERT INTO pmgr_maps (id, site_area_id, width, depth) VALUES\n" .
+ " (1, $aicur_area_id," .
($info{'extents'}{'right'} - $info{'extents'}{'left'}) . ", " .
($info{'extents'}{'bottom'} - $info{'extents'}{'top'}) . ")";
query($db_handle, $query) || die("Unable to insert");
From 5c6189cdefb9204f6ba0d7e71bbcc600f032a71d Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 11:26:09 +0000
Subject: [PATCH 027/717] Added preliminary support for units. The queries are
giving me a heck of a time, so I've cheated in some places. For the most
part though, it's working. Also, something went wrong with svn, and
view/contacts/view.ctp was not right (a checkin seems to have been omitted on
it). This checking brings it up to date.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@28 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/units_controller.php | 123 ++++++++++++++++++++
site/models/unit_size.php | 1 -
site/models/unit_type.php | 1 -
site/views/contacts/view.ctp | 156 +++++++++++++++++++++++---
site/views/elements/units.ctp | 59 ++++++++++
site/views/units/index.ctp | 3 +
site/views/units/view.ctp | 113 +++++++++++++++++++
7 files changed, 439 insertions(+), 17 deletions(-)
create mode 100644 site/controllers/units_controller.php
create mode 100644 site/views/elements/units.ctp
create mode 100644 site/views/units/index.ctp
create mode 100644 site/views/units/view.ctp
diff --git a/site/controllers/units_controller.php b/site/controllers/units_controller.php
new file mode 100644
index 0000000..fe21434
--- /dev/null
+++ b/site/controllers/units_controller.php
@@ -0,0 +1,123 @@
+ 100,
+ 'order' => array('Unit.sort_order' => 'ASC'));
+
+ function index() {
+ $this->all();
+ }
+
+ function vacant() {
+ $this->Unit->recursive = 0;
+ $this->Unit->bindModel(array('hasOne' => array('UnitsLease',
+ 'Lease' => array(
+ 'foreignKey' => false,
+ 'conditions' => array('Lease.id = UnitsLease.lease_id')
+ ))),
+ false);
+
+ $this->set('units', $this->paginate(array('Lease.close_date IS NULL',
+ 'UnitsLease.type != "ALTERNATE"')));
+ $this->render('index');
+ }
+
+ function occupied() {
+ $this->Unit->recursive = 0;
+ $this->Unit->bindModel(array('hasOne' => array('UnitsLease',
+ 'Lease' => array(
+ 'foreignKey' => false,
+ 'conditions' => array('Lease.id = UnitsLease.lease_id')
+ ))),
+ false);
+
+ $this->set('units', $this->paginate(array('Lease.close_date IS NULL',
+ 'UnitsLease.type != "ALTERNATE"')));
+ $this->render('index');
+ }
+
+ function all() {
+ $this->Unit->recursive = 2;
+/* $this->Unit->UnitSize->unbindModel(array('hasMany' => array('Unit'))); */
+/* $this->Unit->UnitSize->UnitType->unbindModel(array('hasMany' => array('UnitSize'))); */
+ //$this->Unit->bindModel(array('hasOne' => array('UnitType')));
+ //function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null) {
+ $this->set('units', $this->paginate(null, null, null, null, null, 2));
+ $this->render('index');
+ }
+
+ function view($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid Item.', true));
+ $this->redirect(array('action'=>''));
+ }
+ $this->Unit->recursive = 4;
+ $this->Unit->UnitSize->unbindModel(array('hasMany' => array('Unit')));
+ $this->Unit->UnitSize->UnitType->unbindModel(array('hasMany' => array('UnitSize')));
+ $this->Unit->Lease->unbindModel(array('belongsTo' => array('Unit')));
+ $this->Unit->Lease->LeaseType->unbindModel(array('hasMany' => array('Lease')));
+ $this->Unit->Lease->Charge->unbindModel(array('belongsTo' => array('Lease')));
+ $this->Unit->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge')));
+ $this->Unit->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt')));
+
+/* //$this->Unit->Lease->unbindModel(array('hasMany' => array('Contact'))); */
+/* $this->Unit->Lease->unbindModel(array('hasAndBelongsToMany' => array('Contact'))); */
+/* //$this->Unit->Lease->unbindModel(array('hasOne' => array('Contact'))); */
+/* //$this->Unit->Lease->unbindModel(array('belongsTo' => array('Contact'))); */
+/* //$this->Unit->Lease->bindModel(array('hasOne' => array('ContactsLease'))); */
+/* //$this->Unit->Lease->bindModel(array('hasOne' => array('Contact'))); */
+/* /\* $this->Unit->Lease->bindModel(array('hasOne' => array('ContactsLease', *\/ */
+/* /\* 'Contact' => array( *\/ */
+/* /\* 'foreignKey' => false, *\/ */
+/* /\* 'conditions' => *\/ */
+/* /\* array('Contact.id = ContactsLease.contact_id', *\/ */
+/* /\* //'ContactsLease.type = "TENANT"' *\/ */
+/* /\* ))))); *\/ */
+
+/* $this->Unit->bindModel(array('hasOne' => array('Lease' => array( */
+/* 'foreignKey' => false, */
+/* 'conditions' => array('Lease.unit_id = Unit.id') */
+/* ), */
+/* 'ContactsLease' => array( */
+/* 'foreignKey' => false, */
+/* 'conditions' => array('ContactsLease.lease_id = Lease.id') */
+/* ), */
+/* 'Contact' => array( */
+/* 'foreignKey' => false, */
+/* 'conditions' => array('Contact.id = ContactsLease.contact_id') */
+/* ))), */
+/* false); */
+
+
+/* $this->Unit->Lease->bindModel(array('hasOne' => array('Contact' => array( */
+/* 'className' => 'ContactsLease', */
+/* 'foreignKey' => false, */
+/* 'conditions' => */
+/* array('ContactsLease.lease_id = Lease.id', */
+/* 'ContactsLease.type = "TENANT"'))))); */
+
+/* # 'hasOne' => array( */
+/* # 'RecipesTag', */
+/* # 'FilterTag' => array( */
+/* # 'className' => 'Tag', */
+/* # 'foreignKey' => false, */
+/* # 'conditions' => array('FilterTag.id = RecipesTag.tag_id') */
+/* # )))); */
+
+ $this->set('unit', $this->Unit->read(null, $id));
+/* $this->Unit->id = $id; */
+/* if ($id !== null && $id !== false) { */
+/* $this->Unit->data = $this->Unit->find('first', */
+/* array('conditions' => array( */
+/* $this->Unit->alias . '.' . $this->Unit->primaryKey => $id, */
+/* 'ContactsLease.type = "TENANT"' */
+/* ) */
+/* )); */
+/* $this->set('unit', $this->Unit->data); */
+/* } */
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/site/models/unit_size.php b/site/models/unit_size.php
index 5bb39f8..29d1a2f 100644
--- a/site/models/unit_size.php
+++ b/site/models/unit_size.php
@@ -13,7 +13,6 @@ class UnitSize extends AppModel {
'amount' => array('money')
);
- //The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'UnitType' => array(
'className' => 'UnitType',
diff --git a/site/models/unit_type.php b/site/models/unit_type.php
index 06f59e4..8488ca0 100644
--- a/site/models/unit_type.php
+++ b/site/models/unit_type.php
@@ -8,7 +8,6 @@ class UnitType extends AppModel {
'name' => array('notempty')
);
- //The Associations below have been created with all possible keys, those that are not needed can be removed
var $hasMany = array(
'UnitSize' => array(
'className' => 'UnitSize',
diff --git a/site/views/contacts/view.ctp b/site/views/contacts/view.ctp
index 18d6021..5d6e968 100644
--- a/site/views/contacts/view.ctp
+++ b/site/views/contacts/view.ctp
@@ -6,22 +6,145 @@
$val) {
- $rows[] = array(array($col, 'width=1%'), $val);
+function phone($phone) {
+ $phone = preg_replace("/\D/", "", $phone);
+ if(strlen($phone) == 7)
+ return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
+ elseif(strlen($phone) == 10)
+ return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
+ else
+ return $phone;
}
+
+function datefmt($date) {
+ $date_fmt = 'm/d/Y';
+ return ($date
+ ? date_format(date_create($date), $date_fmt)
+ : null);
+}
+
+/**********************************************************************
+ * Tenant Info
+ */
echo('' . "\n");
echo(' Tenant Info' . "\n");
-echo $html->tableCells($rows, null, array('class' => "altrow"));
+echo $html->tableCells(array(array('Name', $tenant['Contact']['display_name']),
+ array('Company', $tenant['Contact']['company_name']),
+ array('SSN', $tenant['Contact']['id_federal']),
+ array('ID', $tenant['Contact']['id_num']
+ . ($tenant['Contact']['id_state']
+ ? " - ".$tenant['Contact']['id_state']
+ : "")),
+ array('Comment', $tenant['Contact']['comment'])),
+ null, array('class' => "altrow"), false, false);
echo('
' . "\n");
+
+/**********************************************************************
+ * Phones
+ */
+$headers = array('Location', 'Preference', 'Type', 'Phone', 'Extension', 'Comment');
+$rows = array();
+foreach($tenant['ContactPhone'] AS $phone) {
+ $rows[] = array($phone['ContactsMethod']['type'],
+ $phone['ContactsMethod']['preference'],
+ $phone['type'],
+ phone($phone['phone']),
+ $phone['ext'],
+ $phone['comment']);
+}
+
+if (count($rows)) {
+ echo('' . "\n");
+ echo(' Phone' . "\n");
+ echo $html->tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ echo('
' . "\n");
+}
+
+
+/**********************************************************************
+ * Emails
+ */
+$headers = array('Location', 'Preference', 'Email', 'Comment');
+$rows = array();
+foreach($tenant['ContactEmail'] AS $email) {
+ $rows[] = array($email['ContactsMethod']['type'],
+ $email['ContactsMethod']['preference'],
+ $email['email'],
+ $email['comment']);
+}
+
+if (count($rows)) {
+ echo('' . "\n");
+ echo(' Email' . "\n");
+ echo $html->tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ echo('
' . "\n");
+}
+
+
+/**********************************************************************
+ * Addresses
+ */
+$headers = array('Location', 'Preference', 'Address', 'City', 'State', 'Zip', 'Country', 'Comment');
+$rows = array();
+foreach($tenant['ContactAddress'] AS $address) {
+ $rows[] = array($address['ContactsMethod']['type'],
+ $address['ContactsMethod']['preference'],
+ $address['address'],
+ $address['city'],
+ $address['state'],
+ $address['postcode'],
+ $address['country'],
+ $address['comment']);
+}
+
+if (count($rows)) {
+ echo('' . "\n");
+ echo(' Address' . "\n");
+ echo $html->tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ echo('
' . "\n");
+}
+
+
+/**********************************************************************
+ * Lease History
+ */
+$headers = array('Lease', 'Unit', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
+$rows = array();
+foreach($tenant['Lease'] AS $lease) {
+ $rows[] = array('#'.$lease['id'],
+ $html->link($lease['Unit']['name'],
+ array('controller' => 'units',
+ 'action' => 'view',
+ $lease['Unit']['id'])),
+ datefmt($lease['lease_date']),
+ datefmt($lease['movein_date']),
+ datefmt($lease['moveout_date']),
+ $lease['amount'],
+ $lease['deposit'],
+ $lease['comment']);
+}
+
+echo('' . "\n");
+echo(' Lease History' . "\n");
+echo $html->tableHeaders($headers);
+echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+echo('
' . "\n");
+
+
+/**********************************************************************
+ * Ledger History
+ */
+$security_deposit = 0;
$grand_total = 0;
foreach($tenant['Lease'] AS $lease) {
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
@@ -31,8 +154,7 @@ foreach($tenant['Lease'] AS $lease) {
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
- $rows[] = array(date_format(date_create($charge['charge_date']), 'm-d-Y') . ' - ' .
- date_format(date_create($charge['charge_to_date']), 'm-d-Y'),
+ $rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
'#'.$charge['id'],
$charge['ChargeType']['name'],
$charge['comment'],
@@ -42,10 +164,13 @@ foreach($tenant['Lease'] AS $lease) {
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
- $rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), 'm-d-Y'),
- //null,
+ // REVISIT 20090527:
+ // Using hardcoded value for security deposit... can't be good!
+ if ($charge['charge_type_id'] == 1)
+ $security_deposit += $receipt['ChargesReceipt']['amount'];
+ $rows[] = array(' -- ' . datefmt($receipt['stamp']),
'#'.$receipt['id'],
- 'Receipt',
+ 'Payment/Receipt',
$receipt['comment'],
currency($amount),
currency($running_total));
@@ -54,13 +179,14 @@ foreach($tenant['Lease'] AS $lease) {
$grand_total += $running_total;
echo('' . "\n");
- echo(' Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')' . "\n");
+ echo(' Lease #'.$lease['number'].' ('.$lease['Unit']['name'].')' . "\n");
echo $html->tableHeaders($headers);
- echo $html->tableCells($rows, null, array('class' => "altrow"));
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
echo('
' . "\n");
}
?>
-Grand Total:
+Total Security Deposit:
+Outstanding Balance:
diff --git a/site/views/elements/units.ctp b/site/views/elements/units.ctp
new file mode 100644
index 0000000..ca3b714
--- /dev/null
+++ b/site/views/elements/units.ctp
@@ -0,0 +1,59 @@
+
+
+
+'.__('Units',true).'';
+?>
+
+
+
+
+ counter(array(
+ 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
+
+ $rows = array($paginator->sort('id'),
+ $paginator->sort('name'),
+ $paginator->sort('unit_size_id'),
+ $paginator->sort('status'),
+ $paginator->sort('comment'));
+ } else {
+ $rows = array('Id', 'Name', 'Size', 'Status', 'Comment');
+ }
+ echo $html->tableHeaders($rows);
+
+ $rows = array();
+ foreach ($units as $unit) {
+ $rows[] = array($html->link($unit['Unit']['id'],
+ array('controller' => 'units',
+ 'action' => 'view',
+ $unit['Unit']['id'])),
+ $html->link($unit['Unit']['name'],
+ array('controller' => 'units',
+ 'action' => 'view',
+ $unit['Unit']['id'])),
+ $unit['UnitSize']['name'],
+ $unit['Unit']['status'],
+ $unit['Unit']['comment']);
+ }
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ }
+?>
+
+
+' . "\n");
+ echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
+ echo(' | ');
+ echo $paginator->numbers();
+ echo(' | ');
+ echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
+ echo('' . "\n");
+ }
+?>
diff --git a/site/views/units/index.ctp b/site/views/units/index.ctp
new file mode 100644
index 0000000..df3021c
--- /dev/null
+++ b/site/views/units/index.ctp
@@ -0,0 +1,3 @@
+
+element('units') ?>
+
diff --git a/site/views/units/view.ctp b/site/views/units/view.ctp
new file mode 100644
index 0000000..6e2c113
--- /dev/null
+++ b/site/views/units/view.ctp
@@ -0,0 +1,113 @@
+
+
+
+
+
+ $val) {
+ $rows[] = array(array($col, 'width=1%'), $val);
+}
+
+echo('
' . "\n");
+echo(' Unit Info' . "\n");
+echo $html->tableCells(array(array('Name', $unit['Unit']['name']),
+ array('Status', $unit['Unit']['status']),
+ array('Comment', $unit['Unit']['comment'])),
+ null, array('class' => "altrow"), false, false);
+echo('
' . "\n");
+
+
+/**********************************************************************
+ * Lease History
+ */
+$headers = array('Lease', 'Tenant', 'Signed', 'Move-In', 'Move-Out', 'Rent', 'Deposit', 'Comment');
+$rows = array();
+foreach($unit['Lease'] AS $lease) {
+ $rows[] = array('#'.$lease['id'],
+ $html->link($lease['Contact'][0]['display_name'],
+ array('controller' => 'contacts',
+ 'action' => 'view',
+ $lease['Contact'][0]['id'])),
+ datefmt($lease['lease_date']),
+ datefmt($lease['movein_date']),
+ datefmt($lease['moveout_date']),
+ $lease['amount'],
+ $lease['deposit'],
+ $lease['comment']);
+}
+
+echo('
' . "\n");
+echo(' Lease History' . "\n");
+echo $html->tableHeaders($headers);
+echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+echo('
' . "\n");
+
+
+/**********************************************************************
+ * Ledger History
+ */
+$security_deposit = 0;
+$grand_total = 0;
+foreach($unit['Lease'] AS $lease) {
+ $headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
+
+ $rows = array();
+ $running_total = 0;
+ foreach($lease['Charge'] AS $charge) {
+ $amount = $charge['total'];
+ $running_total += $amount;
+ $rows[] = array(datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
+ '#'.$charge['id'],
+ $charge['ChargeType']['name'],
+ $charge['comment'],
+ currency($amount),
+ currency($running_total));
+
+ foreach ($charge['Receipt'] AS $receipt) {
+ $amount = -1 * $receipt['ChargesReceipt']['amount'];
+ $running_total += $amount;
+ // REVISIT
20090527:
+ // Using hardcoded value for security deposit... can't be good!
+ if ($charge['charge_type_id'] == 1)
+ $security_deposit += $receipt['ChargesReceipt']['amount'];
+ $rows[] = array(' -- ' . datefmt($receipt['stamp']),
+ '#'.$receipt['id'],
+ 'Payment/Receipt',
+ $receipt['comment'],
+ currency($amount),
+ currency($running_total));
+ }
+ }
+ $grand_total += $running_total;
+
+ echo('' . "\n");
+ echo(' Lease #'.$lease['number'].' ('.$lease['Contact'][0]['display_name'].')' . "\n");
+ echo $html->tableHeaders($headers);
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ echo('
' . "\n");
+
+}
+?>
+
+Total Security Deposit:
+Outstanding Balance:
+
From dbe037fee8d978d65c53f33fb81e09e317c48dc9 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 21:52:14 +0000
Subject: [PATCH 028/717] Added support for querying only occupied or vacant
units. It's working at the moment, but I'll probably move some more logic to
the controller next.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@29 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/app_model.php | 39 ++++++++++++++++++++++++++-
site/controllers/units_controller.php | 20 ++------------
site/models/unit.php | 5 +++-
site/views/elements/units.ctp | 4 +--
4 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/site/app_model.php b/site/app_model.php
index 7d083b0..a4e1079 100644
--- a/site/app_model.php
+++ b/site/app_model.php
@@ -37,5 +37,42 @@
* @subpackage cake.app
*/
class AppModel extends Model {
+
+
+ /**
+ * Get Enum Values
+ * Snippet v0.1.3
+ * http://cakeforge.org/snippet/detail.php?type=snippet&id=112
+ *
+ * Gets the enum values for MySQL 4 and 5 to use in selectTag()
+ */
+ function getEnumValues($columnName=null, $respectDefault=false)
+ {
+ if ($columnName==null) { return array(); } //no field specified
+
+ //Get the name of the table
+ $db =& ConnectionManager::getDataSource($this->useDbConfig);
+ $tableName = $db->fullTableName($this, false);
+
+ //Get the values for the specified column (database and version specific, needs testing)
+ $result = $this->query("SHOW COLUMNS FROM {$tableName} LIKE '{$columnName}'");
+
+ //figure out where in the result our Types are (this varies between mysql versions)
+ $types = null;
+ if ( isset( $result[0]['COLUMNS']['Type'] ) ) { //MySQL 5
+ $types = $result[0]['COLUMNS']['Type']; $default = $result[0]['COLUMNS']['Default'];
+ }
+ elseif ( isset( $result[0][0]['Type'] ) ) { //MySQL 4
+ $types = $result[0][0]['Type']; $default = $result[0][0]['Default'];
+ }
+ else { //types return not accounted for
+ return array();
+ }
+
+ //Get the values
+ return array_flip(array_merge(array(''), // MySQL sets 0 to be the empty string
+ explode("','", preg_replace("/(enum)\('(.+?)'\)/","\\2", $types))
+ ));
+ } //end getEnumValues
+
}
-?>
\ No newline at end of file
diff --git a/site/controllers/units_controller.php b/site/controllers/units_controller.php
index fe21434..e6569b3 100644
--- a/site/controllers/units_controller.php
+++ b/site/controllers/units_controller.php
@@ -12,29 +12,13 @@ class UnitsController extends AppController {
function vacant() {
$this->Unit->recursive = 0;
- $this->Unit->bindModel(array('hasOne' => array('UnitsLease',
- 'Lease' => array(
- 'foreignKey' => false,
- 'conditions' => array('Lease.id = UnitsLease.lease_id')
- ))),
- false);
-
- $this->set('units', $this->paginate(array('Lease.close_date IS NULL',
- 'UnitsLease.type != "ALTERNATE"')));
+ $this->set('units', $this->paginate(array('Unit.status < ' . $this->Unit->occupiedEnumValue())));
$this->render('index');
}
function occupied() {
$this->Unit->recursive = 0;
- $this->Unit->bindModel(array('hasOne' => array('UnitsLease',
- 'Lease' => array(
- 'foreignKey' => false,
- 'conditions' => array('Lease.id = UnitsLease.lease_id')
- ))),
- false);
-
- $this->set('units', $this->paginate(array('Lease.close_date IS NULL',
- 'UnitsLease.type != "ALTERNATE"')));
+ $this->set('units', $this->paginate(array('Unit.status >= ' . $this->Unit->occupiedEnumValue())));
$this->render('index');
}
diff --git a/site/models/unit.php b/site/models/unit.php
index 643065a..72c1af9 100644
--- a/site/models/unit.php
+++ b/site/models/unit.php
@@ -45,5 +45,8 @@ class Unit extends AppModel {
)
);
+ function occupiedEnumValue() {
+ $enums = $this->getEnumValues('status');
+ return $enums['OCCUPIED'];
+ }
}
-?>
\ No newline at end of file
diff --git a/site/views/elements/units.ctp b/site/views/elements/units.ctp
index ca3b714..ee19ea9 100644
--- a/site/views/elements/units.ctp
+++ b/site/views/elements/units.ctp
@@ -18,12 +18,12 @@
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$rows = array($paginator->sort('id'),
- $paginator->sort('name'),
+ $paginator->sort('Unit', 'name'),
$paginator->sort('unit_size_id'),
$paginator->sort('status'),
$paginator->sort('comment'));
} else {
- $rows = array('Id', 'Name', 'Size', 'Status', 'Comment');
+ $rows = array('Id', 'Unit', 'Size', 'Status', 'Comment');
}
echo $html->tableHeaders($rows);
From 15930fae30f329a863f37f2b946de5ca82bda664 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 22:09:04 +0000
Subject: [PATCH 029/717] Moved the unit status logic into the model where it
belongs.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@30 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/units_controller.php | 10 ++++++--
site/models/unit.php | 33 ++++++++++++++++++++++++---
2 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/site/controllers/units_controller.php b/site/controllers/units_controller.php
index e6569b3..6e0e931 100644
--- a/site/controllers/units_controller.php
+++ b/site/controllers/units_controller.php
@@ -10,15 +10,21 @@ class UnitsController extends AppController {
$this->all();
}
+ function unavailable() {
+ $this->Unit->recursive = 0;
+ $this->set('units', $this->paginate(array($this->Unit->conditionUnavailable())));
+ $this->render('index');
+ }
+
function vacant() {
$this->Unit->recursive = 0;
- $this->set('units', $this->paginate(array('Unit.status < ' . $this->Unit->occupiedEnumValue())));
+ $this->set('units', $this->paginate(array($this->Unit->conditionVacant())));
$this->render('index');
}
function occupied() {
$this->Unit->recursive = 0;
- $this->set('units', $this->paginate(array('Unit.status >= ' . $this->Unit->occupiedEnumValue())));
+ $this->set('units', $this->paginate(array($this->Unit->conditionOccupied())));
$this->render('index');
}
diff --git a/site/models/unit.php b/site/models/unit.php
index 72c1af9..fb0b173 100644
--- a/site/models/unit.php
+++ b/site/models/unit.php
@@ -45,8 +45,35 @@ class Unit extends AppModel {
)
);
- function occupiedEnumValue() {
- $enums = $this->getEnumValues('status');
- return $enums['OCCUPIED'];
+ function statusEnums() {
+ static $status_enums;
+ if (!isset($status_enums))
+ $status_enums = $this->getEnumValues('status');
+ return $status_enums;
}
+
+ function statusValue($enum) {
+ $enums = $this->statusEnums();
+ return $enums[$enum];
+ }
+
+ function occupiedEnumValue() {
+ return statusValue('OCCUPIED');
+ }
+
+ function conditionOccupied() {
+ return ('Unit.status >= ' . $this->statusValue('OCCUPIED'));
+ }
+
+ function conditionVacant() {
+ return ('Unit.status BETWEEN ' .
+ ($this->statusValue('UNAVAILABLE')+1) .
+ ' AND ' .
+ ($this->statusValue('OCCUPIED')-1));
+ }
+
+ function conditionUnavailable() {
+ return ('Unit.status <= ' . $this->statusValue('UNAVAILABLE'));
+ }
+
}
From 3cc8e95ff49015e92c1bc3548407734e02d86f93 Mon Sep 17 00:00:00 2001
From: abijah
Date: Thu, 28 May 2009 23:18:20 +0000
Subject: [PATCH 030/717] Added a name for our lone map
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@31 97e9348a-65ac-dc4b-aefc-98561f571b83
---
scripts/sitelink2pmgr.pl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl
index 63ef777..ea0db31 100644
--- a/scripts/sitelink2pmgr.pl
+++ b/scripts/sitelink2pmgr.pl
@@ -376,8 +376,8 @@ $info{'extents'}{'bottom'} = $internal_adjustment_factor * ($top_adjustment + $
$info{'extents'}{'right'} = $internal_adjustment_factor * ($left_adjustment + $row->{'rgt'} + 0);
$query =
- "INSERT INTO pmgr_maps (id, site_area_id, width, depth) VALUES\n" .
- " (1, $aicur_area_id," .
+ "INSERT INTO pmgr_maps (id, name, site_area_id, width, depth) VALUES\n" .
+ " (1, 'Main Facility Map', $aicur_area_id," .
($info{'extents'}{'right'} - $info{'extents'}{'left'}) . ", " .
($info{'extents'}{'bottom'} - $info{'extents'}{'top'}) . ")";
query($db_handle, $query) || die("Unable to insert");
From 9fc5562dd82ca2ceb6603b72aa579e5b7421267f Mon Sep 17 00:00:00 2001
From: abijah
Date: Fri, 29 May 2009 01:47:12 +0000
Subject: [PATCH 031/717] Adding mapping ability. Incomplete as of yet, but
coming along nicely.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@32 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/maps_controller.php | 308 +++++++++++++++++++++++++++
site/views/elements/maps.ctp | 61 ++++++
site/views/maps/image.ctp | 95 +++++++++
site/views/maps/index.ctp | 3 +
site/views/maps/view.ctp | 25 +++
5 files changed, 492 insertions(+)
create mode 100644 site/controllers/maps_controller.php
create mode 100644 site/views/elements/maps.ctp
create mode 100644 site/views/maps/image.ctp
create mode 100644 site/views/maps/index.ctp
create mode 100644 site/views/maps/view.ctp
diff --git a/site/controllers/maps_controller.php b/site/controllers/maps_controller.php
new file mode 100644
index 0000000..fe97ee7
--- /dev/null
+++ b/site/controllers/maps_controller.php
@@ -0,0 +1,308 @@
+Map->recursive = 0;
+/* $this->Map->MapSize->unbindModel(array('hasMany' => array('Map'))); */
+/* $this->Map->MapSize->MapType->unbindModel(array('hasMany' => array('MapSize'))); */
+ //$this->Map->bindModel(array('hasOne' => array('MapType')));
+ //function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null) {
+ $this->set('maps', $this->paginate(null, null, null, null, null, 0));
+ }
+
+ function view($id = null) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid Item.', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ $this->Map->recursive = 0;
+ $this->set('map', $this->Map->read(null, $id));
+
+/* $this->Map->MapSize->unbindModel(array('hasMany' => array('Map'))); */
+/* $this->Map->MapSize->MapType->unbindModel(array('hasMany' => array('MapSize'))); */
+/* $this->Map->Lease->unbindModel(array('belongsTo' => array('Map'))); */
+/* $this->Map->Lease->LeaseType->unbindModel(array('hasMany' => array('Lease'))); */
+/* $this->Map->Lease->Charge->unbindModel(array('belongsTo' => array('Lease'))); */
+/* $this->Map->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge'))); */
+/* $this->Map->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt'))); */
+
+/* //$this->Map->Lease->unbindModel(array('hasMany' => array('Contact'))); */
+/* $this->Map->Lease->unbindModel(array('hasAndBelongsToMany' => array('Contact'))); */
+/* //$this->Map->Lease->unbindModel(array('hasOne' => array('Contact'))); */
+/* //$this->Map->Lease->unbindModel(array('belongsTo' => array('Contact'))); */
+/* //$this->Map->Lease->bindModel(array('hasOne' => array('ContactsLease'))); */
+/* //$this->Map->Lease->bindModel(array('hasOne' => array('Contact'))); */
+/* /\* $this->Map->Lease->bindModel(array('hasOne' => array('ContactsLease', *\/ */
+/* /\* 'Contact' => array( *\/ */
+/* /\* 'foreignKey' => false, *\/ */
+/* /\* 'conditions' => *\/ */
+/* /\* array('Contact.id = ContactsLease.contact_id', *\/ */
+/* /\* //'ContactsLease.type = "TENANT"' *\/ */
+/* /\* ))))); *\/ */
+
+/* $this->Map->bindModel(array('hasOne' => array('Lease' => array( */
+/* 'foreignKey' => false, */
+/* 'conditions' => array('Lease.map_id = Map.id') */
+/* ), */
+/* 'ContactsLease' => array( */
+/* 'foreignKey' => false, */
+/* 'conditions' => array('ContactsLease.lease_id = Lease.id') */
+/* ), */
+/* 'Contact' => array( */
+/* 'foreignKey' => false, */
+/* 'conditions' => array('Contact.id = ContactsLease.contact_id') */
+/* ))), */
+/* false); */
+
+
+/* $this->Map->Lease->bindModel(array('hasOne' => array('Contact' => array( */
+/* 'className' => 'ContactsLease', */
+/* 'foreignKey' => false, */
+/* 'conditions' => */
+/* array('ContactsLease.lease_id = Lease.id', */
+/* 'ContactsLease.type = "TENANT"'))))); */
+
+/* # 'hasOne' => array( */
+/* # 'RecipesTag', */
+/* # 'FilterTag' => array( */
+/* # 'className' => 'Tag', */
+/* # 'foreignKey' => false, */
+/* # 'conditions' => array('FilterTag.id = RecipesTag.tag_id') */
+/* # )))); */
+
+/* $this->Map->id = $id; */
+/* if ($id !== null && $id !== false) { */
+/* $this->Map->data = $this->Map->find('first', */
+/* array('conditions' => array( */
+/* $this->Map->alias . '.' . $this->Map->primaryKey => $id, */
+/* 'ContactsLease.type = "TENANT"' */
+/* ) */
+/* )); */
+/* $this->set('map', $this->Map->data); */
+/* } */
+ }
+
+
+ // Temporary function
+ function unitStatusList() {
+ return
+ array('DELETED' => array(),
+ 'DAMAGED' => array(),
+ 'COMPANY' => array(),
+ 'UNAVAILABLE' => array(),
+ 'RESERVED' => array(),
+ 'DIRTY' => array(),
+ 'VACANT' => array(),
+ 'OCCUPIED' => array(),
+ 'LATE' => array(),
+ 'LOCKED' => array(),
+ 'LIENED' => array(),
+ );
+ }
+
+ function map($id = null, $requested_width = 600) {
+ $info = $this->mapInfo($id);
+ $info['border'] = true;
+ $info['clickable'] = true;
+ $this->image($info, $requested_width);
+ }
+
+ function legend($id = null, $requested_width = 400) {
+ $status = $this->unitStatusList();
+ $cols = 6;
+ $rows = (int)((count($status) + $cols - 1) / $cols);
+
+ $info = array('extents' => array(), 'units' => array(), 'legend' => array());
+ $info['legend']['width'] = 360;
+ $info['legend']['depth'] = 120;
+
+ $info['extents']['right'] = $info['legend']['width'] * $cols;
+ $info['extents']['bottom'] = $info['legend']['depth'] * $rows;
+
+ $top = $lft = 0;
+ foreach ($status AS $code => $color) {
+ $info['units'][] = array('name' => $code,
+ 'status' => $code,
+ 'width' => $info['legend']['width'],
+ 'depth' => $info['legend']['depth'],
+ 'left' => $lft,
+ 'right' => $lft + $info['legend']['width'],
+ 'top' => $top,
+ 'bottom' => $top + $info['legend']['depth']);
+ $top += $info['legend']['depth'];
+ if ($top >= $info['legend']['depth'] * $rows) {
+ $top = 0; $lft += $info['legend']['width'];
+ }
+ }
+
+ $this->image($info, $requested_width, true);
+ }
+
+ function image($info, $requested_width, $legend = false) {
+ //var $helpers = array('Html', 'Form', 'Javascript', 'Graph');
+ $this->layout = null;
+ $this->autoLayout = false;
+ Configure::write('debug', '0');
+
+ // Define our color palate
+ // REVISIT : 20090513
+ // Get colors from DB option tables
+ $info['palate']['main']['layout']['bg'] = array('red' => 255, 'green' => 255, 'blue' => 255);
+ $info['palate']['main']['layout']['border'] = array('red' => 192, 'green' => 192, 'blue' => 192);
+ $info['palate']['main']['layout']['wall'] = array('red' => 0, 'green' => 0, 'blue' => 0);
+ $info['palate']['unit']['DELETED']['bg'] = array('red' => 0, 'green' => 0, 'blue' => 0);
+ $info['palate']['unit']['DAMAGED']['bg'] = array('red' => 192, 'green' => 128, 'blue' => 128);
+ $info['palate']['unit']['COMPANY']['bg'] = array('red' => 128, 'green' => 192, 'blue' => 128);
+ $info['palate']['unit']['UNAVAILABLE']['bg'] = array('red' => 128, 'green' => 128, 'blue' => 192);
+ $info['palate']['unit']['RESERVED']['bg'] = array('red' => 192, 'green' => 192, 'blue' => 128);
+ $info['palate']['unit']['DIRTY']['bg'] = array('red' => 128, 'green' => 192, 'blue' => 192);
+ $info['palate']['unit']['VACANT']['bg'] = array('red' => 0, 'green' => 255, 'blue' => 128);
+ $info['palate']['unit']['OCCUPIED']['bg'] = array('red' => 0, 'green' => 128, 'blue' => 255);
+ $info['palate']['unit']['LATE']['bg'] = array('red' => 255, 'green' => 64, 'blue' => 64);
+ $info['palate']['unit']['LOCKED']['bg'] = array('red' => 255, 'green' => 128, 'blue' => 128);
+ $info['palate']['unit']['LIENED']['bg'] = array('red' => 255, 'green' => 192, 'blue' => 192);
+
+ // Determine text color to go with each background
+ foreach ($info['palate']['unit'] AS &$code) {
+ $component = $code['bg'];
+ $method = 3;
+ if ($method == 1) {
+ foreach (array('red', 'green', 'blue') AS $prim)
+ $component[$prim] = 255 - $component[$prim];
+ } elseif ($method == 2) {
+ foreach (array('red', 'green', 'blue') AS $prim)
+ $component[$prim] = ($component[$prim]) >= 128 ? 0 : 255;
+ } elseif ($method == 3) {
+ $val = (sqrt(pow($component['red'], 2) +
+ pow($component['green'], 2) +
+ pow($component['blue'], 2)) >= sqrt(3) * 128) ? 0 : 255;
+ foreach (array('red', 'green', 'blue') AS $prim)
+ $component[$prim] = $val;
+ }
+
+ $code['fg'] = $component;
+ }
+
+ //pr($info);
+
+ /*****
+ * The preference would be to leave all things "screen" related
+ * to reside in the view. However, two separate views need this
+ * information. The 'view' needs it to include a clickable map
+ * that corresponds to the map image, and of course, the 'map'
+ * (or 'image') view needs it to render the image. So, in the
+ * controller for now, unless I come up with a better idea.
+ *****/
+
+ // Scale things according to desired display width
+ $screen_adjustment_factor = $requested_width / $info['extents']['right'];;
+
+ // Define image size
+ $info['width'] = $info['extents']['right'] * $screen_adjustment_factor;
+ $info['depth'] = $info['extents']['bottom'] * $screen_adjustment_factor;
+
+ // Go through each unit, adjusting map locations
+ foreach ($info['units'] AS $unit) {
+ $unit['left'] *= $screen_adjustment_factor;
+ $unit['right'] *= $screen_adjustment_factor;
+ $unit['top'] *= $screen_adjustment_factor;
+ $unit['bottom'] *= $screen_adjustment_factor;
+ }
+
+ $this->set(compact('info'));
+ $this->render('image');
+ }
+
+
+
+ /**************************************************************************
+ **************************************************************************
+ **************************************************************************
+ * mapInfo
+ */
+
+ function mapInfo($site_area_id) {
+ // Set up array to hold the map information
+ $info = array('extents' => array(), 'units' => array());
+
+ $map = $this->Map->SiteArea->read(null, $site_area_id);
+ //pr($map);
+
+ $top_adjustment = 5;
+ $left_adjustment = 5;
+ $info['extents']['top'] = 0;
+ $info['extents']['left'] = 0;
+ $info['extents']['bottom'] = $top_adjustment + $map['Map']['depth'] + 5;
+ $info['extents']['right'] = $left_adjustment + $map['Map']['width'] + 5;
+ return $info;
+
+ // Get the overall site limits
+ $query = "SELECT M.id, M.width, M.depth";
+ $query .= " FROM pmgr_maps M";
+ $query .= " WHERE site_area_id = $site_area_id";
+ $result = $this->Map->query($query);
+
+ //pr($result);
+ $info['extents']['top'] = 0;
+ $info['extents']['left'] = 0;
+ $info['extents']['bottom'] = 360;
+ $info['extents']['right'] = 480;
+ $info['map_id'] = 1;
+ return $info;
+
+ /* // Fetch and verify the result */
+ /* $row = mysql_fetch_array($result); */
+ /* if (!$row) die("Site map query failed!"); */
+ /* mysql_free_result($result); */
+
+ /* // Compute the actual boundaries, adjusting for a border */
+ /* $top_adjustment = 5; */
+ /* $left_adjustment = 5; */
+ /* $info['extents']['top'] = 0; */
+ /* $info['extents']['left'] = 0; */
+ /* $info['extents']['bottom'] = $top_adjustment + $row['depth'] + 5; */
+ /* $info['extents']['right'] = $left_adjustment + $row['width'] + 5; */
+ /* $info['map_id'] = $row['id']; */
+
+ /* // Get list of units and positions */
+ /* $query = "SELECT U.id, U.name, U.status,"; */
+ /* $query .= " ($top_adjustment + Mu.pt_top) AS pt_top,"; */
+ /* $query .= " ($left_adjustment + Mu.pt_left) AS pt_left,"; */
+ /* //$query .= " ($top_adjustment + Mu.pt_bottom) AS pt_bottom,"; */
+ /* //$query .= " ($left_adjustment + Mu.pt_right) AS pt_right,"; */
+ /* $query .= " IF(Mu.transpose, S.depth, S.width) AS width,"; */
+ /* $query .= " IF(Mu.transpose, S.width, S.depth) AS depth"; */
+ /* //$query .= " Mu.transpose"; */
+ /* $query .= " FROM pmgr_maps_units Mu"; */
+ /* $query .= " JOIN pmgr_units U ON U.id = Mu.unit_id"; */
+ /* $query .= " JOIN pmgr_unit_sizes S ON S.id = U.size_id"; */
+ /* $query .= " WHERE Mu.map_id = $info[map_id]"; */
+ /* $result = sql_query($query); */
+
+ /* // Go through each one, calculating the map location */
+ /* while ($row = mysql_fetch_array($result)) { */
+ /* $info['units'][$row['id']] = */
+ /* array( 'id' => $row['id'], */
+ /* 'name' => $row['name'], */
+ /* 'left' => $row['pt_left'], */
+ /* 'right' => $row['pt_left'] + $row['width'], */
+ /* 'top' => $row['pt_top'], */
+ /* 'bottom' => $row['pt_top'] + $row['depth'], */
+ /* 'width' => $row['width'], */
+ /* 'depth' => $row['depth'], */
+ /* 'n-s' => $row['reverseWL'], */
+ /* 'status' => $row['status'] */
+ /* ); */
+ /* } */
+
+ /* // Free the result */
+ /* mysql_free_result($result); */
+
+ /* return $info; */
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/site/views/elements/maps.ctp b/site/views/elements/maps.ctp
new file mode 100644
index 0000000..a62fcaa
--- /dev/null
+++ b/site/views/elements/maps.ctp
@@ -0,0 +1,61 @@
+
+
+
+'.__('Maps',true).'';
+?>
+
+
+
+
+ counter(array(
+ 'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
+
+ $rows = array($paginator->sort('id'),
+ $paginator->sort('name'),
+ $paginator->sort('site_area_id'),
+ $paginator->sort('width'),
+ $paginator->sort('depth'),
+ $paginator->sort('comment'));
+ } else {
+ $rows = array('Id', 'Name', 'Area', 'Width', 'Depth', 'Comment');
+ }
+ echo $html->tableHeaders($rows);
+
+ $rows = array();
+ foreach ($maps as $map) {
+ $rows[] = array($html->link($map['Map']['id'],
+ array('controller' => 'maps',
+ 'action' => 'view',
+ $map['Map']['id'])),
+ $html->link($map['Map']['name'],
+ array('controller' => 'maps',
+ 'action' => 'view',
+ $map['Map']['id'])),
+ $map['SiteArea']['name'],
+ $map['Map']['width'] / 12,
+ $map['Map']['depth'] / 12,
+ $map['Map']['comment']);
+ }
+ echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
+ }
+?>
+
+
+' . "\n");
+ echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
+ echo(' | ');
+ echo $paginator->numbers();
+ echo(' | ');
+ echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
+ echo('' . "\n");
+ }
+?>
diff --git a/site/views/maps/image.ctp b/site/views/maps/image.ctp
new file mode 100644
index 0000000..0d910b2
--- /dev/null
+++ b/site/views/maps/image.ctp
@@ -0,0 +1,95 @@
+ 100) {
+ imagestring($image, 1,
+ $unit['left']+3, $unit['top']+3,
+ $unit['name'],
+ $info['palate']['unit'][$unit['status']]['fg']['color']);
+ }
+ else {
+ imagestringup($image, 1,
+ $unit['left']+3, $unit['bottom']-3,
+ $unit['name'],
+ $info['palate']['unit'][$unit['status']]['fg']['color']);
+ }
+
+}
+
+
+header("Content-type: image/png");
+if (! imagepng($image)) {
+ die("Couldn't output image!");
+}
+
+// Clear image from memory
+imagedestroy($image);
+
+// Closing PHP tag intentionally omitted
diff --git a/site/views/maps/index.ctp b/site/views/maps/index.ctp
new file mode 100644
index 0000000..8660dda
--- /dev/null
+++ b/site/views/maps/index.ctp
@@ -0,0 +1,3 @@
+
+element('maps') ?>
+
diff --git a/site/views/maps/view.ctp b/site/views/maps/view.ctp
new file mode 100644
index 0000000..bc90c4a
--- /dev/null
+++ b/site/views/maps/view.ctp
@@ -0,0 +1,25 @@
+
+
+
+image(array('controller' => 'maps',
+ 'action' => 'map',
+ $map['Map']['id']),
+ array('alt' => 'Site Map',
+ 'class' => 'imagemap',
+ 'usemap' => '#mapimg'));
+?>
+
+
+
+image(array('controller' => 'maps',
+ 'action' => 'legend',
+ $map['Map']['id']),
+ array('alt' => 'Site Map Legend'));
+ */
+?>
+
+
+
From 4e33c582466f6ea4eab47c13f8a0cb45cdfc2bd8 Mon Sep 17 00:00:00 2001
From: abijah
Date: Fri, 29 May 2009 02:45:23 +0000
Subject: [PATCH 032/717] Further progress on the site map. The scale is off
at the moment, but it's working well enough that it's worth a snapshot.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@33 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/maps_controller.php | 275 +++++++++++----------------
site/views/maps/view.ctp | 4 +-
2 files changed, 116 insertions(+), 163 deletions(-)
diff --git a/site/controllers/maps_controller.php b/site/controllers/maps_controller.php
index fe97ee7..088c8cf 100644
--- a/site/controllers/maps_controller.php
+++ b/site/controllers/maps_controller.php
@@ -3,88 +3,118 @@
class MapsController extends AppController {
var $helpers = array('Html');
+ /**************************************************************************
+ **************************************************************************
+ **************************************************************************
+ * action: index
+ * - Generates a list of all site maps
+ *
+ * REVISIT 20090528:
+ * We'll need to present only those site area maps that correspond
+ * to the users particular site.
+ */
+
function index() {
$this->Map->recursive = 0;
-/* $this->Map->MapSize->unbindModel(array('hasMany' => array('Map'))); */
-/* $this->Map->MapSize->MapType->unbindModel(array('hasMany' => array('MapSize'))); */
- //$this->Map->bindModel(array('hasOne' => array('MapType')));
- //function paginate($conditions, $fields, $order, $limit, $page = 1, $recursive = null) {
- $this->set('maps', $this->paginate(null, null, null, null, null, 0));
+ $this->set('maps', $this->paginate());
}
+ /**************************************************************************
+ **************************************************************************
+ **************************************************************************
+ * action: view
+ * - Generates a site map page
+ */
+
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index'));
}
- $this->Map->recursive = 0;
- $this->set('map', $this->Map->read(null, $id));
-
-/* $this->Map->MapSize->unbindModel(array('hasMany' => array('Map'))); */
-/* $this->Map->MapSize->MapType->unbindModel(array('hasMany' => array('MapSize'))); */
-/* $this->Map->Lease->unbindModel(array('belongsTo' => array('Map'))); */
-/* $this->Map->Lease->LeaseType->unbindModel(array('hasMany' => array('Lease'))); */
-/* $this->Map->Lease->Charge->unbindModel(array('belongsTo' => array('Lease'))); */
-/* $this->Map->Lease->Charge->ChargeType->unbindModel(array('hasMany' => array('Charge'))); */
-/* $this->Map->Lease->Charge->Receipt->unbindModel(array('hasMany' => array('ChargesReceipt'))); */
-
-/* //$this->Map->Lease->unbindModel(array('hasMany' => array('Contact'))); */
-/* $this->Map->Lease->unbindModel(array('hasAndBelongsToMany' => array('Contact'))); */
-/* //$this->Map->Lease->unbindModel(array('hasOne' => array('Contact'))); */
-/* //$this->Map->Lease->unbindModel(array('belongsTo' => array('Contact'))); */
-/* //$this->Map->Lease->bindModel(array('hasOne' => array('ContactsLease'))); */
-/* //$this->Map->Lease->bindModel(array('hasOne' => array('Contact'))); */
-/* /\* $this->Map->Lease->bindModel(array('hasOne' => array('ContactsLease', *\/ */
-/* /\* 'Contact' => array( *\/ */
-/* /\* 'foreignKey' => false, *\/ */
-/* /\* 'conditions' => *\/ */
-/* /\* array('Contact.id = ContactsLease.contact_id', *\/ */
-/* /\* //'ContactsLease.type = "TENANT"' *\/ */
-/* /\* ))))); *\/ */
-
-/* $this->Map->bindModel(array('hasOne' => array('Lease' => array( */
-/* 'foreignKey' => false, */
-/* 'conditions' => array('Lease.map_id = Map.id') */
-/* ), */
-/* 'ContactsLease' => array( */
-/* 'foreignKey' => false, */
-/* 'conditions' => array('ContactsLease.lease_id = Lease.id') */
-/* ), */
-/* 'Contact' => array( */
-/* 'foreignKey' => false, */
-/* 'conditions' => array('Contact.id = ContactsLease.contact_id') */
-/* ))), */
-/* false); */
-
-
-/* $this->Map->Lease->bindModel(array('hasOne' => array('Contact' => array( */
-/* 'className' => 'ContactsLease', */
-/* 'foreignKey' => false, */
-/* 'conditions' => */
-/* array('ContactsLease.lease_id = Lease.id', */
-/* 'ContactsLease.type = "TENANT"'))))); */
-
-/* # 'hasOne' => array( */
-/* # 'RecipesTag', */
-/* # 'FilterTag' => array( */
-/* # 'className' => 'Tag', */
-/* # 'foreignKey' => false, */
-/* # 'conditions' => array('FilterTag.id = RecipesTag.tag_id') */
-/* # )))); */
-
-/* $this->Map->id = $id; */
-/* if ($id !== null && $id !== false) { */
-/* $this->Map->data = $this->Map->find('first', */
-/* array('conditions' => array( */
-/* $this->Map->alias . '.' . $this->Map->primaryKey => $id, */
-/* 'ContactsLease.type = "TENANT"' */
-/* ) */
-/* )); */
-/* $this->set('map', $this->Map->data); */
-/* } */
+ $this->set('info', $this->mapInfo($id));
}
+ /**************************************************************************
+ **************************************************************************
+ **************************************************************************
+ * action: map
+ * - Produces a PNG site map image
+ */
+
+ function map($id = null, $requested_width = 600) {
+ if (!$id) {
+ $this->Session->setFlash(__('Invalid Item.', true));
+ $this->redirect(array('action'=>'index'));
+ }
+ $this->image($this->mapInfo($id), $requested_width);
+ }
+
+ /**************************************************************************
+ **************************************************************************
+ **************************************************************************
+ * mapInfo
+ */
+
+ function mapInfo($id) {
+ // Set up array to hold the map information
+ $info = array('extents' => array(), 'units' => array(),
+ 'map_id' => $id, 'border' => true);
+
+/* // Find all of the map/unit information from this SiteArea */
+/* $this->Map->SiteArea->recursive = 3; */
+/* $this->Map->SiteArea->Site->unbindModel(array('hasMany' => array('SiteArea'))); */
+/* $this->Map->unbindModel(array('belongsTo' => array('SiteArea'))); */
+/* $map = $this->Map->SiteArea->read(null, $site_area_id); */
+
+ // Find all of the map/unit information from this SiteArea
+ $this->Map->recursive = 2;
+ $this->Map->SiteArea->unbindModel(array('hasOne' => array('Map')));
+ $map = $this->Map->read(null, $id);
+ //pr($map);
+
+ // Get the overall site limits, and then compute the
+ // actual boundary extents, adjusting for a border
+ $top_adjustment = 5;
+ $left_adjustment = 5;
+ $info['extents']['top'] = 0;
+ $info['extents']['left'] = 0;
+ $info['extents']['bottom'] = $top_adjustment + $map['Map']['depth'] + 5;
+ $info['extents']['right'] = $left_adjustment + $map['Map']['width'] + 5;
+
+ // Go through each unit in the map, calculating the map location
+ foreach ($map['Unit'] AS $unit) {
+ $lft = $unit['MapsUnit']['pt_left'] + $left_adjustment;
+ $top = $unit['MapsUnit']['pt_top'] + $top_adjustment;
+
+ $width =
+ $unit['MapsUnit']['transpose']
+ ? $unit['UnitSize']['depth']
+ : $unit['UnitSize']['width'];
+
+ $depth =
+ $unit['MapsUnit']['transpose']
+ ? $unit['UnitSize']['width']
+ : $unit['UnitSize']['depth'];
+
+ $info['units'][$unit['id']] =
+ array( 'id' => $unit['id'],
+ 'name' => $unit['name'],
+ 'left' => $lft,
+ 'right' => $lft + $width,
+ 'top' => $top,
+ 'bottom' => $top + $depth,
+ 'width' => $width,
+ 'depth' => $depth,
+ 'n-s' => $unit['MapsUnit']['transpose'] ? 0 : 1,
+ 'status' => $unit['status']
+ );
+ }
+
+ //pr($info);
+ return $info;
+ }
+
// Temporary function
function unitStatusList() {
return
@@ -102,12 +132,12 @@ class MapsController extends AppController {
);
}
- function map($id = null, $requested_width = 600) {
- $info = $this->mapInfo($id);
- $info['border'] = true;
- $info['clickable'] = true;
- $this->image($info, $requested_width);
- }
+ /**************************************************************************
+ **************************************************************************
+ **************************************************************************
+ * action: legend
+ * - Produces a PNG color legend image
+ */
function legend($id = null, $requested_width = 400) {
$status = $this->unitStatusList();
@@ -140,6 +170,14 @@ class MapsController extends AppController {
$this->image($info, $requested_width, true);
}
+ /**************************************************************************
+ **************************************************************************
+ **************************************************************************
+ * helper: image
+ * - used by actions map & legend to set up unit information and
+ * color palates before rendering the PNG image.
+ */
+
function image($info, $requested_width, $legend = false) {
//var $helpers = array('Html', 'Form', 'Javascript', 'Graph');
$this->layout = null;
@@ -217,91 +255,6 @@ class MapsController extends AppController {
- /**************************************************************************
- **************************************************************************
- **************************************************************************
- * mapInfo
- */
-
- function mapInfo($site_area_id) {
- // Set up array to hold the map information
- $info = array('extents' => array(), 'units' => array());
-
- $map = $this->Map->SiteArea->read(null, $site_area_id);
- //pr($map);
-
- $top_adjustment = 5;
- $left_adjustment = 5;
- $info['extents']['top'] = 0;
- $info['extents']['left'] = 0;
- $info['extents']['bottom'] = $top_adjustment + $map['Map']['depth'] + 5;
- $info['extents']['right'] = $left_adjustment + $map['Map']['width'] + 5;
- return $info;
-
- // Get the overall site limits
- $query = "SELECT M.id, M.width, M.depth";
- $query .= " FROM pmgr_maps M";
- $query .= " WHERE site_area_id = $site_area_id";
- $result = $this->Map->query($query);
-
- //pr($result);
- $info['extents']['top'] = 0;
- $info['extents']['left'] = 0;
- $info['extents']['bottom'] = 360;
- $info['extents']['right'] = 480;
- $info['map_id'] = 1;
- return $info;
-
- /* // Fetch and verify the result */
- /* $row = mysql_fetch_array($result); */
- /* if (!$row) die("Site map query failed!"); */
- /* mysql_free_result($result); */
-
- /* // Compute the actual boundaries, adjusting for a border */
- /* $top_adjustment = 5; */
- /* $left_adjustment = 5; */
- /* $info['extents']['top'] = 0; */
- /* $info['extents']['left'] = 0; */
- /* $info['extents']['bottom'] = $top_adjustment + $row['depth'] + 5; */
- /* $info['extents']['right'] = $left_adjustment + $row['width'] + 5; */
- /* $info['map_id'] = $row['id']; */
-
- /* // Get list of units and positions */
- /* $query = "SELECT U.id, U.name, U.status,"; */
- /* $query .= " ($top_adjustment + Mu.pt_top) AS pt_top,"; */
- /* $query .= " ($left_adjustment + Mu.pt_left) AS pt_left,"; */
- /* //$query .= " ($top_adjustment + Mu.pt_bottom) AS pt_bottom,"; */
- /* //$query .= " ($left_adjustment + Mu.pt_right) AS pt_right,"; */
- /* $query .= " IF(Mu.transpose, S.depth, S.width) AS width,"; */
- /* $query .= " IF(Mu.transpose, S.width, S.depth) AS depth"; */
- /* //$query .= " Mu.transpose"; */
- /* $query .= " FROM pmgr_maps_units Mu"; */
- /* $query .= " JOIN pmgr_units U ON U.id = Mu.unit_id"; */
- /* $query .= " JOIN pmgr_unit_sizes S ON S.id = U.size_id"; */
- /* $query .= " WHERE Mu.map_id = $info[map_id]"; */
- /* $result = sql_query($query); */
-
- /* // Go through each one, calculating the map location */
- /* while ($row = mysql_fetch_array($result)) { */
- /* $info['units'][$row['id']] = */
- /* array( 'id' => $row['id'], */
- /* 'name' => $row['name'], */
- /* 'left' => $row['pt_left'], */
- /* 'right' => $row['pt_left'] + $row['width'], */
- /* 'top' => $row['pt_top'], */
- /* 'bottom' => $row['pt_top'] + $row['depth'], */
- /* 'width' => $row['width'], */
- /* 'depth' => $row['depth'], */
- /* 'n-s' => $row['reverseWL'], */
- /* 'status' => $row['status'] */
- /* ); */
- /* } */
-
- /* // Free the result */
- /* mysql_free_result($result); */
-
- /* return $info; */
- }
}
diff --git a/site/views/maps/view.ctp b/site/views/maps/view.ctp
index bc90c4a..7eeeb50 100644
--- a/site/views/maps/view.ctp
+++ b/site/views/maps/view.ctp
@@ -3,8 +3,8 @@
image(array('controller' => 'maps',
- 'action' => 'map',
- $map['Map']['id']),
+ 'action' => 'map',
+ $info['map_id']),
array('alt' => 'Site Map',
'class' => 'imagemap',
'usemap' => '#mapimg'));
From 684f02ebc57c3fe3d989668dcf05e1fc8b6a734d Mon Sep 17 00:00:00 2001
From: abijah
Date: Fri, 29 May 2009 03:36:28 +0000
Subject: [PATCH 033/717] More tweaks to get the map working. At the moment,
the clickable area is off because it's not scaled like the actual image is.
I'll have to work on that next.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@34 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/maps_controller.php | 7 ++--
site/views/maps/view.ctp | 54 +++++++++++++++++++---------
2 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/site/controllers/maps_controller.php b/site/controllers/maps_controller.php
index 088c8cf..bab9533 100644
--- a/site/controllers/maps_controller.php
+++ b/site/controllers/maps_controller.php
@@ -42,7 +42,7 @@ class MapsController extends AppController {
* - Produces a PNG site map image
*/
- function map($id = null, $requested_width = 600) {
+ function map($id = null, $requested_width = 800) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index'));
@@ -235,14 +235,14 @@ class MapsController extends AppController {
*****/
// Scale things according to desired display width
- $screen_adjustment_factor = $requested_width / $info['extents']['right'];;
+ $screen_adjustment_factor = $requested_width / $info['extents']['right'];
// Define image size
$info['width'] = $info['extents']['right'] * $screen_adjustment_factor;
$info['depth'] = $info['extents']['bottom'] * $screen_adjustment_factor;
// Go through each unit, adjusting map locations
- foreach ($info['units'] AS $unit) {
+ foreach ($info['units'] AS &$unit) {
$unit['left'] *= $screen_adjustment_factor;
$unit['right'] *= $screen_adjustment_factor;
$unit['top'] *= $screen_adjustment_factor;
@@ -255,7 +255,6 @@ class MapsController extends AppController {
-
}
?>
\ No newline at end of file
diff --git a/site/views/maps/view.ctp b/site/views/maps/view.ctp
index 7eeeb50..a6d5ef6 100644
--- a/site/views/maps/view.ctp
+++ b/site/views/maps/view.ctp
@@ -1,24 +1,46 @@
-
-image(array('controller' => 'maps',
- 'action' => 'map',
- $info['map_id']),
- array('alt' => 'Site Map',
- 'class' => 'imagemap',
- 'usemap' => '#mapimg'));
-?>
+
+
+ image(array('controller' => 'maps',
+ 'action' => 'map',
+ $info['map_id']),
+ array('alt' => 'Site Map',
+ 'class' => 'map',
+ 'usemap' => '#mapzones'));
+ ?>
+
-
+
image(array('controller' => 'maps',
- 'action' => 'legend',
- $map['Map']['id']),
- array('alt' => 'Site Map Legend'));
- */
+ echo $html->image(array('controller' => 'maps',
+ 'action' => 'legend',
+ $info['map_id']),
+ array('alt' => 'Site Map Legend',
+ 'class' => 'map'));
?>
From db03c73b599aafc6bc1dfbd28cc3a34a4b227d1e Mon Sep 17 00:00:00 2001
From: abijah
Date: Fri, 29 May 2009 04:37:24 +0000
Subject: [PATCH 034/717] Fixed the underlying hotlink map to match the
coordinates of the actual image. Also fixed a few issues with
requested_width propogation, although there may still be some bugs.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@35 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/controllers/maps_controller.php | 106 +++++++++++++--------------
site/views/maps/view.ctp | 11 ++-
2 files changed, 59 insertions(+), 58 deletions(-)
diff --git a/site/controllers/maps_controller.php b/site/controllers/maps_controller.php
index bab9533..88140c0 100644
--- a/site/controllers/maps_controller.php
+++ b/site/controllers/maps_controller.php
@@ -26,12 +26,12 @@ class MapsController extends AppController {
* - Generates a site map page
*/
- function view($id = null) {
+ function view($id = null, $requested_width = 800) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index'));
}
- $this->set('info', $this->mapInfo($id));
+ $this->set('info', $this->mapInfo($id, $requested_width));
}
@@ -47,7 +47,7 @@ class MapsController extends AppController {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('action'=>'index'));
}
- $this->image($this->mapInfo($id), $requested_width);
+ $this->image($this->mapInfo($id, $requested_width));
}
/**************************************************************************
@@ -56,16 +56,11 @@ class MapsController extends AppController {
* mapInfo
*/
- function mapInfo($id) {
+ function mapInfo($id, $requested_width) {
// Set up array to hold the map information
- $info = array('extents' => array(), 'units' => array(),
- 'map_id' => $id, 'border' => true);
-
-/* // Find all of the map/unit information from this SiteArea */
-/* $this->Map->SiteArea->recursive = 3; */
-/* $this->Map->SiteArea->Site->unbindModel(array('hasMany' => array('SiteArea'))); */
-/* $this->Map->unbindModel(array('belongsTo' => array('SiteArea'))); */
-/* $map = $this->Map->SiteArea->read(null, $site_area_id); */
+ $info = array('map_id' => $id,
+ 'border' => true,
+ 'units' => array());
// Find all of the map/unit information from this SiteArea
$this->Map->recursive = 2;
@@ -73,19 +68,32 @@ class MapsController extends AppController {
$map = $this->Map->read(null, $id);
//pr($map);
+ /*****
+ * The preference would be to leave all things "screen" related
+ * to reside in the view. However, two separate views need this
+ * information. The 'view' needs it to include a clickable map
+ * that corresponds to the map image, and of course, the 'map'
+ * (or 'image') view needs it to render the image. So, in the
+ * controller for now, unless I come up with a better idea.
+ *****/
+
// Get the overall site limits, and then compute the
// actual boundary extents, adjusting for a border
- $top_adjustment = 5;
- $left_adjustment = 5;
- $info['extents']['top'] = 0;
- $info['extents']['left'] = 0;
- $info['extents']['bottom'] = $top_adjustment + $map['Map']['depth'] + 5;
- $info['extents']['right'] = $left_adjustment + $map['Map']['width'] + 5;
+ $boundary_adjustment = 5;
+ $bottom = 2*$boundary_adjustment + $map['Map']['depth'];
+ $right = 2*$boundary_adjustment + $map['Map']['width'];
+
+ // Scale things according to desired display width
+ $screen_adjustment_factor = $requested_width / $right;
+
+ // Define the overall canvas size
+ $info['width'] = $right * $screen_adjustment_factor;
+ $info['depth'] = $bottom * $screen_adjustment_factor;
// Go through each unit in the map, calculating the map location
foreach ($map['Unit'] AS $unit) {
- $lft = $unit['MapsUnit']['pt_left'] + $left_adjustment;
- $top = $unit['MapsUnit']['pt_top'] + $top_adjustment;
+ $lft = $unit['MapsUnit']['pt_left'] + $boundary_adjustment;
+ $top = $unit['MapsUnit']['pt_top'] + $boundary_adjustment;
$width =
$unit['MapsUnit']['transpose']
@@ -97,7 +105,13 @@ class MapsController extends AppController {
? $unit['UnitSize']['width']
: $unit['UnitSize']['depth'];
- $info['units'][$unit['id']] =
+ $lft *= $screen_adjustment_factor;
+ $top *= $screen_adjustment_factor;
+ $width *= $screen_adjustment_factor;
+ $depth *= $screen_adjustment_factor;
+
+ //$info['units'][$unit['id']] =
+ $info['units'][] =
array( 'id' => $unit['id'],
'name' => $unit['name'],
'left' => $lft,
@@ -144,14 +158,22 @@ class MapsController extends AppController {
$cols = 6;
$rows = (int)((count($status) + $cols - 1) / $cols);
- $info = array('extents' => array(), 'units' => array(), 'legend' => array());
- $info['legend']['width'] = 360;
- $info['legend']['depth'] = 120;
+ $info = array('units' => array(), 'legend' => array());
- $info['extents']['right'] = $info['legend']['width'] * $cols;
- $info['extents']['bottom'] = $info['legend']['depth'] * $rows;
+ // Get the overall site limits, and then compute the
+ // actual boundary extents, adjusting for a border
+ $boundary_adjustment = 2;
+ $bottom = 2*$boundary_adjustment + $cols*360;
+ $right = 2*$boundary_adjustment + $rows*120;
- $top = $lft = 0;
+ // Scale things according to desired display width
+ $screen_adjustment_factor = $requested_width / $right;
+
+ // Define the overall canvas size
+ $info['width'] = $right * $screen_adjustment_factor;
+ $info['depth'] = $bottom * $screen_adjustment_factor;
+
+ $top = $lft = $boundary_adjustment;
foreach ($status AS $code => $color) {
$info['units'][] = array('name' => $code,
'status' => $code,
@@ -163,11 +185,11 @@ class MapsController extends AppController {
'bottom' => $top + $info['legend']['depth']);
$top += $info['legend']['depth'];
if ($top >= $info['legend']['depth'] * $rows) {
- $top = 0; $lft += $info['legend']['width'];
+ $top = $boundary_adjustment; $lft += $info['legend']['width'];
}
}
- $this->image($info, $requested_width, true);
+ $this->image($info, true);
}
/**************************************************************************
@@ -178,7 +200,7 @@ class MapsController extends AppController {
* color palates before rendering the PNG image.
*/
- function image($info, $requested_width, $legend = false) {
+ function image($info, $legend = false) {
//var $helpers = array('Html', 'Form', 'Javascript', 'Graph');
$this->layout = null;
$this->autoLayout = false;
@@ -225,30 +247,6 @@ class MapsController extends AppController {
//pr($info);
- /*****
- * The preference would be to leave all things "screen" related
- * to reside in the view. However, two separate views need this
- * information. The 'view' needs it to include a clickable map
- * that corresponds to the map image, and of course, the 'map'
- * (or 'image') view needs it to render the image. So, in the
- * controller for now, unless I come up with a better idea.
- *****/
-
- // Scale things according to desired display width
- $screen_adjustment_factor = $requested_width / $info['extents']['right'];
-
- // Define image size
- $info['width'] = $info['extents']['right'] * $screen_adjustment_factor;
- $info['depth'] = $info['extents']['bottom'] * $screen_adjustment_factor;
-
- // Go through each unit, adjusting map locations
- foreach ($info['units'] AS &$unit) {
- $unit['left'] *= $screen_adjustment_factor;
- $unit['right'] *= $screen_adjustment_factor;
- $unit['top'] *= $screen_adjustment_factor;
- $unit['bottom'] *= $screen_adjustment_factor;
- }
-
$this->set(compact('info'));
$this->render('image');
}
diff --git a/site/views/maps/view.ctp b/site/views/maps/view.ctp
index a6d5ef6..e6324df 100644
--- a/site/views/maps/view.ctp
+++ b/site/views/maps/view.ctp
@@ -1,15 +1,16 @@
-
From 2da7b6b2c04d4556a64b58c15f814ae1cf199dcc Mon Sep 17 00:00:00 2001
From: abijah
Date: Fri, 29 May 2009 06:57:22 +0000
Subject: [PATCH 036/717] Added a higher preference for horizontal unit names
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@37 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/views/maps/image.ctp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/site/views/maps/image.ctp b/site/views/maps/image.ctp
index 0a68c25..9d789e5 100644
--- a/site/views/maps/image.ctp
+++ b/site/views/maps/image.ctp
@@ -68,7 +68,7 @@ foreach ($info['units'] AS $unit) {
// If the unit is wide enough, run the text horizontal,
// otherwise, we'll have to run it vertical.
- if ($unit['width'] > 40 || ($unit['width'] >= $unit['depth'])) {
+ if ($unit['width'] > 20 || ($unit['width'] >= $unit['depth'])) {
imagestring($image, $unit['width']/25,
$unit['left']+3, $unit['top']+3,
$unit['name'],
From f384e051bfbc2a5f02d837635a828e60b16936fd Mon Sep 17 00:00:00 2001
From: abijah
Date: Fri, 29 May 2009 14:49:11 +0000
Subject: [PATCH 037/717] Initial working version ofa consistent layout with
side menu
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@38 97e9348a-65ac-dc4b-aefc-98561f571b83
---
site/app_controller.php | 19 ++++
site/views/contacts/view.ctp | 1 -
site/views/elements/contacts.ctp | 13 ++-
site/views/elements/maps.ctp | 13 ++-
site/views/elements/sidemenu.ctp | 24 +++++
site/views/elements/units.ctp | 13 ++-
site/views/layouts/default.ctp | 50 +++++++----
site/views/units/view.ctp | 1 -
site/webroot/css/cake.generic.css | 5 +-
site/webroot/css/sidemenu.css | 140 ++++++++++++++++++++++++++++++
10 files changed, 234 insertions(+), 45 deletions(-)
create mode 100644 site/views/elements/sidemenu.ctp
create mode 100644 site/webroot/css/sidemenu.css
diff --git a/site/app_controller.php b/site/app_controller.php
index 87357ed..ae6a785 100644
--- a/site/app_controller.php
+++ b/site/app_controller.php
@@ -35,5 +35,24 @@
* @subpackage cake.app
*/
class AppController extends Controller {
+
+ function sideMenuStandardLinks() {
+ return array(
+ array('name' => 'Standard Menu', 'header' => true),
+ array('name' => 'Site Map', 'url' => array('controller' => 'maps', 'action' => 'view', 1)),
+ array('hr' => true),
+ array('name' => 'Tenants', 'url' => array('controller' => 'contacts', 'action' => 'index')),
+ array('name' => 'Units', 'url' => array('controller' => 'units', 'action' => 'index')),
+ );
+ }
+
+ function sideMenuLinks() {
+ return $this->sideMenuStandardLinks();
+ }
+
+ function beforeRender() {
+ $this->set('sidemenu', $this->sideMenuLinks());
+ }
+
}
?>
\ No newline at end of file
diff --git a/site/views/contacts/view.ctp b/site/views/contacts/view.ctp
index 5d6e968..d2823c9 100644
--- a/site/views/contacts/view.ctp
+++ b/site/views/contacts/view.ctp
@@ -1,7 +1,6 @@