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
This commit is contained in:
abijah
2009-05-27 20:54:14 +00:00
parent 6b53d8a25a
commit f4007a0269
2 changed files with 78 additions and 76 deletions

View File

@@ -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 (<SCHEMA>) {
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)<SUM(P.amount),
COALESCE(Ch.total, 0),
SUM(P.amount)) AS rtot
FROM rmgr_transactionpayments P
LEFT JOIN rmgr_transactionReconciliations Rl ON Rl.receipt_id = P.receipt_id
LEFT JOIN rmgr_transactionCharges Ch ON Ch.id = Rl.charge_id
FROM pmgr_payments P
LEFT JOIN pmgr_charges_receipts Rl ON Rl.receipt_id = P.receipt_id
LEFT JOIN pmgr_charges Ch ON Ch.id = Rl.charge_id
GROUP BY P.receipt_id) Rx ON Rx.rid = R.receipt_id
SET R.amount = Rx.rtot";
query($db_handle, $query) || die("Unable to update");
$query ="UPDATE rmgr_transactionReconciliations R
$query ="UPDATE pmgr_charges_receipts R
JOIN (SELECT P.receipt_id AS rid, P.total AS total
FROM rmgr_transactionpayments P
LEFT JOIN rmgr_transactionReconciliations Rl ON Rl.receipt_id = P.receipt_id
FROM pmgr_payments P
LEFT JOIN pmgr_charges_receipts Rl ON Rl.receipt_id = P.receipt_id
GROUP BY P.receipt_id) Rx ON Rx.rid = R.receipt_id
SET R.amount = Rx.rtot";
query($db_handle, $query) || die("Unable to update");
@@ -782,11 +784,11 @@ query($db_handle, $query) || die("Unable to update");
# SELECT Rs.receipt_id, Rs.rsum, Ps.psum, rids, pids
# FROM
# (SELECT receipt_id, SUM(R.amount) AS rsum, CAST(GROUP_CONCAT(id) AS CHAR) AS rids
# FROM rmgr_transactionreconciliations R
# FROM pmgr_charges_receipts R
# GROUP BY receipt_id) Rs
# LEFT JOIN
# (SELECT receipt_id, SUM(P.amount) AS psum, CAST(GROUP_CONCAT(id) AS CHAR) AS pids
# FROM rmgr_transactionpayments P
# FROM pmgr_payments P
# GROUP BY receipt_id) Ps ON Ps.receipt_id = Rs.receipt_id

View File

@@ -7,7 +7,7 @@ class DATABASE_CONFIG {
'host' => 'localhost',
'login' => 'pmgr',
'password' => 'pmgruser',
'database' => 'pmgr',
'database' => 'property_manager',
'prefix' => 'pmgr_',
);
}