', $templateCode);
@@ -567,7 +569,7 @@ class="btn btn-default"
$templateCode .= $jsReadOnly;
$templateCode .= $jsEditable;
- if(!$selected_id) {
+ if(!$hasSelectedId) {
$templateCode.="\n\tif(document.getElementById('primary_emailEdit')) { document.getElementById('primary_emailEdit').style.display='inline'; }";
$templateCode.="\n\tif(document.getElementById('primary_emailEditLink')) { document.getElementById('primary_emailEditLink').style.display='none'; }";
$templateCode.="\n\tif(document.getElementById('alternate_emailEdit')) { document.getElementById('alternate_emailEdit').style.display='inline'; }";
@@ -599,8 +601,8 @@ class="btn btn-default"
/* default field values */
$rdata = $jdata = get_defaults('rental_owners');
- if($selected_id) {
- $jdata = get_joined_record('rental_owners', $selected_id);
+ if($hasSelectedId) {
+ $jdata = get_joined_record('rental_owners', $selectedId);
if($jdata === false) $jdata = get_defaults('rental_owners');
$rdata = $row;
}
@@ -609,7 +611,7 @@ class="btn btn-default"
// hook: rental_owners_dv
if(function_exists('rental_owners_dv')) {
$args = [];
- rental_owners_dv(($selected_id ? $selected_id : FALSE), getMemberInfo(), $templateCode, $args);
+ rental_owners_dv(($hasSelectedId ? $selectedId : FALSE), getMemberInfo(), $templateCode, $args);
}
return $templateCode;
diff --git a/app/residence_and_rental_history_dml.php b/app/residence_and_rental_history_dml.php
index 5b72121..0d4c761 100644
--- a/app/residence_and_rental_history_dml.php
+++ b/app/residence_and_rental_history_dml.php
@@ -183,31 +183,40 @@ function residence_and_rental_history_update(&$selected_id, &$error_message = ''
set_record_owner('residence_and_rental_history', $selected_id);
}
-function residence_and_rental_history_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $AllowDelete = 1, $separateDV = 0, $TemplateDV = '', $TemplateDVP = '') {
+function residence_and_rental_history_form($selectedId = '', $allowUpdate = true, $allowInsert = true, $allowDelete = true, $separateDV = true, $templateDV = '', $templateDVP = '') {
// function to return an editable form for a table records
- // and fill it with data of record whose ID is $selected_id. If $selected_id
+ // and fill it with data of record whose ID is $selectedId. If $selectedId
// is empty, an empty form is shown, with only an 'Add New'
// button displayed.
global $Translation;
$eo = ['silentErrors' => true];
- $noUploads = null;
- $row = $urow = $jsReadOnly = $jsEditable = $lookups = null;
-
+ $noUploads = $row = $urow = $jsReadOnly = $jsEditable = $lookups = null;
$noSaveAsCopy = false;
+ $hasSelectedId = strlen($selectedId) > 0;
// mm: get table permissions
$arrPerm = getTablePermissions('residence_and_rental_history');
- if(!$arrPerm['insert'] && $selected_id == '')
+ $allowInsert = ($arrPerm['insert'] ? true : false);
+ $allowUpdate = $hasSelectedId && check_record_permission('residence_and_rental_history', $selectedId, 'edit');
+ $allowDelete = $hasSelectedId && check_record_permission('residence_and_rental_history', $selectedId, 'delete');
+
+ if(!$allowInsert && !$hasSelectedId)
// no insert permission and no record selected
- // so show access denied error unless TVDV
+ // so show access denied error -- except if TVDV: just hide DV
return $separateDV ? $Translation['tableAccessDenied'] : '';
- $AllowInsert = ($arrPerm['insert'] ? true : false);
+
+ if($hasSelectedId && !check_record_permission('residence_and_rental_history', $selectedId, 'view'))
+ return $Translation['tableAccessDenied'];
+
// print preview?
- $dvprint = false;
- if(strlen($selected_id) && Request::val('dvprint_x') != '') {
- $dvprint = true;
- }
+ $dvprint = $hasSelectedId && Request::val('dvprint_x') != '';
+
+ $showSaveNew = !$dvprint && ($allowInsert && !$hasSelectedId);
+ $showSaveChanges = !$dvprint && $allowUpdate && $hasSelectedId;
+ $showDelete = !$dvprint && $allowDelete && $hasSelectedId;
+ $showSaveAsCopy = !$dvprint && ($allowInsert && $hasSelectedId && !$noSaveAsCopy);
+ $fieldsAreEditable = !$dvprint && (($allowInsert && !$hasSelectedId) || ($allowUpdate && $hasSelectedId) || $showSaveAsCopy);
$filterer_tenant = Request::val('filterer_tenant');
@@ -234,17 +243,8 @@ function residence_and_rental_history_form($selected_id = '', $AllowUpdate = 1,
$combo_to->MonthNames = $Translation['month names'];
$combo_to->NamePrefix = 'to';
- if($selected_id) {
- if(!check_record_permission('residence_and_rental_history', $selected_id, 'view'))
- return $Translation['tableAccessDenied'];
-
- // can edit?
- $AllowUpdate = check_record_permission('residence_and_rental_history', $selected_id, 'edit');
-
- // can delete?
- $AllowDelete = check_record_permission('residence_and_rental_history', $selected_id, 'delete');
-
- $res = sql("SELECT * FROM `residence_and_rental_history` WHERE `id`='" . makeSafe($selected_id) . "'", $eo);
+ if($hasSelectedId) {
+ $res = sql("SELECT * FROM `residence_and_rental_history` WHERE `id`='" . makeSafe($selectedId) . "'", $eo);
if(!($row = db_fetch_array($res))) {
return error_message($Translation['No records found'], 'residence_and_rental_history_view.php', false);
}
@@ -267,7 +267,7 @@ function residence_and_rental_history_form($selected_id = '', $AllowUpdate = 1,
\n";
@@ -604,8 +606,8 @@ class="btn btn-default"
/* default field values */
$rdata = $jdata = get_defaults('residence_and_rental_history');
- if($selected_id) {
- $jdata = get_joined_record('residence_and_rental_history', $selected_id);
+ if($hasSelectedId) {
+ $jdata = get_joined_record('residence_and_rental_history', $selectedId);
if($jdata === false) $jdata = get_defaults('residence_and_rental_history');
$rdata = $row;
}
@@ -614,7 +616,7 @@ class="btn btn-default"
// hook: residence_and_rental_history_dv
if(function_exists('residence_and_rental_history_dv')) {
$args = [];
- residence_and_rental_history_dv(($selected_id ? $selected_id : FALSE), getMemberInfo(), $templateCode, $args);
+ residence_and_rental_history_dv(($hasSelectedId ? $selectedId : FALSE), getMemberInfo(), $templateCode, $args);
}
return $templateCode;
diff --git a/app/resources/lib/CSVImport.php b/app/resources/lib/CSVImport.php
index 2a5d7be..3b6ee5a 100644
--- a/app/resources/lib/CSVImport.php
+++ b/app/resources/lib/CSVImport.php
@@ -876,36 +876,24 @@ private function saveJob() {
}
private function setupDb() {
- $eo = ['silentErrors' => true];
-
$tn = self::JOBS_TABLE;
- sql(
- "CREATE TABLE IF NOT EXISTS `{$tn}` (
- `id` VARCHAR(40) NOT NULL,
- `memberID` VARCHAR(100) NOT NULL,
- `config` TEXT,
- `insert_ts` INT,
- `last_update_ts` INT,
- `total` INT DEFAULT 99999999,
- `done` INT DEFAULT 0,
- PRIMARY KEY (`id`),
- INDEX `memberID` (`memberID`)
- ) CHARSET " . mysql_charset,
- $eo);
+ createTableIfNotExists($tn);
+ addIndex($tn, 'memberID');
// TODO
/*
$tn = self::JOBS_LOG_TABLE;
- sql(
- "CREATE TABLE IF NOT EXISTS `{$tn}` (
- `id` BIGINT NOT NULL AUTO_INCREMENT,
- `job_id` VARCHAR(40) NOT NULL,
- `ts` INT,
- `details` TEXT,
- PRIMARY KEY (`id`),
- INDEX `job_id` (`job_id`)
- ) CHARSET " . mysql_charset,
- $eo);
+ createTableIfNotExists($tn);
+ addIndex($n, 'job_id');
+
+ CREATE TABLE IF NOT EXISTS `{$tn}` (
+ `id` BIGINT NOT NULL AUTO_INCREMENT,
+ `job_id` VARCHAR(40) NOT NULL,
+ `ts` INT,
+ `details` TEXT,
+ PRIMARY KEY (`id`),
+ INDEX `job_id` (`job_id`)
+ ) CHARSET mysql_charset
*/
}
diff --git a/app/unit_photos_dml.php b/app/unit_photos_dml.php
index 57719ee..ed77e1a 100644
--- a/app/unit_photos_dml.php
+++ b/app/unit_photos_dml.php
@@ -204,31 +204,40 @@ function unit_photos_update(&$selected_id, &$error_message = '') {
set_record_owner('unit_photos', $selected_id);
}
-function unit_photos_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $AllowDelete = 1, $separateDV = 0, $TemplateDV = '', $TemplateDVP = '') {
+function unit_photos_form($selectedId = '', $allowUpdate = true, $allowInsert = true, $allowDelete = true, $separateDV = true, $templateDV = '', $templateDVP = '') {
// function to return an editable form for a table records
- // and fill it with data of record whose ID is $selected_id. If $selected_id
+ // and fill it with data of record whose ID is $selectedId. If $selectedId
// is empty, an empty form is shown, with only an 'Add New'
// button displayed.
global $Translation;
$eo = ['silentErrors' => true];
- $noUploads = null;
- $row = $urow = $jsReadOnly = $jsEditable = $lookups = null;
-
+ $noUploads = $row = $urow = $jsReadOnly = $jsEditable = $lookups = null;
$noSaveAsCopy = false;
+ $hasSelectedId = strlen($selectedId) > 0;
// mm: get table permissions
$arrPerm = getTablePermissions('unit_photos');
- if(!$arrPerm['insert'] && $selected_id == '')
+ $allowInsert = ($arrPerm['insert'] ? true : false);
+ $allowUpdate = $hasSelectedId && check_record_permission('unit_photos', $selectedId, 'edit');
+ $allowDelete = $hasSelectedId && check_record_permission('unit_photos', $selectedId, 'delete');
+
+ if(!$allowInsert && !$hasSelectedId)
// no insert permission and no record selected
- // so show access denied error unless TVDV
+ // so show access denied error -- except if TVDV: just hide DV
return $separateDV ? $Translation['tableAccessDenied'] : '';
- $AllowInsert = ($arrPerm['insert'] ? true : false);
+
+ if($hasSelectedId && !check_record_permission('unit_photos', $selectedId, 'view'))
+ return $Translation['tableAccessDenied'];
+
// print preview?
- $dvprint = false;
- if(strlen($selected_id) && Request::val('dvprint_x') != '') {
- $dvprint = true;
- }
+ $dvprint = $hasSelectedId && Request::val('dvprint_x') != '';
+
+ $showSaveNew = !$dvprint && ($allowInsert && !$hasSelectedId);
+ $showSaveChanges = !$dvprint && $allowUpdate && $hasSelectedId;
+ $showDelete = !$dvprint && $allowDelete && $hasSelectedId;
+ $showSaveAsCopy = !$dvprint && ($allowInsert && $hasSelectedId && !$noSaveAsCopy);
+ $fieldsAreEditable = !$dvprint && (($allowInsert && !$hasSelectedId) || ($allowUpdate && $hasSelectedId) || $showSaveAsCopy);
$filterer_unit = Request::val('filterer_unit');
@@ -239,17 +248,8 @@ function unit_photos_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1,
// combobox: unit
$combo_unit = new DataCombo;
- if($selected_id) {
- if(!check_record_permission('unit_photos', $selected_id, 'view'))
- return $Translation['tableAccessDenied'];
-
- // can edit?
- $AllowUpdate = check_record_permission('unit_photos', $selected_id, 'edit');
-
- // can delete?
- $AllowDelete = check_record_permission('unit_photos', $selected_id, 'delete');
-
- $res = sql("SELECT * FROM `unit_photos` WHERE `id`='" . makeSafe($selected_id) . "'", $eo);
+ if($hasSelectedId) {
+ $res = sql("SELECT * FROM `unit_photos` WHERE `id`='" . makeSafe($selectedId) . "'", $eo);
if(!($row = db_fetch_array($res))) {
return error_message($Translation['No records found'], 'unit_photos_view.php', false);
}
@@ -270,7 +270,7 @@ function unit_photos_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1,
\n";
@@ -556,8 +558,8 @@ class="btn btn-default"
/* default field values */
$rdata = $jdata = get_defaults('unit_photos');
- if($selected_id) {
- $jdata = get_joined_record('unit_photos', $selected_id);
+ if($hasSelectedId) {
+ $jdata = get_joined_record('unit_photos', $selectedId);
if($jdata === false) $jdata = get_defaults('unit_photos');
$rdata = $row;
}
@@ -566,7 +568,7 @@ class="btn btn-default"
// hook: unit_photos_dv
if(function_exists('unit_photos_dv')) {
$args = [];
- unit_photos_dv(($selected_id ? $selected_id : FALSE), getMemberInfo(), $templateCode, $args);
+ unit_photos_dv(($hasSelectedId ? $selectedId : FALSE), getMemberInfo(), $templateCode, $args);
}
return $templateCode;
diff --git a/app/units_dml.php b/app/units_dml.php
index acfbfad..0212d55 100644
--- a/app/units_dml.php
+++ b/app/units_dml.php
@@ -276,31 +276,40 @@ function units_update(&$selected_id, &$error_message = '') {
set_record_owner('units', $selected_id);
}
-function units_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $AllowDelete = 1, $separateDV = 0, $TemplateDV = '', $TemplateDVP = '') {
+function units_form($selectedId = '', $allowUpdate = true, $allowInsert = true, $allowDelete = true, $separateDV = true, $templateDV = '', $templateDVP = '') {
// function to return an editable form for a table records
- // and fill it with data of record whose ID is $selected_id. If $selected_id
+ // and fill it with data of record whose ID is $selectedId. If $selectedId
// is empty, an empty form is shown, with only an 'Add New'
// button displayed.
global $Translation;
$eo = ['silentErrors' => true];
- $noUploads = null;
- $row = $urow = $jsReadOnly = $jsEditable = $lookups = null;
-
+ $noUploads = $row = $urow = $jsReadOnly = $jsEditable = $lookups = null;
$noSaveAsCopy = false;
+ $hasSelectedId = strlen($selectedId) > 0;
// mm: get table permissions
$arrPerm = getTablePermissions('units');
- if(!$arrPerm['insert'] && $selected_id == '')
+ $allowInsert = ($arrPerm['insert'] ? true : false);
+ $allowUpdate = $hasSelectedId && check_record_permission('units', $selectedId, 'edit');
+ $allowDelete = $hasSelectedId && check_record_permission('units', $selectedId, 'delete');
+
+ if(!$allowInsert && !$hasSelectedId)
// no insert permission and no record selected
- // so show access denied error unless TVDV
+ // so show access denied error -- except if TVDV: just hide DV
return $separateDV ? $Translation['tableAccessDenied'] : '';
- $AllowInsert = ($arrPerm['insert'] ? true : false);
+
+ if($hasSelectedId && !check_record_permission('units', $selectedId, 'view'))
+ return $Translation['tableAccessDenied'];
+
// print preview?
- $dvprint = false;
- if(strlen($selected_id) && Request::val('dvprint_x') != '') {
- $dvprint = true;
- }
+ $dvprint = $hasSelectedId && Request::val('dvprint_x') != '';
+
+ $showSaveNew = !$dvprint && ($allowInsert && !$hasSelectedId);
+ $showSaveChanges = !$dvprint && $allowUpdate && $hasSelectedId;
+ $showDelete = !$dvprint && $allowDelete && $hasSelectedId;
+ $showSaveAsCopy = !$dvprint && ($allowInsert && $hasSelectedId && !$noSaveAsCopy);
+ $fieldsAreEditable = !$dvprint && (($allowInsert && !$hasSelectedId) || ($allowUpdate && $hasSelectedId) || $showSaveAsCopy);
$filterer_property = Request::val('filterer_property');
@@ -342,17 +351,8 @@ function units_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $Allo
}
$combo_features->SelectName = 'features';
- if($selected_id) {
- if(!check_record_permission('units', $selected_id, 'view'))
- return $Translation['tableAccessDenied'];
-
- // can edit?
- $AllowUpdate = check_record_permission('units', $selected_id, 'edit');
-
- // can delete?
- $AllowDelete = check_record_permission('units', $selected_id, 'delete');
-
- $res = sql("SELECT * FROM `units` WHERE `id`='" . makeSafe($selected_id) . "'", $eo);
+ if($hasSelectedId) {
+ $res = sql("SELECT * FROM `units` WHERE `id`='" . makeSafe($selectedId) . "'", $eo);
if(!($row = db_fetch_array($res))) {
return error_message($Translation['No records found'], 'units_view.php', false);
}
@@ -378,7 +378,7 @@ function units_form($selected_id = '', $AllowUpdate = 1, $AllowInsert = 1, $Allo
\n";
@@ -723,7 +725,7 @@ class="btn btn-default"
$templateCode .= "\t\t\tcontentType: 'application/x-www-form-urlencoded; charset=" . datalist_db_encoding . "',\n";
$templateCode .= "\t\t\ttype: 'GET',\n";
$templateCode .= "\t\t\tbeforeSend: function() { \$j('#property$rnd1').prop('disabled', true); },\n";
- $templateCode .= "\t\t\tcomplete: function() { " . (($arrPerm['insert'] || (($arrPerm['edit'] == 1 && $ownerMemberID == getLoggedMemberID()) || ($arrPerm['edit'] == 2 && $ownerGroupID == getLoggedGroupID()) || $arrPerm['edit'] == 3)) ? "\$j('#property$rnd1').prop('disabled', false); " : "\$j('#property$rnd1').prop('disabled', true); ")." \$j(window).resize(); }\n";
+ $templateCode .= "\t\t\tcomplete: function() { " . (($allowInsert || $allowUpdate) ? "\$j('#property$rnd1').prop('disabled', false); " : "\$j('#property$rnd1').prop('disabled', true); ")." \$j(window).resize(); }\n";
}
$templateCode .= "\t\t});\n";
$templateCode .= "\t};\n";
@@ -747,8 +749,8 @@ class="btn btn-default"
/* default field values */
$rdata = $jdata = get_defaults('units');
- if($selected_id) {
- $jdata = get_joined_record('units', $selected_id);
+ if($hasSelectedId) {
+ $jdata = get_joined_record('units', $selectedId);
if($jdata === false) $jdata = get_defaults('units');
$rdata = $row;
}
@@ -757,7 +759,7 @@ class="btn btn-default"
// hook: units_dv
if(function_exists('units_dv')) {
$args = [];
- units_dv(($selected_id ? $selected_id : FALSE), getMemberInfo(), $templateCode, $args);
+ units_dv(($hasSelectedId ? $selectedId : FALSE), getMemberInfo(), $templateCode, $args);
}
return $templateCode;
diff --git a/app/updateDB.php b/app/updateDB.php
index 2156cad..f06ffd1 100644
--- a/app/updateDB.php
+++ b/app/updateDB.php
@@ -9,195 +9,40 @@
// check if this setup file already run
if($thisMD5 != $prevMD5) {
// set up tables
- setupTable(
- 'applicants_and_tenants', "
- CREATE TABLE IF NOT EXISTS `applicants_and_tenants` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `last_name` VARCHAR(40) NULL,
- `first_name` VARCHAR(40) NULL,
- `email` VARCHAR(80) NULL,
- `phone` VARCHAR(15) NULL,
- `birth_date` DATE NULL,
- `driver_license_number` VARCHAR(15) NULL,
- `driver_license_state` VARCHAR(15) NULL,
- `requested_lease_term` VARCHAR(15) NULL,
- `monthly_gross_pay` DECIMAL(8,2) NULL,
- `additional_income` DECIMAL(8,2) NULL,
- `assets` DECIMAL(8,2) NULL,
- `status` VARCHAR(40) NOT NULL DEFAULT 'Applicant',
- `notes` TEXT NULL
- ) CHARSET utf8"
- );
-
- setupTable(
- 'applications_leases', "
- CREATE TABLE IF NOT EXISTS `applications_leases` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `tenants` INT UNSIGNED NULL,
- `status` VARCHAR(40) NOT NULL DEFAULT 'Application',
- `property` INT UNSIGNED NULL,
- `unit` INT UNSIGNED NULL,
- `type` VARCHAR(40) NOT NULL DEFAULT 'Fixed',
- `total_number_of_occupants` VARCHAR(15) NULL,
- `start_date` DATE NULL,
- `end_date` DATE NULL,
- `recurring_charges_frequency` VARCHAR(40) NOT NULL DEFAULT 'Monthly',
- `next_due_date` DATE NULL,
- `rent` DECIMAL(10,2) NULL,
- `security_deposit` DECIMAL(15,2) NULL,
- `security_deposit_date` DATE NULL,
- `emergency_contact` VARCHAR(100) NULL,
- `co_signer_details` VARCHAR(100) NULL,
- `notes` TEXT NULL,
- `agreement` VARCHAR(40) NULL
- ) CHARSET utf8"
- );
+ setupTable('applicants_and_tenants', []);
+
+ setupTable('applications_leases', []);
setupIndexes('applications_leases', ['tenants','property','unit',]);
- setupTable(
- 'residence_and_rental_history', "
- CREATE TABLE IF NOT EXISTS `residence_and_rental_history` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `tenant` INT UNSIGNED NULL,
- `address` VARCHAR(40) NULL,
- `landlord_or_manager_name` VARCHAR(100) NULL,
- `landlord_or_manager_phone` VARCHAR(15) NULL,
- `monthly_rent` DECIMAL(10,2) NULL,
- `duration_of_residency_from` DATE NULL,
- `to` DATE NULL,
- `reason_for_leaving` VARCHAR(40) NULL,
- `notes` TEXT NULL
- ) CHARSET utf8"
- );
+ setupTable('residence_and_rental_history', []);
setupIndexes('residence_and_rental_history', ['tenant',]);
- setupTable(
- 'employment_and_income_history', "
- CREATE TABLE IF NOT EXISTS `employment_and_income_history` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `tenant` INT UNSIGNED NULL,
- `employer_name` VARCHAR(100) NULL,
- `city` VARCHAR(100) NULL,
- `employer_phone` VARCHAR(15) NULL,
- `employed_from` DATE NULL,
- `employed_till` DATE NULL,
- `occupation` VARCHAR(40) NULL,
- `notes` TEXT NULL
- ) CHARSET utf8"
- );
+ setupTable('employment_and_income_history', []);
setupIndexes('employment_and_income_history', ['tenant',]);
- setupTable(
- 'references', "
- CREATE TABLE IF NOT EXISTS `references` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `tenant` INT UNSIGNED NULL,
- `reference_name` VARCHAR(100) NULL,
- `phone` VARCHAR(15) NULL
- ) CHARSET utf8"
- );
+ setupTable('references', []);
setupIndexes('references', ['tenant',]);
- setupTable(
- 'rental_owners', "
- CREATE TABLE IF NOT EXISTS `rental_owners` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `first_name` VARCHAR(40) NULL,
- `last_name` VARCHAR(40) NULL,
- `company_name` VARCHAR(40) NULL,
- `date_of_birth` DATE NULL,
- `primary_email` VARCHAR(40) NULL,
- `alternate_email` VARCHAR(40) NULL,
- `phone` VARCHAR(40) NULL,
- `country` VARCHAR(40) NULL,
- `street` VARCHAR(40) NULL,
- `city` VARCHAR(40) NULL,
- `state` VARCHAR(40) NULL,
- `zip` DECIMAL(15,0) NULL,
- `comments` TEXT NULL
- ) CHARSET utf8"
- );
-
- setupTable(
- 'properties', "
- CREATE TABLE IF NOT EXISTS `properties` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `property_name` VARCHAR(100) NOT NULL,
- `photo` VARCHAR(40) NULL,
- `type` VARCHAR(40) NOT NULL,
- `number_of_units` DECIMAL(15,0) NULL,
- `owner` INT UNSIGNED NULL,
- `operating_account` VARCHAR(40) NULL,
- `property_reserve` DECIMAL(15,0) NULL,
- `lease_term` VARCHAR(15) NULL,
- `country` VARCHAR(40) NULL,
- `street` VARCHAR(40) NULL,
- `City` VARCHAR(40) NULL,
- `State` VARCHAR(40) NULL,
- `ZIP` DECIMAL(15,0) NULL
- ) CHARSET utf8"
- );
+ setupTable('rental_owners', []);
+
+ setupTable('properties', []);
setupIndexes('properties', ['owner',]);
- setupTable(
- 'property_photos', "
- CREATE TABLE IF NOT EXISTS `property_photos` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `property` INT UNSIGNED NULL,
- `photo` VARCHAR(40) NULL,
- `description` TEXT NULL
- ) CHARSET utf8"
- );
+ setupTable('property_photos', []);
setupIndexes('property_photos', ['property',]);
- setupTable(
- 'units', "
- CREATE TABLE IF NOT EXISTS `units` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `property` INT UNSIGNED NULL,
- `unit_number` VARCHAR(40) NULL,
- `photo` VARCHAR(40) NULL,
- `status` VARCHAR(40) NOT NULL,
- `size` VARCHAR(40) NULL,
- `country` INT UNSIGNED NULL,
- `street` INT UNSIGNED NULL,
- `city` INT UNSIGNED NULL,
- `state` INT UNSIGNED NULL,
- `postal_code` INT UNSIGNED NULL,
- `rooms` VARCHAR(40) NULL,
- `bathroom` DECIMAL(15,0) NULL,
- `features` TEXT NULL,
- `market_rent` DECIMAL(15,2) NULL,
- `rental_amount` DECIMAL(10,2) NULL,
- `deposit_amount` DECIMAL(10,2) NULL,
- `description` TEXT NULL
- ) CHARSET utf8"
- );
+ setupTable('units', []);
setupIndexes('units', ['property',]);
- setupTable(
- 'unit_photos', "
- CREATE TABLE IF NOT EXISTS `unit_photos` (
- `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- PRIMARY KEY (`id`),
- `unit` INT UNSIGNED NULL,
- `photo` VARCHAR(40) NULL,
- `description` TEXT NULL
- ) CHARSET utf8"
- );
+ setupTable('unit_photos', []);
setupIndexes('unit_photos', ['unit',]);
+ // set up internal tables
+ setupTable('appgini_query_log', []);
+ setupTable('appgini_csv_import_jobs', []);
+
// save MD5
@file_put_contents($setupHash, $thisMD5);
}
@@ -216,15 +61,17 @@ function setupIndexes($tableName, $arrFields) {
}
- function setupTable($tableName, $createSQL = '', $arrAlter = '') {
+ function setupTable($tableName, $arrAlter = []) {
global $Translation;
$oldTableName = '';
+
+ $createSQL = createTableIfNotExists($tableName, true);
ob_start();
echo '
';
// is there a table rename query?
- if(is_array($arrAlter)) {
+ if(!empty($arrAlter)) {
$matches = [];
if(preg_match("/ALTER TABLE `(.*)` RENAME `$tableName`/i", $arrAlter[0], $matches)) {
$oldTableName = $matches[1];
@@ -234,7 +81,7 @@ function setupTable($tableName, $createSQL = '', $arrAlter = '') {
if($res = @db_query("SELECT COUNT(1) FROM `$tableName`")) { // table already exists
if($row = @db_fetch_array($res)) {
echo str_replace(['', ''], [$tableName, $row[0]], $Translation['table exists']);
- if(is_array($arrAlter)) {
+ if(!empty($arrAlter)) {
echo ' ';
foreach($arrAlter as $alter) {
if($alter != '') {
@@ -267,9 +114,9 @@ function setupTable($tableName, $createSQL = '', $arrAlter = '') {
echo '' . $Translation['ok'] . '';
}
- if(is_array($arrAlter)) setupTable($tableName, $createSQL, false, $arrAlter); // execute Alter queries on renamed table ...
+ if(!empty($arrAlter)) setupTable($tableName, $arrAlter); // execute Alter queries on renamed table ...
} else { // if old tableName doesn't exist (nor the new one since we're here), then just create the table.
- setupTable($tableName, $createSQL, false); // no Alter queries passed ...
+ setupTable($tableName); // no Alter queries passed ...
}
} else { // tableName doesn't exist and no rename, so just create the table
echo str_replace("", $tableName, $Translation["creating table"]);
diff --git a/orpm.axp b/orpm.axp
index 4c39935..fa00a93 100644
--- a/orpm.axp
+++ b/orpm.axp
@@ -1 +1 @@
-rental_property_managerlocalhostUTF-8FalseFalse12FalseAmerica/New_YorkFalseFalseTrueFalsebootstrap.cssTrueTrue03424.132024-05-20 21:55:41C:\Users\micro\vm-shared\appgini-open-source-apps\online-rental-property-manager\app0False402TrueTrueFalseFalse{"events":{"end-of-lease":{"type":"end-of-lease","color":"danger","textColor":"danger","table":"applications_leases","customWhere":"`applications_leases`.`status` = 'Lease'","title":"<b>End of lease</b><br>Property {4} unit# {5}","allDay":true,"startDateField":"end_date","startTimeField":"","endDateField":"","endTimeField":""},"start-of-lease":{"type":"start-of-lease","color":"success","textColor":"success","table":"applications_leases","customWhere":"`applications_leases`.`status` = 'Lease'","title":"<b>Start of lease</b><br>Property {4} unit# {5}","allDay":true,"startDateField":"start_date","startTimeField":"","endDateField":"","endTimeField":""}},"calendars":{"lease-start-end":{"id":"lease-start-end","title":"Leases starting/ending","initial-view":"dayGridMonth","initial-date":"[today]","events":["end-of-lease","start-of-lease"],"locale":"","groups":["Admins"],"links-home":"1","links-navmenu":"1"}}}dummy
12:9:1:4:13:9001:[{"report_hash":"id5fq91qu393nf0k42r1","title":"Applicants By Status","table":"applicants_and_tenants","table_index":0,"label":"status","caption1":"Status","caption2":"Count of Applicants and tenants","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"","look_up_value":"","label_field_index":"13","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"","date_separator":"\/"}][{"label":"Change status","icon":"circle-arrow-right","field":"status","value":"allowUserToSpecify","fixedValue":"","confirmation":1,"groups":[],"hash":"m8xfpspfv9y3762768or"},{"label":"Edit Notes","icon":"pencil","field":"notes","value":"allowUserToSpecify","fixedValue":"","confirmation":1,"groups":[],"hash":"li3ml58uplm5oyp54b8x"}]applicants_and_tenantsFalseFalseTrueFalseFalseTrueFalseTrueTrueTrueTrueTrueTrueFalseTrue
1:3:2:5:7:8:16:9001:[{"report_hash":"rs1tinh2qcc2azdob0r6","title":"Applications\/Leases Over Time","table":"applications_leases","table_index":1,"label":"status","caption1":"Application status","caption2":"Count of Applications\/Leases","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"","look_up_value":"","label_field_index":"3","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":1,"piechart_section":0,"override_permissions":0,"custom_where":"","date_separator":"\/"},{"report_hash":"7dlamlewaen7fh5e7omb","title":"Applications\/Leases By Property","table":"applications_leases","table_index":1,"label":"property","caption1":"Property","caption2":"Count of Applications\/Leases","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"properties","look_up_value":"property_name","label_field_index":"4","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"","date_separator":"\/"},{"report_hash":"uh2omkvwpr1oqfvdt70y","title":"Leases By Property Over Time","table":"applications_leases","table_index":1,"label":"property","caption1":"Property","caption2":"Count of Applications\/Leases","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"properties","look_up_value":"property_name","label_field_index":"4","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"`applications_leases`.`status`='Lease'","date_separator":"\/"},{"report_hash":"lezfr2w8z8mwp5yq26pw","title":"Lease Value By Property Over Time","table":"applications_leases","table_index":1,"label":"property","caption1":"Property","caption2":"Sum of Applications\/Leases","group_function":"sum","group_function_field":"rent","group_array":[],"look_up_table":"properties","look_up_value":"property_name","label_field_index":"4","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"`applications_leases`.`status` LIKE '%lease'","date_separator":"\/"}][{"label":"Approve application","icon":"ok","field":"status","value":"fixedValue","fixedValue":"Lease","confirmation":1,"groups":[],"hash":"ghqe4agakj7de10gc0ba"}]applications_leasesFalseFalseTrueFalseFalseTrueFalseTrueTrueTrueTrueTrueTrueFalseTrue
I understand that this is a routine application to establish credit, character, employment, and rental history.
I also understand that this is NOT an agreement to rent and that all applications must be approved.
I authorize verification of references given.
I declare that the statements above are true and correct, and I agree that the landlord may terminate my agreement entered into in reliance on any misstatement made above.
+rental_property_managerlocalhostUTF-8FalseFalse12FalseAmerica/New_YorkFalseFalseTrueFalsebootstrap.cssTrueTrue03424.142024-06-04 18:41:56C:\Users\micro\vm-shared\appgini-open-source-apps\online-rental-property-manager\app0False402TrueTrueFalseFalse{"events":{"end-of-lease":{"type":"end-of-lease","color":"danger","textColor":"danger","table":"applications_leases","customWhere":"`applications_leases`.`status` = 'Lease'","title":"<b>End of lease</b><br>Property {4} unit# {5}","allDay":true,"startDateField":"end_date","startTimeField":"","endDateField":"","endTimeField":""},"start-of-lease":{"type":"start-of-lease","color":"success","textColor":"success","table":"applications_leases","customWhere":"`applications_leases`.`status` = 'Lease'","title":"<b>Start of lease</b><br>Property {4} unit# {5}","allDay":true,"startDateField":"start_date","startTimeField":"","endDateField":"","endTimeField":""}},"calendars":{"lease-start-end":{"id":"lease-start-end","title":"Leases starting/ending","initial-view":"dayGridMonth","initial-date":"[today]","events":["end-of-lease","start-of-lease"],"locale":"","groups":["Admins"],"links-home":"1","links-navmenu":"1"}}}dummy
12:9:1:4:13:9001:[{"report_hash":"id5fq91qu393nf0k42r1","title":"Applicants By Status","table":"applicants_and_tenants","table_index":0,"label":"status","caption1":"Status","caption2":"Count of Applicants and tenants","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"","look_up_value":"","label_field_index":"13","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"","date_separator":"\/"}][{"label":"Change status","icon":"circle-arrow-right","field":"status","value":"allowUserToSpecify","fixedValue":"","confirmation":1,"groups":[],"hash":"m8xfpspfv9y3762768or"},{"label":"Edit Notes","icon":"pencil","field":"notes","value":"allowUserToSpecify","fixedValue":"","confirmation":1,"groups":[],"hash":"li3ml58uplm5oyp54b8x"}]applicants_and_tenantsFalseFalseTrueFalseFalseTrueFalseTrueTrueTrueTrueTrueTrueFalseTrue
1:3:2:5:7:8:16:9001:[{"report_hash":"rs1tinh2qcc2azdob0r6","title":"Applications\/Leases Over Time","table":"applications_leases","table_index":1,"label":"status","caption1":"Application status","caption2":"Count of Applications\/Leases","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"","look_up_value":"","label_field_index":"3","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":1,"piechart_section":0,"override_permissions":0,"custom_where":"","date_separator":"\/"},{"report_hash":"7dlamlewaen7fh5e7omb","title":"Applications\/Leases By Property","table":"applications_leases","table_index":1,"label":"property","caption1":"Property","caption2":"Count of Applications\/Leases","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"properties","look_up_value":"property_name","label_field_index":"4","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"","date_separator":"\/"},{"report_hash":"uh2omkvwpr1oqfvdt70y","title":"Leases By Property Over Time","table":"applications_leases","table_index":1,"label":"property","caption1":"Property","caption2":"Count of Applications\/Leases","group_function":"count","group_function_field":null,"group_array":[],"look_up_table":"properties","look_up_value":"property_name","label_field_index":"4","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"`applications_leases`.`status`='Lease'","date_separator":"\/"},{"report_hash":"lezfr2w8z8mwp5yq26pw","title":"Lease Value By Property Over Time","table":"applications_leases","table_index":1,"label":"property","caption1":"Property","caption2":"Sum of Applications\/Leases","group_function":"sum","group_function_field":"rent","group_array":[],"look_up_table":"properties","look_up_value":"property_name","label_field_index":"4","date_field":"start_date","date_field_index":"8","report_header_url":"","report_footer_url":"","data_table_section":1,"barchart_section":0,"piechart_section":1,"override_permissions":0,"custom_where":"`applications_leases`.`status` LIKE '%lease'","date_separator":"\/"}][{"label":"Approve application","icon":"ok","field":"status","value":"fixedValue","fixedValue":"Lease","confirmation":1,"groups":[],"hash":"ghqe4agakj7de10gc0ba"}]applications_leasesFalseFalseTrueFalseFalseTrueFalseTrueTrueTrueTrueTrueTrueFalseTrue
I understand that this is a routine application to establish credit, character, employment, and rental history.
I also understand that this is NOT an agreement to rent and that all applications must be approved.
I authorize verification of references given.
I declare that the statements above are true and correct, and I agree that the landlord may terminate my agreement entered into in reliance on any misstatement made above.