Compare commits
2 Commits
jqgrid_3.5
...
statement_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae09d160bb | ||
|
|
4ee9c99e30 |
124
db/schema.sql
@@ -644,17 +644,6 @@ CREATE TABLE `pmgr_customers` (
|
|||||||
-- contacts_customers table?
|
-- contacts_customers table?
|
||||||
`primary_contact_id` INT(10) UNSIGNED NOT NULL,
|
`primary_contact_id` INT(10) UNSIGNED NOT NULL,
|
||||||
|
|
||||||
-- Number of different leases for this customer.
|
|
||||||
-- It's not good to have redundant information,
|
|
||||||
-- but these fields change infrequently, and make
|
|
||||||
-- certain queries much easier, most notably for
|
|
||||||
-- the grid query, in which linking customer to
|
|
||||||
-- lease results in repeated statement entries
|
|
||||||
-- when a customer has more than one lease.
|
|
||||||
`lease_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
|
||||||
`current_lease_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
|
||||||
`past_lease_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0,
|
|
||||||
|
|
||||||
`comment` VARCHAR(255) DEFAULT NULL,
|
`comment` VARCHAR(255) DEFAULT NULL,
|
||||||
|
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
@@ -855,8 +844,8 @@ CREATE TABLE `pmgr_accounts` (
|
|||||||
-- normal circumstances, when a debit occurs.
|
-- normal circumstances, when a debit occurs.
|
||||||
-- `trackable` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
|
-- `trackable` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
|
||||||
`deposits` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for deposits?
|
`deposits` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for deposits?
|
||||||
`invoices` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for invoices?
|
`charges` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for charges?
|
||||||
`receipts` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for receipts?
|
`payments` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for payments?
|
||||||
`refunds` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for refunds?
|
`refunds` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0, -- Can be used for refunds?
|
||||||
|
|
||||||
-- Security Level
|
-- Security Level
|
||||||
@@ -884,21 +873,20 @@ INSERT INTO `pmgr_accounts` (`type`, `name`)
|
|||||||
-- us identify how serious the NSF situation is.
|
-- us identify how serious the NSF situation is.
|
||||||
('ASSET', 'NSF' ),
|
('ASSET', 'NSF' ),
|
||||||
('LIABILITY', 'A/P' );
|
('LIABILITY', 'A/P' );
|
||||||
INSERT INTO `pmgr_accounts` (`type`, `name`, `receipts`, `refunds`)
|
INSERT INTO `pmgr_accounts` (`type`, `name`, `payments`, `refunds`)
|
||||||
VALUES
|
VALUES
|
||||||
('ASSET', 'Cash', 1, 0),
|
('ASSET', 'Cash', 1, 1),
|
||||||
('ASSET', 'Check', 1, 0),
|
('ASSET', 'Check', 1, 0),
|
||||||
('ASSET', 'Money Order', 1, 0),
|
('ASSET', 'Money Order', 1, 0),
|
||||||
('ASSET', 'ACH', 1, 0),
|
('ASSET', 'ACH', 1, 0),
|
||||||
('ASSET', 'Closing', 0, 0), -- REVISIT <AP>: Temporary
|
('ASSET', 'Closing', 0, 0), -- REVISIT <AP>: Temporary
|
||||||
('EXPENSE', 'Concession', 1, 0),
|
('EXPENSE', 'Concession', 1, 0);
|
||||||
('EXPENSE', 'Waiver', 0, 0);
|
|
||||||
INSERT INTO `pmgr_accounts` (`type`, `name`, `refunds`, `deposits`)
|
INSERT INTO `pmgr_accounts` (`type`, `name`, `refunds`, `deposits`)
|
||||||
VALUES
|
VALUES
|
||||||
-- REVISIT <AP>: 20090710 : We probably don't really want petty cash depositable.
|
-- REVISIT <AP>: 20090710 : We probably don't really want petty cash depositable.
|
||||||
-- This is just for testing our deposit code
|
-- This is just for testing our deposit code
|
||||||
('ASSET', 'Petty Cash', 1, 1);
|
('ASSET', 'Petty Cash', 1, 1);
|
||||||
INSERT INTO `pmgr_accounts` (`type`, `name`, `invoices`)
|
INSERT INTO `pmgr_accounts` (`type`, `name`, `charges`)
|
||||||
VALUES
|
VALUES
|
||||||
('LIABILITY', 'Tax', 1),
|
('LIABILITY', 'Tax', 1),
|
||||||
('LIABILITY', 'Security Deposit', 1),
|
('LIABILITY', 'Security Deposit', 1),
|
||||||
@@ -961,19 +949,14 @@ DROP TABLE IF EXISTS `pmgr_transactions`;
|
|||||||
CREATE TABLE `pmgr_transactions` (
|
CREATE TABLE `pmgr_transactions` (
|
||||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
|
||||||
-- REVISIT <AP>: 20090804
|
`type` ENUM('INVOICE',
|
||||||
-- I'm not sure about most of these terms.
|
'RECEIPT',
|
||||||
-- Just as long as they're distinct though... I can rename them later
|
|
||||||
`type` ENUM('INVOICE', -- Sales Invoice
|
|
||||||
'RECEIPT', -- Actual receipt of monies
|
|
||||||
'PURCHASE_INVOICE', -- Committment to pay
|
|
||||||
'CREDIT_NOTE', -- Inverse of Sales Invoice
|
|
||||||
'PAYMENT', -- Actual payment
|
|
||||||
'DEPOSIT',
|
'DEPOSIT',
|
||||||
'CLOSE', -- Essentially an internal (not accounting) transaction
|
'CLOSE',
|
||||||
-- 'CREDIT',
|
-- 'CREDIT',
|
||||||
-- 'REFUND',
|
-- 'REFUND',
|
||||||
'TRANSFER') -- Unsure of TRANSFERs use
|
-- 'WAIVER',
|
||||||
|
'TRANSFER')
|
||||||
NOT NULL,
|
NOT NULL,
|
||||||
|
|
||||||
`stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
`stamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
@@ -998,6 +981,10 @@ CREATE TABLE `pmgr_transactions` (
|
|||||||
-- (e.g. A/R, Bank, etc)
|
-- (e.g. A/R, Bank, etc)
|
||||||
`account_id` INT(10) UNSIGNED DEFAULT NULL,
|
`account_id` INT(10) UNSIGNED DEFAULT NULL,
|
||||||
`ledger_id` INT(10) UNSIGNED DEFAULT NULL,
|
`ledger_id` INT(10) UNSIGNED DEFAULT NULL,
|
||||||
|
|
||||||
|
-- For convenience. Actually, INVOICE will always set crdr
|
||||||
|
-- to DEBIT, RECEIPT will use CREDIT, and DEPOSIT will use
|
||||||
|
-- DEBIT
|
||||||
`crdr` ENUM('DEBIT',
|
`crdr` ENUM('DEBIT',
|
||||||
'CREDIT')
|
'CREDIT')
|
||||||
DEFAULT NULL,
|
DEFAULT NULL,
|
||||||
@@ -1013,9 +1000,9 @@ CREATE TABLE `pmgr_transactions` (
|
|||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- -- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
-- -- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
-- -- TABLE pmgr_ledger_entries
|
-- TABLE pmgr_ledger_entries
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `pmgr_ledger_entries`;
|
DROP TABLE IF EXISTS `pmgr_ledger_entries`;
|
||||||
CREATE TABLE `pmgr_ledger_entries` (
|
CREATE TABLE `pmgr_ledger_entries` (
|
||||||
@@ -1026,6 +1013,9 @@ CREATE TABLE `pmgr_ledger_entries` (
|
|||||||
-- The account/ledger of the entry
|
-- The account/ledger of the entry
|
||||||
`account_id` INT(10) UNSIGNED NOT NULL,
|
`account_id` INT(10) UNSIGNED NOT NULL,
|
||||||
`ledger_id` INT(10) UNSIGNED NOT NULL,
|
`ledger_id` INT(10) UNSIGNED NOT NULL,
|
||||||
|
|
||||||
|
-- For convenience. Actually, CHARGE will always set crdr
|
||||||
|
-- to CREDIT and PAYMENT will use DEBIT.
|
||||||
`crdr` ENUM('DEBIT',
|
`crdr` ENUM('DEBIT',
|
||||||
'CREDIT')
|
'CREDIT')
|
||||||
NOT NULL,
|
NOT NULL,
|
||||||
@@ -1038,9 +1028,9 @@ CREATE TABLE `pmgr_ledger_entries` (
|
|||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- -- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
-- -- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
-- -- TABLE pmgr_double_entries
|
-- TABLE pmgr_double_entries
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `pmgr_double_entries`;
|
DROP TABLE IF EXISTS `pmgr_double_entries`;
|
||||||
CREATE TABLE `pmgr_double_entries` (
|
CREATE TABLE `pmgr_double_entries` (
|
||||||
@@ -1063,35 +1053,27 @@ CREATE TABLE `pmgr_double_entries` (
|
|||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
-- -- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
-- -- ----------------------------------------------------------------------
|
-- ----------------------------------------------------------------------
|
||||||
-- -- TABLE pmgr_statement_entries
|
-- TABLE pmgr_statement_entries
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `pmgr_statement_entries`;
|
DROP TABLE IF EXISTS `pmgr_statement_entries`;
|
||||||
CREATE TABLE `pmgr_statement_entries` (
|
CREATE TABLE `pmgr_statement_entries` (
|
||||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
|
||||||
-- REVISIT <AP>: 20090804
|
`type` ENUM('CHARGE',
|
||||||
-- I'm not sure about most of these terms.
|
'PAYMENT',
|
||||||
-- Just as long as they're distinct though... I can rename them later
|
'SURPLUS',
|
||||||
`type` ENUM('CHARGE', -- Invoiced Charge to Customer
|
|
||||||
'DISBURSEMENT', -- Disbursement of Receipt Funds
|
|
||||||
'REVERSAL', -- Reversal of a charge
|
|
||||||
'WRITEOFF', -- Write-off bad debt
|
|
||||||
'VOUCHER', -- Agreement to pay
|
|
||||||
'PAYMENT', -- Payment of a Voucher
|
|
||||||
'REFUND', -- Payment due to refund
|
|
||||||
'SURPLUS', -- Surplus Receipt Funds
|
|
||||||
'WAIVER', -- Waived Charge
|
|
||||||
-- REVISIT <AP>: 20090730
|
-- REVISIT <AP>: 20090730
|
||||||
-- VOID is used for handling NSF and perhaps charge reversals.
|
-- VOID is just to test out a theory
|
||||||
-- It's not clear this is the best way to handle these things.
|
-- for handling NSF and charge reversals
|
||||||
|
'WAIVE',
|
||||||
'VOID')
|
'VOID')
|
||||||
NOT NULL,
|
NOT NULL,
|
||||||
|
|
||||||
`transaction_id` INT(10) UNSIGNED NOT NULL,
|
`transaction_id` INT(10) UNSIGNED NOT NULL,
|
||||||
|
|
||||||
-- Effective date is when the charge/disbursement/transfer actually
|
-- Effective date is when the charge/payment/transfer actually
|
||||||
-- takes effect (since it may not be at the time of the transaction).
|
-- takes effect (since it may not be at the time of the transaction).
|
||||||
-- Through date is used if/when a charge covers a certain time period,
|
-- Through date is used if/when a charge covers a certain time period,
|
||||||
-- like rent. A security deposit, for example, would not use the
|
-- like rent. A security deposit, for example, would not use the
|
||||||
@@ -1108,15 +1090,12 @@ CREATE TABLE `pmgr_statement_entries` (
|
|||||||
|
|
||||||
`amount` FLOAT(12,2) NOT NULL,
|
`amount` FLOAT(12,2) NOT NULL,
|
||||||
|
|
||||||
-- The account of the entry
|
-- Account ID is used only for those statement entries that have
|
||||||
-- REVISIT <AP>: 20090720
|
-- a guaranteed single ledger entry, and thus single account.
|
||||||
-- We don't want to confuse statement entries with ledger entries,
|
-- Right now, this is only used for charges.
|
||||||
-- yet we're including account here. It doesn't feel right, but at
|
|
||||||
-- the same time, it will allow us to show _what_ was charged for
|
|
||||||
-- in the statement. Keeping it for now...
|
|
||||||
`account_id` INT(10) UNSIGNED DEFAULT NULL,
|
`account_id` INT(10) UNSIGNED DEFAULT NULL,
|
||||||
|
|
||||||
-- Allow the disbursement to reconcile against the charge
|
-- Allow the payment to reconcile against the charge
|
||||||
`charge_entry_id` INT(10) UNSIGNED DEFAULT NULL,
|
`charge_entry_id` INT(10) UNSIGNED DEFAULT NULL,
|
||||||
|
|
||||||
`comment` VARCHAR(255) DEFAULT NULL,
|
`comment` VARCHAR(255) DEFAULT NULL,
|
||||||
@@ -1125,6 +1104,27 @@ CREATE TABLE `pmgr_statement_entries` (
|
|||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
-- ----------------------------------------------------------------------
|
||||||
|
-- TABLE pmgr_statement_entries_ledger_entries
|
||||||
|
-- TABLE pmgr_statement_fractions
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `pmgr_statement_fractions`;
|
||||||
|
CREATE TABLE `pmgr_statement_fractions` (
|
||||||
|
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
|
|
||||||
|
-- The two entries that make up a "double entry"
|
||||||
|
`statement_entry_id` INT(10) UNSIGNED NOT NULL,
|
||||||
|
`ledger_entry_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_tender_types
|
-- TABLE pmgr_tender_types
|
||||||
@@ -1155,12 +1155,6 @@ CREATE TABLE `pmgr_tender_types` (
|
|||||||
`data3_name` VARCHAR(80) DEFAULT NULL,
|
`data3_name` VARCHAR(80) DEFAULT NULL,
|
||||||
`data4_name` VARCHAR(80) DEFAULT NULL,
|
`data4_name` VARCHAR(80) DEFAULT NULL,
|
||||||
|
|
||||||
-- The field from pmgr_tenders that is used for helping
|
|
||||||
-- to name the tender. For example, a Check tender type
|
|
||||||
-- might specify data1 as the field, so that tenders
|
|
||||||
-- would be named "Check #0000"
|
|
||||||
`naming_field` VARCHAR(80) DEFAULT 'id',
|
|
||||||
|
|
||||||
-- When we accept legal tender of this form, where does
|
-- When we accept legal tender of this form, where does
|
||||||
-- it go? Each type of legal tender can specify an
|
-- it go? Each type of legal tender can specify an
|
||||||
-- account, either distinct or non-distinct from others
|
-- account, either distinct or non-distinct from others
|
||||||
|
|||||||
@@ -50,19 +50,19 @@ Operations to be functional
|
|||||||
X - Assess NSF Fees
|
X - Assess NSF Fees
|
||||||
X - Determine Lease Paid-Through status
|
X - Determine Lease Paid-Through status
|
||||||
- Report: List of customers overdue
|
- Report: List of customers overdue
|
||||||
X - Flag unit as overlocked
|
- Flag unit as overlocked
|
||||||
X - Flag unit as evicting
|
- Flag unit as evicting
|
||||||
X - Flag unit as normal status
|
- Flag unit as normal status
|
||||||
X - Flag unit as dirty
|
- Flag unit as dirty
|
||||||
- Enter notes when communicating with Customer
|
- Enter notes when communicating with Customer
|
||||||
X - Accept pre-payments
|
X - Accept pre-payments
|
||||||
X - Record Customer Move-Out from Unit
|
X - Record Customer Move-Out from Unit
|
||||||
X - Record utilization of Security Deposit
|
? - Record utilization of Security Deposit
|
||||||
X - Record issuing of a refund
|
- Record issuing of a refund
|
||||||
- Record Deposit into Petty Cash
|
- Record Deposit into Petty Cash
|
||||||
- Record Payment from Petty Cash to expenses
|
- Record Payment from Petty Cash to expenses
|
||||||
X - Record Petty Cash to refund.
|
- Record Petty Cash to refund.
|
||||||
X - Write Off Bad Debt
|
? - Write Off Bad Debt
|
||||||
X - Perform a Deposit
|
X - Perform a Deposit
|
||||||
X - Close the Books (nightly / weekly, etc)
|
X - Close the Books (nightly / weekly, etc)
|
||||||
X - Determine Rents Collected for a given period.
|
X - Determine Rents Collected for a given period.
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ use Data::Dumper;
|
|||||||
use File::Copy;
|
use File::Copy;
|
||||||
|
|
||||||
my $closing_one_transaction = 0;
|
my $closing_one_transaction = 0;
|
||||||
my $work_from_scratch = 0;
|
|
||||||
|
|
||||||
# Internally adjust all numbers coming from the database to
|
# Internally adjust all numbers coming from the database to
|
||||||
# be in inches. Not necessary to go to this detail, but the
|
# be in inches. Not necessary to go to this detail, but the
|
||||||
@@ -544,19 +543,16 @@ foreach my $tender_name ('Cash', 'Check', 'Money Order', 'ACH',
|
|||||||
) {
|
) {
|
||||||
my ($tillable, $fields) = (0, 0);
|
my ($tillable, $fields) = (0, 0);
|
||||||
my ($name1, $name2, $name3, $name4);
|
my ($name1, $name2, $name3, $name4);
|
||||||
my ($name_field) = ('id');
|
|
||||||
|
|
||||||
$tillable = 1
|
$tillable = 1
|
||||||
if ($tender_name =~ /^Cash|Check|Money Order$/);
|
if ($tender_name =~ /^Cash|Check|Money Order$/);
|
||||||
|
|
||||||
($name1, $name_field) = ('Check Number', 'data1')
|
($name1) = ('Check Number')
|
||||||
if ($tender_name eq 'Check');
|
if ($tender_name eq 'Check');
|
||||||
|
|
||||||
($name1, $name_field) = ('Money Order Number', 'data1')
|
($name1) = ('Money Order Number')
|
||||||
if ($tender_name eq 'Money Order');
|
if ($tender_name eq 'Money Order');
|
||||||
|
|
||||||
# REVISIT <AP>: 20090810
|
|
||||||
# Make data3 be the confirmation number?
|
|
||||||
($name1, $name2) = ('Routing Number', 'Account Number')
|
($name1, $name2) = ('Routing Number', 'Account Number')
|
||||||
if ($tender_name eq 'ACH');
|
if ($tender_name eq 'ACH');
|
||||||
|
|
||||||
@@ -574,7 +570,6 @@ foreach my $tender_name ('Cash', 'Check', 'Money Order', 'ACH',
|
|||||||
'data2_name' => $name2,
|
'data2_name' => $name2,
|
||||||
'data3_name' => $name3,
|
'data3_name' => $name3,
|
||||||
'data4_name' => $name4,
|
'data4_name' => $name4,
|
||||||
'naming_field' => $name_field,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$newdb{'lookup'}{'tender_type'}{$tender_name}
|
$newdb{'lookup'}{'tender_type'}{$tender_name}
|
||||||
@@ -966,7 +961,7 @@ foreach $row (@{query($sdbh, $query)}) {
|
|||||||
'lease_date' => datefmt($row->{'DateIn'}),
|
'lease_date' => datefmt($row->{'DateIn'}),
|
||||||
'movein_date' => datefmt($row->{'DateIn'}),
|
'movein_date' => datefmt($row->{'DateIn'}),
|
||||||
'moveout_date' => datefmt($row->{'DateOut'}),
|
'moveout_date' => datefmt($row->{'DateOut'}),
|
||||||
#'close_date' => datefmt($row->{'DateClosed'}),
|
'close_date' => datefmt($row->{'DateClosed'}),
|
||||||
'rent' => $row->{'Rent'},
|
'rent' => $row->{'Rent'},
|
||||||
#'comment' => "LedgerID: $row->{'LedgerID'}",
|
#'comment' => "LedgerID: $row->{'LedgerID'}",
|
||||||
});
|
});
|
||||||
@@ -1103,6 +1098,17 @@ foreach $row (@{query($sdbh, $query)}) {
|
|||||||
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_entry_id'}
|
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_entry_id'}
|
||||||
= $newdb{'tables'}{'statement_entries'}{'autoid'};
|
= $newdb{'tables'}{'statement_entries'}{'autoid'};
|
||||||
|
|
||||||
|
# Add the Charge Statement Entry Fraction
|
||||||
|
addRow('statement_fractions', {
|
||||||
|
'statement_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_entry_id'},
|
||||||
|
'ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'credit_entry_id'},
|
||||||
|
'amount' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'amount'},
|
||||||
|
#'comment' => "Charge: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}",
|
||||||
|
});
|
||||||
|
|
||||||
|
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_fraction_id'}
|
||||||
|
= $newdb{'tables'}{'statement_fractions'}{'autoid'};
|
||||||
|
|
||||||
next unless $row->{'TaxAmount'};
|
next unless $row->{'TaxAmount'};
|
||||||
|
|
||||||
# # Add the tax charge entry
|
# # Add the tax charge entry
|
||||||
@@ -1210,6 +1216,8 @@ foreach $row (@{query($sdbh, $query)}) {
|
|||||||
= $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'};
|
= $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'};
|
||||||
|
|
||||||
if ($SITELINK_ACCOUNT_TYPE{$row->{'PaymentType'}} eq 'Check') {
|
if ($SITELINK_ACCOUNT_TYPE{$row->{'PaymentType'}} eq 'Check') {
|
||||||
|
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'}
|
||||||
|
= 'Check #' . $row->{'CheckNum'};
|
||||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'data1'}
|
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'data1'}
|
||||||
= $row->{'CheckNum'};
|
= $row->{'CheckNum'};
|
||||||
}
|
}
|
||||||
@@ -1311,13 +1319,19 @@ foreach $row (@{query($sdbh, $query)})
|
|||||||
# 'effective_date' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'effective_date'},
|
# 'effective_date' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'effective_date'},
|
||||||
# 'effective_date' => $effective_date;
|
# 'effective_date' => $effective_date;
|
||||||
# 'through_date' => $through_date;
|
# 'through_date' => $through_date;
|
||||||
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
'lease_id' => ($row->{'entry_type'} eq 'CREDIT'
|
||||||
|
? 0
|
||||||
|
: $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'}),
|
||||||
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
||||||
'amount' => $reconcile_amount,
|
'amount' => $reconcile_amount,
|
||||||
|
|
||||||
'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'},
|
'account_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'},
|
||||||
|
'debit_entry_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_entry_id'},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$row->{'ChargeID'} = undef
|
||||||
|
if $row->{'entry_type'} eq 'CREDIT';
|
||||||
|
|
||||||
# Update the receipt & tender customer_id, now that we have payment info
|
# Update the receipt & tender customer_id, now that we have payment info
|
||||||
$newdb{'tables'}{'transactions'}{'rows'}[
|
$newdb{'tables'}{'transactions'}{'rows'}[
|
||||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'}
|
||||||
@@ -1334,14 +1348,13 @@ foreach $row (@{query($sdbh, $query)})
|
|||||||
# Add the Payment Statement Entry
|
# Add the Payment Statement Entry
|
||||||
addRow('statement_entries', {
|
addRow('statement_entries', {
|
||||||
'transaction_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'},
|
'transaction_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'},
|
||||||
'type' => 'DISBURSEMENT',
|
'type' => $row->{'entry_type'} || 'PAYMENT',
|
||||||
# 'effective_date' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'effective_date'},
|
# 'effective_date' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'effective_date'},
|
||||||
# 'through_date' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'through_date'},
|
# 'through_date' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'through_date'},
|
||||||
'effective_date' => $effective_date,
|
'effective_date' => $effective_date,
|
||||||
'through_date' => $through_date,
|
'through_date' => $through_date,
|
||||||
'customer_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'},
|
'customer_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'},
|
||||||
'lease_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'lease_id'},
|
'lease_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'lease_id'},
|
||||||
'account_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'account_id'},
|
|
||||||
'amount' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'amount'},
|
'amount' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'amount'},
|
||||||
'charge_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_entry_id'},
|
'charge_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'statement_entry_id'},
|
||||||
'comment' => $comment,
|
'comment' => $comment,
|
||||||
@@ -1349,6 +1362,17 @@ foreach $row (@{query($sdbh, $query)})
|
|||||||
|
|
||||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'statement_entry_id'}
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'statement_entry_id'}
|
||||||
= $newdb{'tables'}{'statement_entries'}{'autoid'};
|
= $newdb{'tables'}{'statement_entries'}{'autoid'};
|
||||||
|
|
||||||
|
# Add the Charge Statement Entry Fraction
|
||||||
|
addRow('statement_fractions', {
|
||||||
|
'statement_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'statement_entry_id'},
|
||||||
|
'ledger_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_entry_id'},
|
||||||
|
'amount' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'amount'},
|
||||||
|
});
|
||||||
|
|
||||||
|
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'statement_fraction_id'}
|
||||||
|
= $newdb{'tables'}{'statement_fractions'}{'autoid'};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1469,30 +1493,6 @@ addRow('double_entries', {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
## Debug ... work from scratch
|
|
||||||
if ($work_from_scratch) {
|
|
||||||
# delete $newdb{'tables'}{'contacts'}{'rows'};
|
|
||||||
# delete $newdb{'tables'}{'contacts_methods'}{'rows'};
|
|
||||||
# delete $newdb{'tables'}{'contacts_addresses'}{'rows'};
|
|
||||||
# delete $newdb{'tables'}{'contacts_emails'}{'rows'};
|
|
||||||
# delete $newdb{'tables'}{'contacts_phones'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'contacts_customers'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'customers'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'double_entries'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'leases'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'ledger_entries'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'statement_entries'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'tenders'}{'rows'};
|
|
||||||
delete $newdb{'tables'}{'transactions'}{'rows'};
|
|
||||||
|
|
||||||
foreach (@{$newdb{'tables'}{'units'}{'rows'}}) {
|
|
||||||
$_->{'status'} = 'VACANT'
|
|
||||||
if defined $_ && ($_->{'status'} =~ /^(OCCUPIED)$/ || $_->{'name'} =~ /^Y/);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## Build the Database
|
## Build the Database
|
||||||
|
|
||||||
@@ -1552,21 +1552,6 @@ $query = "UPDATE pmgr_units U, pmgr_leases L
|
|||||||
WHERE L.unit_id = U.id AND L.close_date IS NULL";
|
WHERE L.unit_id = U.id AND L.close_date IS NULL";
|
||||||
query($db_handle, $query);
|
query($db_handle, $query);
|
||||||
|
|
||||||
# All current_lease_counts will be zero at the moment, since
|
|
||||||
# everything was just created. This will update any customers
|
|
||||||
# that have ever leased anything.
|
|
||||||
$query = "UPDATE pmgr_customers C,
|
|
||||||
(SELECT L.customer_id,
|
|
||||||
SUM(IF(L.close_date IS NULL, 1, 0)) AS current,
|
|
||||||
SUM(IF(L.close_date IS NULL, 0, 1)) AS closed
|
|
||||||
FROM pmgr_leases L
|
|
||||||
GROUP BY L.customer_id) AS X
|
|
||||||
SET C.`lease_count` = X.current + X.closed,
|
|
||||||
C.`current_lease_count` = X.current,
|
|
||||||
C.`past_lease_count` = X.closed
|
|
||||||
WHERE X.customer_id = C.id";
|
|
||||||
query($db_handle, $query);
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
## Invoice/Receipt totals
|
## Invoice/Receipt totals
|
||||||
@@ -1578,26 +1563,3 @@ $query = "UPDATE pmgr_transactions T, pmgr_ledger_entries E
|
|||||||
WHERE E.transaction_id = T.id AND E.account_id = T.account_id";
|
WHERE E.transaction_id = T.id AND E.account_id = T.account_id";
|
||||||
query($db_handle, $query);
|
query($db_handle, $query);
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
## Tender Names
|
|
||||||
|
|
||||||
print("Set Tender Names...\n");
|
|
||||||
|
|
||||||
$query = "UPDATE pmgr_tenders T, pmgr_tender_types TT
|
|
||||||
SET T.`name` = CONCAT(T.`name`, ' #',
|
|
||||||
IF(T.tender_type_id IN (2,3), T.data1, T.id))
|
|
||||||
WHERE T.tender_type_id IS NULL OR TT.id = T.tender_type_id";
|
|
||||||
query($db_handle, $query);
|
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
|
||||||
## Invoice date fixes
|
|
||||||
|
|
||||||
# print("Fix Invoice Dates...\n");
|
|
||||||
|
|
||||||
# $query = "UPDATE pmgr_transactions T, pmgr_statement_entries E
|
|
||||||
# SET T.`stamp` =
|
|
||||||
# WHERE E.transaction_id = T.id AND E.account_id = T.account_id";
|
|
||||||
# query($db_handle, $query);
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,14 +46,11 @@ class AppController extends Controller {
|
|||||||
array('name' => 'Leases', 'url' => array('controller' => 'leases', 'action' => 'index')),
|
array('name' => 'Leases', 'url' => array('controller' => 'leases', 'action' => 'index')),
|
||||||
array('name' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index')),
|
array('name' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index')),
|
||||||
array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index')),
|
array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index')),
|
||||||
array('name' => 'Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit')),
|
|
||||||
array('name' => 'Debug', 'header' => true),
|
array('name' => 'Debug', 'header' => true),
|
||||||
array('name' => 'Un-Nuke', 'url' => '#', 'htmlAttributes' =>
|
|
||||||
array('onclick' => '$(".pr-section").show(); return false;')),
|
|
||||||
array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index')),
|
array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index')),
|
||||||
array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index')),
|
array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index')),
|
||||||
//array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')),
|
array('name' => 'New Ledgers', 'url' => array('controller' => 'accounts', 'action' => 'newledger')),
|
||||||
//array('name' => 'RESET DATA', 'url' => array('controller' => 'accounts', 'action' => 'reset_data')),
|
array('name' => 'RESET DATA', 'url' => array('controller' => 'accounts', 'action' => 'reset_data')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,26 +187,17 @@ class AppController extends Controller {
|
|||||||
// This SHOULD always be set, except when debugging
|
// This SHOULD always be set, except when debugging
|
||||||
if (isset($params['post']))
|
if (isset($params['post']))
|
||||||
$params['post'] = unserialize($params['post']);
|
$params['post'] = unserialize($params['post']);
|
||||||
else
|
|
||||||
$params['post'] = array();
|
|
||||||
|
|
||||||
// Unserialize our complex structure of dynamic post data
|
// Unserialize our complex structure of dynamic post data
|
||||||
if (isset($params['dynamic_post']))
|
if (isset($params['dynamic_post']))
|
||||||
$params['dynamic_post'] = unserialize($params['dynamic_post']);
|
$params['dynamic_post'] = unserialize($params['dynamic_post']);
|
||||||
else
|
|
||||||
$params['dynamic_post'] = null;
|
|
||||||
|
|
||||||
// Unserialize our complex structure of dynamic post data
|
|
||||||
if (isset($params['dynamic_post_replace']))
|
|
||||||
$params['dynamic_post_replace'] = unserialize($params['dynamic_post_replace']);
|
|
||||||
else
|
|
||||||
$params['dynamic_post_replace'] = null;
|
|
||||||
|
|
||||||
// Merge the static and dynamic post data
|
// Merge the static and dynamic post data
|
||||||
if (!empty($params['dynamic_post']))
|
if (empty($params['post']) && !empty($params['dynamic_post']))
|
||||||
|
$params['post'] = $params['dynamic_post'];
|
||||||
|
elseif (!empty($params['post']) && !empty($params['dynamic_post']))
|
||||||
|
//$params['post'] = array_merge($params['post'], $params['dynamic_post']);
|
||||||
$params['post'] = array_merge_recursive($params['post'], $params['dynamic_post']);
|
$params['post'] = array_merge_recursive($params['post'], $params['dynamic_post']);
|
||||||
if (!empty($params['dynamic_post_replace']))
|
|
||||||
$params['post'] = array_merge($params['post'], $params['dynamic_post_replace']);
|
|
||||||
|
|
||||||
// This SHOULD always be set, except when debugging
|
// This SHOULD always be set, except when debugging
|
||||||
if (!isset($params['post']['fields']))
|
if (!isset($params['post']['fields']))
|
||||||
@@ -692,7 +680,7 @@ class AppController extends Controller {
|
|||||||
|
|
||||||
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
||||||
// Don't create any links if ordered not to.
|
// Don't create any links if ordered not to.
|
||||||
if (isset($params['post']['nolinks']))
|
if (isset($params['nolinks']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach ($links AS $table => $fields) {
|
foreach ($links AS $table => $fields) {
|
||||||
|
|||||||
@@ -114,48 +114,20 @@ class AppModel extends Model {
|
|||||||
$line = $caller['line'];
|
$line = $caller['line'];
|
||||||
|
|
||||||
// So, this caller holds the calling function name
|
// So, this caller holds the calling function name
|
||||||
$caller = $trace[0];
|
$caller = array_shift($trace);
|
||||||
$function = $caller['function'];
|
$function = $caller['function'];
|
||||||
$class = $caller['class'];
|
$class = $caller['class'];
|
||||||
//$class = $this->name;
|
//$class = $this->name;
|
||||||
|
|
||||||
// Use class or function specific log level if available
|
// Adjust the log level from default, if necessary
|
||||||
if (isset($this->class_log_level[$class]))
|
if (isset($this->class_log_level[$class]))
|
||||||
$log_level = $this->class_log_level[$class];
|
$log_level = $this->class_log_level[$class];
|
||||||
if (isset($this->function_log_level["{$class}-{$function}"]))
|
if (isset($this->function_log_level["{$class}-{$function}"]))
|
||||||
$log_level = $this->function_log_level["{$class}-{$function}"];
|
$log_level = $this->function_log_level["{$class}-{$function}"];
|
||||||
|
if (isset($this->min_log_level))
|
||||||
// Establish log level minimums
|
$log_level = max($log_level, $this->min_log_level);
|
||||||
$min_log_level = $this->min_log_level;
|
if (isset($this->max_log_level))
|
||||||
if (is_array($this->min_log_level)) {
|
$log_level = min($log_level, $this->max_log_level);
|
||||||
$min_show_level = $min_log_level['show'];
|
|
||||||
$min_log_level = $min_log_level['log'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establish log level maximums
|
|
||||||
$max_log_level = $this->max_log_level;
|
|
||||||
if (is_array($this->max_log_level)) {
|
|
||||||
$max_show_level = $max_log_level['show'];
|
|
||||||
$max_log_level = $max_log_level['log'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine the applicable log and show levels
|
|
||||||
if (is_array($log_level)) {
|
|
||||||
$show_level = $log_level['show'];
|
|
||||||
$log_level = $log_level['log'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust log level up/down to min/max
|
|
||||||
if (isset($min_log_level))
|
|
||||||
$log_level = max($log_level, $min_log_level);
|
|
||||||
if (isset($max_log_level))
|
|
||||||
$log_level = min($log_level, $max_log_level);
|
|
||||||
|
|
||||||
// Adjust show level up/down to min/max
|
|
||||||
if (isset($min_show_level))
|
|
||||||
$show_level = max($show_level, $min_show_level);
|
|
||||||
if (isset($max_show_level))
|
|
||||||
$show_level = min($show_level, $max_show_level);
|
|
||||||
|
|
||||||
// If the level is insufficient, bail out
|
// If the level is insufficient, bail out
|
||||||
if ($level > $log_level)
|
if ($level > $log_level)
|
||||||
@@ -169,87 +141,13 @@ class AppModel extends Model {
|
|||||||
$mixed = $chk + array($mixed);
|
$mixed = $chk + array($mixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static $pr_unique_number = 0;
|
echo '<DIV CLASS="pr-caller">';
|
||||||
$pr_id = 'pr-section-class-' . $class . '-print-' . (++$pr_unique_number);
|
echo '<strong>' . substr(str_replace(ROOT, '', $file), 1) . '</strong>';
|
||||||
$pr_trace_id = $pr_id . '-trace';
|
echo ' (line <strong>' . $line . '</strong>)';
|
||||||
$pr_output_id = $pr_id . '-output';
|
echo ' : level-' . $level;
|
||||||
|
echo '</DIV>' . "\n";
|
||||||
|
|
||||||
$pr_entire_base_class = "pr-section";
|
pr(array("{$class}::{$function}()" => $mixed), false, false);
|
||||||
$pr_entire_class_class = $pr_entire_base_class . '-class-' . $class;
|
|
||||||
$pr_entire_function_class = $pr_entire_class_class . '-function-' . $function;
|
|
||||||
$pr_entire_class = "$pr_entire_base_class $pr_entire_class_class $pr_entire_function_class";
|
|
||||||
$pr_header_class = "pr-caller";
|
|
||||||
$pr_trace_class = "pr-trace";
|
|
||||||
$pr_output_base_class = 'pr-output';
|
|
||||||
$pr_output_class_class = $pr_output_base_class . '-class-' . $class;
|
|
||||||
$pr_output_function_class = $pr_output_class_class . '-function-' . $function;
|
|
||||||
$pr_output_class = "$pr_output_base_class $pr_output_class_class $pr_output_function_class";
|
|
||||||
|
|
||||||
echo '<DIV class="'.$pr_entire_class.'" id="'.$pr_id.'">'."\n";
|
|
||||||
echo '<DIV class="'.$pr_header_class.'">'."\n";
|
|
||||||
echo '<DIV class="'.$pr_trace_class.'" id="'.$pr_trace_id.'" style="display:none;">'."\n";
|
|
||||||
echo '<HR />' . "\n";
|
|
||||||
|
|
||||||
// Flip trace around so the sequence flows from top to bottom
|
|
||||||
// Then print out the entire stack trace (in hidden div)
|
|
||||||
$trace = array_reverse($trace);
|
|
||||||
for ($i = 0; $i < count($trace); ++$i) {
|
|
||||||
$bline = $trace[$i]['line'];
|
|
||||||
$bfile = $trace[$i]['file'];
|
|
||||||
$bfile = str_replace(ROOT.DS, '', $bfile);
|
|
||||||
$bfile = str_replace(CAKE_CORE_INCLUDE_PATH.DS, '', $bfile);
|
|
||||||
|
|
||||||
if ($i > 0) {
|
|
||||||
$bfunc = $trace[$i-1]['function'];
|
|
||||||
$bclas = $trace[$i-1]['class'];
|
|
||||||
} else {
|
|
||||||
$bfunc = null;
|
|
||||||
$bclas = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo("$bfile:$bline (" . ($bclas ? "$bclas::$bfunc" : "entry point") . ")<BR>\n");
|
|
||||||
//echo(($bclas ? "$bclas::$bfunc" : "entry point") . "; $bfile : $bline<BR>\n");
|
|
||||||
}
|
|
||||||
echo '</DIV>' . "\n"; // End pr_trace_class
|
|
||||||
$file = str_replace(ROOT.DS, '', $file);
|
|
||||||
$file = str_replace(CAKE_CORE_INCLUDE_PATH.DS, '', $file);
|
|
||||||
|
|
||||||
echo "<strong>$file:$line ($class::$function)</strong>" . ";\n";
|
|
||||||
/* $log_show_level = isset($show_level) ? $show_level : '?'; */
|
|
||||||
/* echo ' L' . $level . "({$log_level}/{$log_show_level})" . ";\n"; */
|
|
||||||
echo ' L' . $level . ";\n";
|
|
||||||
echo ' <A HREF="#" onclick="$' . "('#{$pr_trace_id}').slideToggle(); return false;" . '">stack</A>'.";\n";
|
|
||||||
|
|
||||||
echo " this ";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('#{$pr_output_id}').slideToggle(); return false;" . '">t</A>'."/";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('#{$pr_id}').hide(); return false;" . '">n</A>'.";\n";
|
|
||||||
|
|
||||||
echo " $class ";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_output_class_class}').slideDown(); return false;" . '">s</A>'."/";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_output_class_class}').slideUp(); return false;" . '">h</A>'."/";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_entire_class_class}').hide(); return false;" . '">n</A>'.";\n";
|
|
||||||
|
|
||||||
echo " $function ";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_output_function_class}').slideDown(); return false;" . '">s</A>'."/";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_output_function_class}').slideUp(); return false;" . '">h</A>'."/";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_entire_function_class}').hide(); return false;" . '">n</A>'.";\n";
|
|
||||||
|
|
||||||
echo " all ";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_output_base_class}').show(); return false;" . '">s</A>'."/";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_output_base_class}').hide(); return false;" . '">h</A>'."/";
|
|
||||||
echo '<A HREF="#" onclick="$' . "('.{$pr_entire_base_class}').hide(); return false;" . '">n</A>'."\n";
|
|
||||||
|
|
||||||
echo '</DIV>' . "\n"; // End pr_header_class
|
|
||||||
|
|
||||||
if (isset($show_level) && $level > $show_level)
|
|
||||||
$display = 'none';
|
|
||||||
else
|
|
||||||
$display = 'block';
|
|
||||||
|
|
||||||
echo '<DIV class="'.$pr_output_class.'" id="'.$pr_output_id.'" style="display:'.$display.';">'."\n";
|
|
||||||
pr($mixed, false, false);
|
|
||||||
echo '</DIV>' . "\n"; // End pr_output_class
|
|
||||||
echo '</DIV>' . "\n"; // End pr_entire_class
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pr($level, $mixed, $checkpoint = null) {
|
function pr($level, $mixed, $checkpoint = null) {
|
||||||
|
|||||||
@@ -31,39 +31,6 @@
|
|||||||
* You can also use this to include or require any files in your application.
|
* You can also use this to include or require any files in your application.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function INTERNAL_ERROR($message) {
|
|
||||||
echo '<DIV class="internal-error" style="color:#000; background:#c22; padding:0.5em 1.5em 0.5em 1.5em;">';
|
|
||||||
echo '<H1 style="margin-bottom:0.2em">INTERNAL ERROR:</H1>';
|
|
||||||
echo '<H2 style="margin-top:0; margin-left:1.5em">' . $message . '</H2>';
|
|
||||||
echo '<H4>This error was not caused by anything that you did wrong.';
|
|
||||||
echo '<BR>It is a problem within the application itself and should be reported to the administrator.</H4>';
|
|
||||||
|
|
||||||
// Print out the entire stack trace
|
|
||||||
echo "<HR>Stack Trace:<OL>";
|
|
||||||
$trace = debug_backtrace(false);
|
|
||||||
for ($i = 0; $i < count($trace); ++$i) {
|
|
||||||
$bline = $trace[$i]['line'];
|
|
||||||
$bfile = $trace[$i]['file'];
|
|
||||||
$bfile = str_replace(ROOT.DS, '', $bfile);
|
|
||||||
$bfile = str_replace(CAKE_CORE_INCLUDE_PATH.DS, '', $bfile);
|
|
||||||
|
|
||||||
if ($i < count($trace)-1) {
|
|
||||||
$bfunc = $trace[$i+1]['function'];
|
|
||||||
$bclas = $trace[$i+1]['class'];
|
|
||||||
} else {
|
|
||||||
$bfunc = null;
|
|
||||||
$bclas = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo("<LI>$bfile:$bline (" . ($bclas ? "$bclas::$bfunc" : "entry point") . ")</LI>\n");
|
|
||||||
}
|
|
||||||
echo '</OL>';
|
|
||||||
|
|
||||||
echo '</DIV>';
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The settings below can be used to set additional paths to models, views and controllers.
|
* The settings below can be used to set additional paths to models, views and controllers.
|
||||||
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
|
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ class AccountsController extends AppController {
|
|||||||
array('name' => 'Equity', 'url' => array('controller' => 'accounts', 'action' => 'equity')),
|
array('name' => 'Equity', 'url' => array('controller' => 'accounts', 'action' => 'equity')),
|
||||||
array('name' => 'Income', 'url' => array('controller' => 'accounts', 'action' => 'income')),
|
array('name' => 'Income', 'url' => array('controller' => 'accounts', 'action' => 'income')),
|
||||||
array('name' => 'Expense', 'url' => array('controller' => 'accounts', 'action' => 'expense')),
|
array('name' => 'Expense', 'url' => array('controller' => 'accounts', 'action' => 'expense')),
|
||||||
|
array('name' => 'Deposits', 'header' => true),
|
||||||
|
array('name' => 'Prior Deposits', 'url' => array('controller' => 'transactions', 'action' => 'deposit')),
|
||||||
|
array('name' => 'New Deposit', 'url' => array('controller' => 'tenders', 'action' => 'deposit')),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -135,18 +138,17 @@ class AccountsController extends AppController {
|
|||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Account->recursive = -1;
|
|
||||||
$account = $this->Account->read(null, $id);
|
|
||||||
$account = $account['Account'];
|
|
||||||
|
|
||||||
$payment_accounts = $this->Account->collectableAccounts();
|
$payment_accounts = $this->Account->collectableAccounts();
|
||||||
//$payment_accounts[$this->Account->nameToID('Closing')] = 'Closing';
|
//$payment_accounts[$this->Account->nameToID('Closing')] = 'Closing';
|
||||||
//$payment_accounts[$this->Account->nameToID('Equity')] = 'Equity';
|
//$payment_accounts[$this->Account->nameToID('Equity')] = 'Equity';
|
||||||
//$payment_accounts[$id] = 'Reversals';
|
$default_accounts = array_diff_key($this->Account->paymentAccounts(),
|
||||||
$default_accounts = array_diff_key($this->Account->receiptAccounts(),
|
|
||||||
array($this->Account->concessionAccountID() => 1));
|
array($this->Account->concessionAccountID() => 1));
|
||||||
$this->set(compact('payment_accounts', 'default_accounts'));
|
$this->set(compact('payment_accounts', 'default_accounts'));
|
||||||
|
|
||||||
|
$this->Account->recursive = -1;
|
||||||
|
$account = $this->Account->read(null, $id);
|
||||||
|
$account = $account['Account'];
|
||||||
|
|
||||||
$title = ($account['name'] . ': Collected Report');
|
$title = ($account['name'] . ': Collected Report');
|
||||||
$this->set(compact('account', 'title'));
|
$this->set(compact('account', 'title'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class CustomersController extends AppController {
|
|||||||
('link' =>
|
('link' =>
|
||||||
array(// Models
|
array(// Models
|
||||||
'PrimaryContact',
|
'PrimaryContact',
|
||||||
|
'CurrentLease' => array('fields' => array()),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -63,19 +64,19 @@ class CustomersController extends AppController {
|
|||||||
|
|
||||||
function gridDataFields(&$params, &$model) {
|
function gridDataFields(&$params, &$model) {
|
||||||
$fields = parent::gridDataFields($params, $model);
|
$fields = parent::gridDataFields($params, $model);
|
||||||
|
$fields[] = ('COUNT(DISTINCT CurrentLease.id) AS lease_count');
|
||||||
return array_merge($fields,
|
return array_merge($fields,
|
||||||
$this->Customer->StatementEntry->chargeDisbursementFields(true));
|
$this->Customer->StatementEntry->chargePaymentFields(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function gridDataConditions(&$params, &$model) {
|
function gridDataConditions(&$params, &$model) {
|
||||||
$conditions = parent::gridDataConditions($params, $model);
|
$conditions = parent::gridDataConditions($params, $model);
|
||||||
|
|
||||||
if ($params['action'] === 'current') {
|
if ($params['action'] === 'current') {
|
||||||
$conditions[] = array('Customer.current_lease_count >' => 0);
|
$conditions[] = 'CurrentLease.id IS NOT NULL';
|
||||||
}
|
}
|
||||||
elseif ($params['action'] === 'past') {
|
elseif ($params['action'] === 'past') {
|
||||||
$conditions[] = array('Customer.current_lease_count' => 0);
|
$conditions[] = 'CurrentLease.id IS NULL';
|
||||||
$conditions[] = array('Customer.past_lease_count >' => 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $conditions;
|
return $conditions;
|
||||||
@@ -98,6 +99,30 @@ class CustomersController extends AppController {
|
|||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gridDataCount(&$params, &$model) {
|
||||||
|
|
||||||
|
if ($params['action'] != 'current')
|
||||||
|
return parent::gridDataCount($params, $model);
|
||||||
|
|
||||||
|
// OK, for current customers, we have an issue.
|
||||||
|
// We don't have a good way to use the query to obtain
|
||||||
|
// our count. The problem is that we're relying on the
|
||||||
|
// group by for the query, but that simply won't work
|
||||||
|
// for the count. However, it's not difficult to simply
|
||||||
|
// derive it since 'current' customers are mutually
|
||||||
|
// exclusive to 'past' customers.
|
||||||
|
|
||||||
|
$tmp_params = $params;
|
||||||
|
$tmp_params['action'] = 'all';
|
||||||
|
$all_count = parent::gridDataCount($tmp_params, $model);
|
||||||
|
$tmp_params['action'] = 'past';
|
||||||
|
$past_count = parent::gridDataCount($tmp_params, $model);
|
||||||
|
|
||||||
|
// The current customer count is simply calculated
|
||||||
|
// as all customers that are not past customers.
|
||||||
|
return $all_count - $past_count;
|
||||||
|
}
|
||||||
|
|
||||||
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
||||||
$links['Customer'] = array('name');
|
$links['Customer'] = array('name');
|
||||||
return parent::gridDataPostProcessLinks($params, $model, $records, $links);
|
return parent::gridDataPostProcessLinks($params, $model, $records, $links);
|
||||||
@@ -178,44 +203,17 @@ class CustomersController extends AppController {
|
|||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get details on this customer, its contacts and leases
|
/* //$result = $this->Customer->securityDeposits($id); */
|
||||||
$customer = $this->Customer->find
|
/* $result = $this->Customer->excessPayments($id); */
|
||||||
('first', array
|
/* //$result = $this->Customer->unreconciledCharges($id); */
|
||||||
('contain' => array
|
/* echo('<HR>'); */
|
||||||
(// Models
|
/* pr($result); */
|
||||||
'Contact' =>
|
/* $this->autoRender = false; */
|
||||||
array('order' => array('Contact.display_name'),
|
/* return; */
|
||||||
// Models
|
|
||||||
'ContactPhone',
|
|
||||||
'ContactEmail',
|
|
||||||
'ContactAddress',
|
|
||||||
),
|
|
||||||
'Lease' =>
|
|
||||||
array('Unit' =>
|
|
||||||
array('order' => array('sort_order'),
|
|
||||||
'fields' => array('id', 'name'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
'conditions' => array('Customer.id' => $id),
|
$customer = $this->Customer->details($id);
|
||||||
));
|
|
||||||
//pr($customer);
|
//pr($customer);
|
||||||
|
$outstanding_balance = $customer['stats']['balance'];
|
||||||
// Determine how long this customer has been with us.
|
|
||||||
$leaseinfo = $this->Customer->find
|
|
||||||
('first', array
|
|
||||||
('link' => array('Lease' => array('fields' => array())),
|
|
||||||
'fields' => array('MIN(Lease.movein_date) AS since',
|
|
||||||
'IF(Customer.current_lease_count = 0, MAX(Lease.moveout_date), NULL) AS until'),
|
|
||||||
'conditions' => array('Customer.id' => $id),
|
|
||||||
'group' => 'Customer.id',
|
|
||||||
));
|
|
||||||
$this->set($leaseinfo[0]);
|
|
||||||
|
|
||||||
// Figure out the outstanding balances for this customer
|
|
||||||
//$this->set('stats', $this->Customer->stats($id));
|
|
||||||
$outstanding_balance = $this->Customer->balance($id);
|
|
||||||
$outstanding_deposit = $this->Customer->securityDepositBalance($id);
|
$outstanding_deposit = $this->Customer->securityDepositBalance($id);
|
||||||
|
|
||||||
// Figure out if this customer has any non-closed leases
|
// Figure out if this customer has any non-closed leases
|
||||||
@@ -249,22 +247,12 @@ class CustomersController extends AppController {
|
|||||||
/* $id)); */
|
/* $id)); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
if ($show_payment || $outstanding_balance > 0)
|
if ($show_payment) {
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'New Receipt',
|
array('name' => 'Payment',
|
||||||
'url' => array('action' => 'receipt',
|
'url' => array('action' => 'receipt',
|
||||||
$id));
|
$id));
|
||||||
|
}
|
||||||
if (!$show_moveout && $outstanding_balance > 0)
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Write-Off',
|
|
||||||
'url' => array('action' => 'bad_debt',
|
|
||||||
$id));
|
|
||||||
|
|
||||||
if ($outstanding_balance < 0)
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Issue Refund',
|
|
||||||
'url' => array('action' => 'refund', $id));
|
|
||||||
|
|
||||||
// Prepare to render.
|
// Prepare to render.
|
||||||
$title = 'Customer: ' . $customer['Customer']['name'];
|
$title = 'Customer: ' . $customer['Customer']['name'];
|
||||||
@@ -400,7 +388,7 @@ class CustomersController extends AppController {
|
|||||||
$default_type = $TT->defaultPaymentType();
|
$default_type = $TT->defaultPaymentType();
|
||||||
$this->set(compact('payment_types', 'default_type'));
|
$this->set(compact('payment_types', 'default_type'));
|
||||||
|
|
||||||
$title = ($customer['name'] . ': Receipt Entry');
|
$title = ($customer['name'] . ': Payment Entry');
|
||||||
$this->set(compact('customer', 'charges', 'stats', 'title'));
|
$this->set(compact('customer', 'charges', 'stats', 'title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,64 +400,18 @@ class CustomersController extends AppController {
|
|||||||
* - Refunds customer charges
|
* - Refunds customer charges
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function refund($id) {
|
function refund() {
|
||||||
$customer = $this->Customer->find
|
$entries = $this->Customer->StatementEntry->find
|
||||||
('first', array
|
('all', array
|
||||||
('contain' => false,
|
('contain' => false,
|
||||||
'conditions' => array(array('Customer.id' => $id),
|
'conditions' => array('StatementEntry.id' =>
|
||||||
|
//array(199,200,201)
|
||||||
|
61
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
if (empty($customer)) {
|
pr(compact('entries'));
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine the customer balance, bailing if the customer owes money
|
$this->Customer->StatementEntry->reverse($entries);
|
||||||
$balance = $this->Customer->balance($id);
|
|
||||||
if ($balance >= 0) {
|
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The refund will be for a positive amount
|
|
||||||
$balance *= -1;
|
|
||||||
|
|
||||||
// Get the accounts capable of paying the refund
|
|
||||||
$refundAccounts = $this->Customer->StatementEntry->Account->refundAccounts();
|
|
||||||
$defaultAccount = current($refundAccounts);
|
|
||||||
$this->set(compact('refundAccounts', 'defaultAccount'));
|
|
||||||
|
|
||||||
// Prepare to render
|
|
||||||
$title = ($customer['Customer']['name'] . ': Refund');
|
|
||||||
$this->set(compact('title', 'customer', 'balance'));
|
|
||||||
$this->render('/transactions/refund');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: bad_debt
|
|
||||||
* - Sets up the write-off entry page, so that the
|
|
||||||
* user can write off remaining charges of a customer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function bad_debt($id) {
|
|
||||||
$this->Customer->id = $id;
|
|
||||||
$customer = $this->Customer->find
|
|
||||||
('first', array
|
|
||||||
('contain' => false,
|
|
||||||
));
|
|
||||||
|
|
||||||
// Make sure we have a valid customer to write off
|
|
||||||
if (empty($customer))
|
|
||||||
$this->redirect(array('action' => 'index'));
|
|
||||||
|
|
||||||
// Get the customer balance
|
|
||||||
$balance = $this->Customer->balance($id);
|
|
||||||
|
|
||||||
// Prepare to render
|
|
||||||
$title = ($customer['Customer']['name'] . ': Write Off Bad Debt');
|
|
||||||
$this->set(compact('title', 'customer', 'balance'));
|
|
||||||
$this->render('/transactions/bad_debt');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -486,8 +428,8 @@ class CustomersController extends AppController {
|
|||||||
$this->layout = null;
|
$this->layout = null;
|
||||||
$this->autoLayout = false;
|
$this->autoLayout = false;
|
||||||
$this->autoRender = false;
|
$this->autoRender = false;
|
||||||
Configure::write('debug', '0');
|
//Configure::write('debug', '0');
|
||||||
header("Content-type: text/xml;charset=utf-8");
|
//header("Content-type: text/xml;charset=utf-8");
|
||||||
|
|
||||||
App::import('Helper', 'Xml');
|
App::import('Helper', 'Xml');
|
||||||
$xml = new XmlHelper();
|
$xml = new XmlHelper();
|
||||||
@@ -495,22 +437,16 @@ class CustomersController extends AppController {
|
|||||||
// Find the unreconciled entries, then manipulate the structure
|
// Find the unreconciled entries, then manipulate the structure
|
||||||
// slightly to accomodate the format necessary for XML Helper.
|
// slightly to accomodate the format necessary for XML Helper.
|
||||||
$unreconciled = $this->Customer->unreconciledCharges($id);
|
$unreconciled = $this->Customer->unreconciledCharges($id);
|
||||||
|
|
||||||
foreach ($unreconciled['entries'] AS &$entry)
|
|
||||||
$entry = array_intersect_key($entry['StatementEntry'],
|
|
||||||
array('id'=>1));
|
|
||||||
|
|
||||||
$unreconciled = array('entries' =>
|
$unreconciled = array('entries' =>
|
||||||
array('entry' => $unreconciled['entries'],
|
array_intersect_key($unreconciled['debit'],
|
||||||
'balance' => $unreconciled['summary']['balance']));
|
array('entry'=>1, 'balance'=>1)));
|
||||||
|
|
||||||
// XML Helper will dump an empty tag if the array is empty
|
// XML Helper will dump an empty tag if the array is empty
|
||||||
if (empty($unreconciled['entries']['entry']))
|
if (!count($unreconciled['entries']['entry']))
|
||||||
unset($unreconciled['entries']['entry']);
|
unset($unreconciled['entries']['entry']);
|
||||||
|
|
||||||
/* pr(compact('unreconciled')); */
|
//pr($unreconciled);
|
||||||
/* echo htmlspecialchars($xml->serialize($unreconciled)); */
|
//$reconciled = $cust->reconcileNewStatementEntry($cust_id, 'credit', $amount);
|
||||||
/* $this->render('/fake'); */
|
|
||||||
|
|
||||||
$opts = array();
|
$opts = array();
|
||||||
//$opts['format'] = 'tags';
|
//$opts['format'] = 'tags';
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class LeasesController extends AppController {
|
|||||||
function gridDataFields(&$params, &$model) {
|
function gridDataFields(&$params, &$model) {
|
||||||
$fields = parent::gridDataFields($params, $model);
|
$fields = parent::gridDataFields($params, $model);
|
||||||
return array_merge($fields,
|
return array_merge($fields,
|
||||||
$this->Lease->StatementEntry->chargeDisbursementFields(true));
|
$this->Lease->StatementEntry->chargePaymentFields(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function gridDataConditions(&$params, &$model) {
|
function gridDataConditions(&$params, &$model) {
|
||||||
@@ -135,22 +135,17 @@ class LeasesController extends AppController {
|
|||||||
|
|
||||||
// Handle the move in based on the data given
|
// Handle the move in based on the data given
|
||||||
//pr(array('Move-in data', $this->data));
|
//pr(array('Move-in data', $this->data));
|
||||||
foreach (array('deposit', 'rent') AS $currency) {
|
|
||||||
$this->data['Lease'][$currency]
|
|
||||||
= str_replace('$', '', $this->data['Lease'][$currency]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$lid = $this->Lease->moveIn($this->data['Lease']['customer_id'],
|
$lid = $this->Lease->moveIn($this->data['Lease']['customer_id'],
|
||||||
$this->data['Lease']['unit_id'],
|
$this->data['Lease']['unit_id'],
|
||||||
$this->data['Lease']['deposit'],
|
null, null,
|
||||||
$this->data['Lease']['rent'],
|
|
||||||
$this->data['Lease']['movein_date'],
|
$this->data['Lease']['movein_date'],
|
||||||
$this->data['Lease']['comment']
|
$this->data['Lease']['comment']
|
||||||
);
|
);
|
||||||
|
|
||||||
// Since this is a new lease, go to the invoice
|
// Since this is a new lease, go to the invoice
|
||||||
// screen so we can start assessing charges.
|
// screen so we can start assessing charges.
|
||||||
$this->redirect(array('action'=>'invoice', $lid, 'move-in'));
|
$this->redirect(array('action'=>'invoice', $lid));
|
||||||
|
|
||||||
// For debugging, only if the redirect above have been
|
// For debugging, only if the redirect above have been
|
||||||
// commented out, otherwise this section isn't reached.
|
// commented out, otherwise this section isn't reached.
|
||||||
@@ -177,6 +172,8 @@ class LeasesController extends AppController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->redirect($this->data['redirect']);
|
$this->redirect($this->data['redirect']);
|
||||||
|
$this->autoRender = false;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($id))
|
if (!isset($id))
|
||||||
@@ -216,69 +213,118 @@ class LeasesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* /\************************************************************************** */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
/* ************************************************************************** */
|
|
||||||
/* * action: promote_credit */
|
|
||||||
/* * - Moves any lease credit up to the customer level, so that */
|
|
||||||
/* * it may be used for charges other than those on this lease. */
|
|
||||||
/* *\/ */
|
|
||||||
|
|
||||||
/* function promote_surplus($id) { */
|
|
||||||
/* $this->Lease->promoteSurplus($id); */
|
|
||||||
/* pr("PREVENTING REDIRECT"); */
|
|
||||||
/* $this->render('fake'); */
|
|
||||||
/* $this->redirect(array('controller' => 'leases', */
|
|
||||||
/* 'action' => 'view', */
|
|
||||||
/* $id)); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* action: refund
|
* action: apply_deposit
|
||||||
* - Provides lease customer with a refund
|
* - Applies the security deposit to charges. This is much
|
||||||
|
* like a receipt, but it's separated to keep it simple and
|
||||||
|
* to prevent feature overload on the receipt page.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function refund($id) {
|
function apply_deposit($id = null) {
|
||||||
|
// Create some models for convenience
|
||||||
|
$A = new Account();
|
||||||
|
|
||||||
|
if ($this->data) {
|
||||||
|
// Handle the move out based on the data given
|
||||||
|
pr($this->data);
|
||||||
|
$this->Lease->releaseSecurityDeposits($this->data['Lease']['id']);
|
||||||
|
die();
|
||||||
|
|
||||||
|
// Assume this will succeed
|
||||||
|
$ret = true;
|
||||||
|
|
||||||
|
// Go through the entered payments
|
||||||
|
$receipt_transaction = array_intersect_key($this->data,
|
||||||
|
array('Transaction'=>1,
|
||||||
|
'transaction_id'=>1));
|
||||||
|
foreach ($data['StatementEntry'] AS $entry) {
|
||||||
|
// Create the receipt entry, and reconcile the credit side
|
||||||
|
// of the double-entry (which should be A/R) as a payment.
|
||||||
|
$ids = $this->StatementEntry->Ledger->Account->postLedgerEntry
|
||||||
|
($receipt_transaction,
|
||||||
|
array_intersect_key($entry, array('MonetarySource'=>1))
|
||||||
|
+ array_intersect_key($entry, array('account_id'=>1)),
|
||||||
|
array('debit_ledger_id' => $A->currentLedgerID($entry['account_id']),
|
||||||
|
'credit_ledger_id' => $A->currentLedgerID($A->receiptAccountID()),
|
||||||
|
'customer_id' => $customer_id,
|
||||||
|
'lease_id' => $lease_id)
|
||||||
|
+ $entry,
|
||||||
|
'receipt');
|
||||||
|
|
||||||
|
if ($ids['error'])
|
||||||
|
$ret = false;
|
||||||
|
|
||||||
|
$db = &$model->getDataSource();
|
||||||
|
$fields = $db->fields($model, $model->alias);
|
||||||
|
$fields[] = ("SUM(IF(Account.id IS NULL, 0," .
|
||||||
|
" IF(LedgerEntry.debit_ledger_id = Account.id," .
|
||||||
|
" 1, -1))" .
|
||||||
|
" * IF(LedgerEntry.amount IS NULL, 0, LedgerEntry.amount))" .
|
||||||
|
" AS 'balance'");
|
||||||
|
return $fields;
|
||||||
|
$receipt_transaction = array_intersect_key($ids,
|
||||||
|
array('transaction_id'=>1,
|
||||||
|
'split_transaction_id'=>1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->Lease->moveOut($this->data['Lease']['id'],
|
||||||
|
'VACANT',
|
||||||
|
$this->data['Lease']['moveout_date'],
|
||||||
|
//true // Close this lease, if able
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->redirect(array('controller' => 'leases',
|
||||||
|
'action' => 'view',
|
||||||
|
$this->data['Lease']['id']));
|
||||||
|
$this->autoRender = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$A = new Account();
|
||||||
|
|
||||||
$lease = $this->Lease->find
|
$lease = $this->Lease->find
|
||||||
('first', array
|
('first', array
|
||||||
('contain' => array
|
('contain' => array
|
||||||
(// Models
|
(// Models
|
||||||
'Unit' => array('fields' => array('id', 'name')),
|
'Unit' =>
|
||||||
'Customer' => array('fields' => array('id', 'name')),
|
array('order' => array('sort_order'),
|
||||||
|
'fields' => array('id', 'name'),
|
||||||
|
),
|
||||||
|
|
||||||
|
'Customer' =>
|
||||||
|
array('fields' => array('id', 'name'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
'conditions' => array(array('Lease.id' => $id),
|
'conditions' => array(array('Lease.id' => $id),
|
||||||
// Make sure lease is not closed...
|
|
||||||
array('Lease.close_date' => null),
|
array('Lease.close_date' => null),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
if (empty($lease)) {
|
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine the lease balance, bailing if the customer owes money
|
|
||||||
$balance = $this->Lease->balance($id);
|
|
||||||
if ($balance >= 0) {
|
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The refund will be for a positive amount
|
// Get the lease balance, part of lease stats
|
||||||
$balance *= -1;
|
$this->Lease->statsMerge($lease['Lease'],
|
||||||
|
array('stats' => $this->Lease->stats($id)));
|
||||||
|
|
||||||
// Get the accounts capable of paying the refund
|
// Determine the lease security deposit
|
||||||
$refundAccounts = $this->Lease->StatementEntry->Account->refundAccounts();
|
$deposit_balance = $this->Lease->securityDeposits($lease['Lease']['id']);
|
||||||
$defaultAccount = current($refundAccounts);
|
$this->set(compact('deposit_balance'));
|
||||||
$this->set(compact('refundAccounts', 'defaultAccount'));
|
$this->set('customer', $lease['Customer']);
|
||||||
|
$this->set('unit', $lease['Unit']);
|
||||||
|
$this->set('lease', $lease['Lease']);
|
||||||
|
$this->set('account', array('id' => $A->securityDepositAccountID()));
|
||||||
|
|
||||||
|
/* $redirect = array('controller' => 'leases', */
|
||||||
|
/* 'action' => 'view', */
|
||||||
|
/* $id); */
|
||||||
|
|
||||||
// Prepare to render
|
|
||||||
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
||||||
$lease['Unit']['name'] . ': ' .
|
$lease['Unit']['name'] . ': ' .
|
||||||
$lease['Customer']['name'] . ': Refund');
|
$lease['Customer']['name'] . ': Utilize Security Deposit');
|
||||||
$this->set(compact('title', 'lease', 'balance'));
|
$this->set(compact('title', 'redirect'));
|
||||||
$this->render('/transactions/refund');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -286,34 +332,82 @@ class LeasesController extends AppController {
|
|||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* action: bad_debt
|
* action: bad_debt
|
||||||
* - Sets up the write-off entry page, so that the
|
* - Writes off remaining charges on a lease.
|
||||||
* user can write off remaining charges on a lease.
|
* REVISIT <AP>: 20090710
|
||||||
|
* Should this be a customer function? What customer
|
||||||
|
* would have only one lease that results in bad debt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function bad_debt($id) {
|
function bad_debt($id) {
|
||||||
$this->Lease->id = $id;
|
$A = new Account();
|
||||||
|
|
||||||
$lease = $this->Lease->find
|
$lease = $this->Lease->find
|
||||||
('first', array
|
('first', array
|
||||||
('contain' => array
|
('contain' => array
|
||||||
(// Models
|
(// Models
|
||||||
'Unit' => array('fields' => array('id', 'name')),
|
'Unit' =>
|
||||||
'Customer' => array('fields' => array('id', 'name')),
|
array('order' => array('sort_order'),
|
||||||
|
'fields' => array('id', 'name'),
|
||||||
|
),
|
||||||
|
|
||||||
|
'Customer' =>
|
||||||
|
array('fields' => array('id', 'name'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'conditions' => array(array('Lease.id' => $id),
|
||||||
|
array('Lease.close_date' => null),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
// Make sure we have a valid lease to write off
|
|
||||||
if (empty($lease))
|
|
||||||
$this->redirect(array('action' => 'view', $id));
|
|
||||||
|
|
||||||
// Get the lease balance
|
// Get the lease balance, part of lease stats
|
||||||
$balance = $this->Lease->balance($id);
|
$this->Lease->statsMerge($lease['Lease'],
|
||||||
|
array('stats' => $this->Lease->stats($id)));
|
||||||
|
|
||||||
|
// Determine the lease security deposit
|
||||||
|
$deposit_balance = $this->Lease->securityDepositBalance($lease['Lease']['id']);
|
||||||
|
if ($deposit_balance > 0)
|
||||||
|
die("Still have un-utilized security deposit");
|
||||||
|
|
||||||
|
$this->set('customer', $lease['Customer']);
|
||||||
|
$this->set('unit', $lease['Unit']);
|
||||||
|
$this->set('lease', $lease['Lease']);
|
||||||
|
$this->set('account', array('id' => $A->badDebtAccountID()));
|
||||||
|
|
||||||
|
/* $redirect = array('controller' => 'leases', */
|
||||||
|
/* 'action' => 'view', */
|
||||||
|
/* $id); */
|
||||||
|
|
||||||
// Prepare to render
|
|
||||||
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
||||||
$lease['Unit']['name'] . ': ' .
|
$lease['Unit']['name'] . ': ' .
|
||||||
$lease['Customer']['name'] . ': Write Off Bad Debt');
|
$lease['Customer']['name'] . ': Write Off Bad Debt');
|
||||||
$this->set(compact('title', 'lease', 'balance'));
|
$this->set(compact('title', 'redirect'));
|
||||||
$this->render('/transactions/bad_debt');
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* action: refund
|
||||||
|
* - Provides user with a refund
|
||||||
|
* REVISIT <AP>: 20090710
|
||||||
|
* Should this be a customer function?
|
||||||
|
*/
|
||||||
|
|
||||||
|
function refund($id) {
|
||||||
|
/* // Obtain the overall lease balance */
|
||||||
|
/* $stats = $this->Lease->stats($id); */
|
||||||
|
/* $outstanding_balance = $stats['balance']; */
|
||||||
|
|
||||||
|
/* // Determine the lease security deposit */
|
||||||
|
/* $deposits = $this->Lease->securityDeposits($id); */
|
||||||
|
/* $outstanding_deposit = $deposits['summary']['balance']; */
|
||||||
|
|
||||||
|
|
||||||
|
/* $this->set(compact('lease', 'title', */
|
||||||
|
/* 'outstanding_deposit', */
|
||||||
|
/* 'outstanding_balance')); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -324,23 +418,9 @@ class LeasesController extends AppController {
|
|||||||
* - Closes a lease to any further action
|
* - Closes a lease to any further action
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// REVISIT <AP>: 20090809
|
|
||||||
// While cleaning up the sitelink data, then delete reldep()
|
|
||||||
function reldep($id) {
|
|
||||||
$this->Lease->id = $id;
|
|
||||||
$stamp = $this->Lease->field('moveout_date');
|
|
||||||
$this->Lease->releaseSecurityDeposits($id, $stamp);
|
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function close($id) {
|
function close($id) {
|
||||||
// REVISIT <AP>: 20090708
|
// REVISIT <AP>: 20090708
|
||||||
// We should probably seek confirmation first...
|
// We should probably seek confirmation first...
|
||||||
if (!$this->Lease->closeable($id)) {
|
|
||||||
INTERNAL_ERROR("This lease is not ready to close");
|
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->Lease->close($id);
|
$this->Lease->close($id);
|
||||||
$this->redirect(array('action'=>'view', $id));
|
$this->redirect(array('action'=>'view', $id));
|
||||||
}
|
}
|
||||||
@@ -375,32 +455,15 @@ class LeasesController extends AppController {
|
|||||||
));
|
));
|
||||||
|
|
||||||
$A = new Account();
|
$A = new Account();
|
||||||
$charge_accounts = $A->invoiceAccounts();
|
$charge_accounts = $A->chargeAccounts();
|
||||||
$default_account = $A->rentAccountID();
|
$default_account = $A->rentAccountID();
|
||||||
$rent_account = $A->rentAccountID();
|
$this->set(compact('charge_accounts', 'default_account'));
|
||||||
$security_deposit_account = $A->securityDepositAccountID();
|
|
||||||
$this->set(compact('charge_accounts', 'default_account',
|
|
||||||
'rent_account', 'security_deposit_account'));
|
|
||||||
|
|
||||||
// REVISIT <AP> 20090705:
|
// REVISIT <AP> 20090705:
|
||||||
// Of course, the late charge should come from the late_schedule
|
// Of course, the late charge should come from the late_schedule
|
||||||
|
$default_rent = $lease['Lease']['rent'];
|
||||||
$default_late = 10;
|
$default_late = 10;
|
||||||
$this->set(compact('default_late'));
|
$this->set(compact('default_rent', 'default_late'));
|
||||||
|
|
||||||
if ($type === 'move-in') {
|
|
||||||
$movein = array();
|
|
||||||
$movein['time'] = strtotime($lease['Lease']['movein_date']);
|
|
||||||
$movein['effective_time'] = strtotime($lease['Lease']['movein_date']);
|
|
||||||
$movein_date = getdate($movein['effective_time']);
|
|
||||||
$movein['through_time'] = mktime(0, 0, 0, $movein_date['mon'] + 1, 0, $movein_date['year']);
|
|
||||||
$days_in_month = idate('d', $movein['through_time']);
|
|
||||||
$movein['prorated_days'] = $days_in_month - $movein_date['mday'] + 1;
|
|
||||||
$movein['prorated_rent'] = $lease['Lease']['rent'] * $movein['prorated_days'] / $days_in_month;
|
|
||||||
$movein['prorated'] = $movein['prorated_days'] != $days_in_month;
|
|
||||||
$movein['deposit'] = $lease['Lease']['deposit'];
|
|
||||||
$this->set(compact('movein'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
|
||||||
$lease['Unit']['name'] . ': ' .
|
$lease['Unit']['name'] . ': ' .
|
||||||
@@ -409,21 +472,6 @@ class LeasesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: assess_rent/late
|
|
||||||
* - Assesses the new monthly rent/late charge, if need be
|
|
||||||
*/
|
|
||||||
|
|
||||||
function assess_rent($date = null) {
|
|
||||||
$this->Lease->assessMonthlyRentAll($date);
|
|
||||||
}
|
|
||||||
function assess_late($date = null) {
|
|
||||||
$this->Lease->assessMonthlyLateAll($date);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -456,15 +504,16 @@ class LeasesController extends AppController {
|
|||||||
$this->set('charge_gaps', $this->Lease->rentChargeGaps($id));
|
$this->set('charge_gaps', $this->Lease->rentChargeGaps($id));
|
||||||
$this->set('charge_through', $this->Lease->rentChargeThrough($id));
|
$this->set('charge_through', $this->Lease->rentChargeThrough($id));
|
||||||
|
|
||||||
// Figure out the outstanding balances for this lease
|
// Obtain the overall lease balance
|
||||||
$outstanding_balance = $this->Lease->balance($id);
|
$this->Lease->statsMerge($lease['Lease'],
|
||||||
$outstanding_deposit = $this->Lease->securityDepositBalance($id);
|
array('stats' => $this->Lease->stats($id)));
|
||||||
|
$outstanding_balance = $lease['Lease']['stats']['balance'];
|
||||||
|
|
||||||
// Set up dynamic menu items. Normally, these will only be present
|
// Determine the lease security deposit
|
||||||
// on an open lease, but it's possible for a lease to be closed, and
|
$outstanding_deposit = $this->Lease->securityDepositBalance($lease['Lease']['id']);
|
||||||
// yet still have an outstanding balance. This can happen if someone
|
|
||||||
// were to reverse charges, or if a payment should come back NSF.
|
// Set up dynamic menu items
|
||||||
if (!isset($lease['Lease']['close_date']) || $outstanding_balance > 0) {
|
if (!isset($lease['Lease']['close_date'])) {
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Operations', 'header' => true);
|
array('name' => 'Operations', 'header' => true);
|
||||||
|
|
||||||
@@ -473,36 +522,28 @@ class LeasesController extends AppController {
|
|||||||
array('name' => 'Move-Out', 'url' => array('action' => 'move_out',
|
array('name' => 'Move-Out', 'url' => array('action' => 'move_out',
|
||||||
$id));
|
$id));
|
||||||
|
|
||||||
if (!isset($lease['Lease']['close_date']))
|
$this->sidemenu_links[] =
|
||||||
$this->sidemenu_links[] =
|
array('name' => 'Charges', 'url' => array('action' => 'invoice',
|
||||||
array('name' => 'New Invoice', 'url' => array('action' => 'invoice',
|
$id));
|
||||||
$id));
|
|
||||||
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'New Receipt', 'url' => array('controller' => 'customers',
|
array('name' => 'Payments', 'url' => array('controller' => 'customers',
|
||||||
'action' => 'receipt',
|
'action' => 'receipt',
|
||||||
$lease['Customer']['id']));
|
$lease['Customer']['id']));
|
||||||
|
|
||||||
/* if ($outstanding_balance < 0) */
|
if (isset($lease['Lease']['moveout_date']) && $outstanding_deposit > 0 && $outstanding_balance > 0)
|
||||||
/* $this->sidemenu_links[] = */
|
$this->sidemenu_links[] =
|
||||||
/* array('name' => 'Transfer Credit to Customer', */
|
array('name' => 'Apply Deposit', 'url' => array('action' => 'apply_deposit',
|
||||||
/* 'url' => array('action' => 'promote_surplus', $id)); */
|
$id));
|
||||||
|
|
||||||
// REVISIT <AP>:
|
if (isset($lease['Lease']['moveout_date']) &&
|
||||||
// Not allowing refund to be issued from the lease, as
|
$outstanding_balance <= 0 &&
|
||||||
// in fact, we should never have a positive lease balance.
|
($outstanding_deposit - $outstanding_balance) > 0)
|
||||||
// I'll flag this at the moment, since we might get one
|
$this->sidemenu_links[] =
|
||||||
// when a charge is reimbursed; a bug that we'll either
|
array('name' => 'Issue Refund', 'url' => array('action' => 'refund',
|
||||||
// need to fix, or we'll have to revisit this assumption.
|
$id));
|
||||||
if ($outstanding_balance < 0)
|
|
||||||
INTERNAL_ERROR("Should not have a customer lease credit.");
|
|
||||||
|
|
||||||
/* if ($outstanding_balance < 0) */
|
if (isset($lease['Lease']['moveout_date']) && $outstanding_deposit == 0 && $outstanding_balance > 0)
|
||||||
/* $this->sidemenu_links[] = */
|
|
||||||
/* array('name' => 'Issue Refund', */
|
|
||||||
/* 'url' => array('action' => 'refund', $id)); */
|
|
||||||
|
|
||||||
if (isset($lease['Lease']['moveout_date']) && $outstanding_balance > 0)
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Write-Off', 'url' => array('action' => 'bad_debt',
|
array('name' => 'Write-Off', 'url' => array('action' => 'bad_debt',
|
||||||
$id));
|
$id));
|
||||||
|
|||||||
@@ -16,16 +16,6 @@ class LedgerEntriesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: index / current / past / all
|
|
||||||
* - Creates a list of ledger entries
|
|
||||||
*/
|
|
||||||
|
|
||||||
function index() { $this->gridView('All Ledger Entries'); }
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
@@ -16,16 +16,6 @@ class StatementEntriesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: index / current / past / all
|
|
||||||
* - Creates a list of statement entries
|
|
||||||
*/
|
|
||||||
|
|
||||||
function index() { $this->gridView('All Statement Entries'); }
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -35,7 +25,7 @@ class StatementEntriesController extends AppController {
|
|||||||
* to jqGrid.
|
* to jqGrid.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function gridDataTables(&$params, &$model) {
|
function gridDataCountTables(&$params, &$model) {
|
||||||
$link =
|
$link =
|
||||||
array(// Models
|
array(// Models
|
||||||
'Transaction' =>
|
'Transaction' =>
|
||||||
@@ -52,50 +42,53 @@ class StatementEntriesController extends AppController {
|
|||||||
array('fields' => array('id', 'name'),
|
array('fields' => array('id', 'name'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
'Account' =>
|
|
||||||
array('fields' => array('id', 'name', 'type'),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($params['post']['custom']['statement_entry_id'])) {
|
if (isset($params['post']['custom']['statement_entry_id'])) {
|
||||||
$link['DisbursementEntry'] = array();
|
$link['PaymentEntry'] = array();
|
||||||
$link['ChargeEntry'] = array();
|
$link['ChargeEntry'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if ($params['action'] === 'collected') { */
|
if (isset($params['post']['custom']['account_id'])) {
|
||||||
/* $link['DisbursementEntry'] = array('Receipt' => array('class' => 'Transaction')); */
|
$link['LedgerEntry'] = array('fields' => array('id'));
|
||||||
/* $link['ChargeEntry'] = array('Invoice' => array('class' => 'Transaction')); */
|
$link['LedgerEntry']['Account'] = array('fields' => array('id', 'name', 'type'));
|
||||||
/* } */
|
}
|
||||||
|
|
||||||
/* if (count(array_intersect($params['fields'], array('applied'))) == 1) { */
|
/* if (count(array_intersect($params['fields'], array('applied'))) == 1) { */
|
||||||
/* $link['DisbursementEntry'] = array(); */
|
/* $link['PaymentEntry'] = array(); */
|
||||||
/* $link['ChargeEntry'] = array(); */
|
/* $link['ChargeEntry'] = array(); */
|
||||||
/* } */
|
|
||||||
/* elseif (isset($params['post']['custom']['customer_id']) || isset($params['post']['custom']['lease_id'])) { */
|
|
||||||
/* $link['DisbursementEntry'] = array(); */
|
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
return array('link' => $link);
|
return array('link' => $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gridDataTables(&$params, &$model) {
|
||||||
|
$tables = $this->gridDataCountTables($params, $model);
|
||||||
|
$tables['link']['LedgerEntry'] = array('fields' => array('id'));
|
||||||
|
$tables['link']['LedgerEntry']['Account'] = array('fields' => array('id', 'name', 'type'));
|
||||||
|
return $tables;
|
||||||
|
}
|
||||||
|
|
||||||
function gridDataFields(&$params, &$model) {
|
function gridDataFields(&$params, &$model) {
|
||||||
|
//foreach(
|
||||||
$fields = parent::gridDataFields($params, $model);
|
$fields = parent::gridDataFields($params, $model);
|
||||||
|
|
||||||
|
$fields[] = "COUNT(LedgerEntry.id) AS ledger_entry_count";
|
||||||
|
|
||||||
if (in_array('applied', $params['post']['fields'])) {
|
if (in_array('applied', $params['post']['fields'])) {
|
||||||
$fields[] = ("IF(StatementEntry.type = 'CHARGE'," .
|
$fields[] = ("IF(StatementEntry.type = 'CHARGE'," .
|
||||||
" SUM(COALESCE(DisbursementEntry.amount,0))," .
|
" SUM(COALESCE(PaymentEntry.amount,0))," .
|
||||||
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
||||||
" AS 'applied'");
|
" AS 'applied'");
|
||||||
$fields[] = ("StatementEntry.amount - (" .
|
$fields[] = ("StatementEntry.amount - (" .
|
||||||
"IF(StatementEntry.type = 'CHARGE'," .
|
"IF(StatementEntry.type = 'CHARGE'," .
|
||||||
" SUM(COALESCE(DisbursementEntry.amount,0))," .
|
" SUM(COALESCE(PaymentEntry.amount,0))," .
|
||||||
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
||||||
") AS 'balance'");
|
") AS 'balance'");
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = array_merge($fields,
|
$fields = array_merge($fields,
|
||||||
$this->StatementEntry->chargeDisbursementFields());
|
$this->StatementEntry->chargePaymentFields());
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
@@ -115,17 +108,25 @@ class StatementEntriesController extends AppController {
|
|||||||
$this->StatementEntry->Transaction->dateFormatBeforeSave($through_date . ' 23:59:59'));
|
$this->StatementEntry->Transaction->dateFormatBeforeSave($through_date . ' 23:59:59'));
|
||||||
|
|
||||||
if (isset($account_id))
|
if (isset($account_id))
|
||||||
$conditions[] = array('StatementEntry.account_id' => $account_id);
|
$conditions[] = array('LedgerEntry.account_id' => $account_id);
|
||||||
|
|
||||||
if (isset($statement_entry_id)) {
|
if (isset($statement_entry_id)) {
|
||||||
$conditions[] = array('OR' =>
|
$conditions[] = array('OR' =>
|
||||||
array(array('ChargeEntry.id' => $statement_entry_id),
|
array(array('ChargeEntry.id' => $statement_entry_id),
|
||||||
array('DisbursementEntry.id' => $statement_entry_id)));
|
array('PaymentEntry.id' => $statement_entry_id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $conditions;
|
return $conditions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gridDataPostProcessCalculatedFields(&$params, &$model, &$records) {
|
||||||
|
parent::gridDataPostProcessCalculatedFields($params, $model, $records);
|
||||||
|
foreach ($records AS &$record) {
|
||||||
|
if ($record['StatementEntry']['ledger_entry_count'] > 1)
|
||||||
|
$record['Account']['name'] = 'Multiple';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
||||||
$links['StatementEntry'] = array('id');
|
$links['StatementEntry'] = array('id');
|
||||||
$links['Transaction'] = array('id');
|
$links['Transaction'] = array('id');
|
||||||
@@ -154,13 +155,13 @@ class StatementEntriesController extends AppController {
|
|||||||
if (in_array('applied', $params['post']['fields'])) {
|
if (in_array('applied', $params['post']['fields'])) {
|
||||||
$tquery = array_diff_key($query, array('fields'=>1,'group'=>1,'limit'=>1,'order'=>1));
|
$tquery = array_diff_key($query, array('fields'=>1,'group'=>1,'limit'=>1,'order'=>1));
|
||||||
$tquery['fields'] = array("IF(StatementEntry.type = 'CHARGE'," .
|
$tquery['fields'] = array("IF(StatementEntry.type = 'CHARGE'," .
|
||||||
" SUM(COALESCE(DisbursementEntry.amount,0))," .
|
" SUM(COALESCE(StatementFraction.amount,0))," .
|
||||||
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
||||||
" AS 'applied'",
|
" AS 'applied'",
|
||||||
|
|
||||||
"StatementEntry.amount - (" .
|
"StatementEntry.amount - (" .
|
||||||
"IF(StatementEntry.type = 'CHARGE'," .
|
"IF(StatementEntry.type = 'CHARGE'," .
|
||||||
" SUM(COALESCE(DisbursementEntry.amount,0))," .
|
" SUM(COALESCE(PaymentEntry.amount,0))," .
|
||||||
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
" SUM(COALESCE(ChargeEntry.amount,0)))" .
|
||||||
") AS 'balance'",
|
") AS 'balance'",
|
||||||
);
|
);
|
||||||
@@ -193,18 +194,6 @@ class StatementEntriesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: waive the ledger entry
|
|
||||||
*/
|
|
||||||
|
|
||||||
function waive($id) {
|
|
||||||
$this->StatementEntry->waive($id);
|
|
||||||
$this->redirect(array('action'=>'view', $id));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -219,54 +208,68 @@ class StatementEntriesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the StatementEntry and related fields
|
// Get the StatementEntry and related fields
|
||||||
|
$this->StatementEntry->prClassLevel(30, 'Model');
|
||||||
$entry = $this->StatementEntry->find
|
$entry = $this->StatementEntry->find
|
||||||
('first',
|
('first',
|
||||||
array('contain' => array
|
array('contain' => array
|
||||||
('Transaction' => array('fields' => array('id', 'type', 'stamp')),
|
('Transaction' => array('fields' => array('id', 'stamp')),
|
||||||
'Account' => array('id', 'name', 'type'),
|
|
||||||
'Customer' => array('fields' => array('id', 'name')),
|
'Customer' => array('fields' => array('id', 'name')),
|
||||||
'Lease' => array('fields' => array('id')),
|
'Lease' => array('fields' => array('id')),
|
||||||
|
'LedgerEntry' => array('fields' => array('id'),
|
||||||
|
'Account' => array('id', 'name', 'type')),
|
||||||
),
|
),
|
||||||
|
|
||||||
'conditions' => array('StatementEntry.id' => $id),
|
'conditions' => array('StatementEntry.id' => $id),
|
||||||
));
|
));
|
||||||
|
pr($entry);
|
||||||
|
//die();
|
||||||
|
|
||||||
$reconciled = $this->StatementEntry->reconciledEntries($id);
|
$reconciled = $this->StatementEntry->reconciledEntries($id);
|
||||||
|
|
||||||
|
|
||||||
|
/* // REVISIT <AP>: 20090711 */
|
||||||
|
/* // It's not clear whether we should be able to reverse charges that have */
|
||||||
|
/* // already been paid/cleared/reconciled. Certainly, that will be the */
|
||||||
|
/* // case when someone has pre-paid and then moves out early. However, this */
|
||||||
|
/* // will work well for items accidentally charged but not yet paid for. */
|
||||||
|
/* if ((!$entry['DebitLedger']['Account']['trackable'] || */
|
||||||
|
/* $stats['debit']['amount_reconciled'] == 0) && */
|
||||||
|
/* (!$entry['CreditLedger']['Account']['trackable'] || */
|
||||||
|
/* $stats['credit']['amount_reconciled'] == 0) */
|
||||||
|
|
||||||
|
/* && 0 */
|
||||||
|
|
||||||
|
/* ) */
|
||||||
|
/* { */
|
||||||
|
/* // Set up dynamic menu items */
|
||||||
|
/* $this->sidemenu_links[] = */
|
||||||
|
/* array('name' => 'Operations', 'header' => true); */
|
||||||
|
|
||||||
|
/* $this->sidemenu_links[] = */
|
||||||
|
/* array('name' => 'Undo', */
|
||||||
|
/* 'url' => array('action' => 'reverse', */
|
||||||
|
/* $id)); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* if ($this->StatementEntry->Ledger->Account->type */
|
||||||
|
/* ($entry['CreditLedger']['Account']['id']) == 'INCOME') */
|
||||||
|
/* { */
|
||||||
|
/* // Set up dynamic menu items */
|
||||||
|
/* $this->sidemenu_links[] = */
|
||||||
|
/* array('name' => 'Operations', 'header' => true); */
|
||||||
|
|
||||||
|
/* $this->sidemenu_links[] = */
|
||||||
|
/* array('name' => 'Reverse', */
|
||||||
|
/* 'url' => array('action' => 'reverse', */
|
||||||
|
/* $id)); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
$stats = $this->StatementEntry->stats($id);
|
$stats = $this->StatementEntry->stats($id);
|
||||||
|
|
||||||
if (in_array(strtoupper($entry['StatementEntry']['type']), $this->StatementEntry->debitTypes()))
|
if (strtoupper($entry['StatementEntry']['type']) === 'CHARGE')
|
||||||
$stats = $stats['Charge'];
|
$stats = $stats['Charge'];
|
||||||
else
|
else
|
||||||
$stats = $stats['Disbursement'];
|
$stats = $stats['Payment'];
|
||||||
|
|
||||||
|
|
||||||
if (strtoupper($entry['StatementEntry']['type']) === 'CHARGE') {
|
|
||||||
|
|
||||||
$reversal = $this->StatementEntry->find
|
|
||||||
('first',
|
|
||||||
array('link' => array('DisbursementEntry'),
|
|
||||||
'conditions' => array(array('StatementEntry.id' => $id),
|
|
||||||
array('DisbursementEntry.type' => 'REVERSAL')),
|
|
||||||
));
|
|
||||||
|
|
||||||
// Set up dynamic menu items
|
|
||||||
if (empty($reversal) || $stats['balance'] > 0)
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Operations', 'header' => true);
|
|
||||||
|
|
||||||
if (empty($reversal))
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Reverse',
|
|
||||||
'url' => array('action' => 'reverse',
|
|
||||||
$id));
|
|
||||||
|
|
||||||
if ($stats['balance'] > 0)
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Waive Balance',
|
|
||||||
'url' => array('action' => 'waive',
|
|
||||||
$id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare to render.
|
// Prepare to render.
|
||||||
$title = "Statement Entry #{$entry['StatementEntry']['id']}";
|
$title = "Statement Entry #{$entry['StatementEntry']['id']}";
|
||||||
|
|||||||
@@ -115,33 +115,15 @@ class TendersController extends AppController {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function nsf($id = null) {
|
function nsf($id = null) {
|
||||||
if ($this->data) {
|
|
||||||
$result = $this->Tender->nsf
|
|
||||||
($this->data['Tender']['id'],
|
|
||||||
$this->data['Transaction']['stamp'],
|
|
||||||
$this->data['Transaction']['comment']);
|
|
||||||
$this->redirect(array('controller' => 'tenders',
|
|
||||||
'action' => 'view',
|
|
||||||
$this->data['Tender']['id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
$this->Session->setFlash(__('Invalid Item.', true));
|
$this->Session->setFlash(__('Invalid Item.', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Tender->id = $id;
|
$this->Tender->nsf($id);
|
||||||
$tender = $this->Tender->find
|
$this->redirect(array('action'=>'view', $id));
|
||||||
('first', array
|
|
||||||
('contain' => array('Customer', 'LedgerEntry' => array('Transaction')),
|
|
||||||
));
|
|
||||||
|
|
||||||
// Prepare to render.
|
|
||||||
$title = "Tender #{$tender['Tender']['id']} : {$tender['Tender']['name']} : NSF";
|
|
||||||
$this->set(compact('tender', 'title'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -156,30 +138,22 @@ class TendersController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the Tender and related fields
|
// Get the Tender and related fields
|
||||||
$this->Tender->id = $id;
|
|
||||||
$tender = $this->Tender->find
|
$tender = $this->Tender->find
|
||||||
('first', array
|
('first', array
|
||||||
('contain' => array('TenderType', 'Customer', 'LedgerEntry' => array('Transaction')),
|
('contain' => array('TenderType', 'Customer', 'LedgerEntry' => array('Transaction')),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
// Set up dynamic menu items
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Operations', 'header' => true);
|
|
||||||
|
|
||||||
// Watch out for the special "Closing" entries
|
|
||||||
if (!empty($tender['TenderType']['id']))
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Edit',
|
|
||||||
'url' => array('action' => 'edit',
|
|
||||||
$id));
|
|
||||||
|
|
||||||
if (!empty($tender['Tender']['deposit_transaction_id'])
|
if (!empty($tender['Tender']['deposit_transaction_id'])
|
||||||
&& empty($tender['Tender']['nsf_transaction_id'])
|
&& empty($tender['Tender']['nsf_transaction_id'])
|
||||||
// Hard to tell what types of items can come back as NSF.
|
// Hard to tell what types of items can come back as NSF.
|
||||||
// For now, assume iff it is a named item, it can be NSF.
|
// For now, assume iff it is a named item, it can be NSF.
|
||||||
&& !empty($tender['TenderType']['data1_name'])
|
&& !empty($tender['TenderType']['data1_name'])
|
||||||
) {
|
) {
|
||||||
|
// Set up dynamic menu items
|
||||||
|
$this->sidemenu_links[] =
|
||||||
|
array('name' => 'Operations', 'header' => true);
|
||||||
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'NSF',
|
array('name' => 'NSF',
|
||||||
'url' => array('action' => 'nsf',
|
'url' => array('action' => 'nsf',
|
||||||
@@ -187,76 +161,7 @@ class TendersController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare to render.
|
// Prepare to render.
|
||||||
$title = "Tender #{$tender['Tender']['id']} : {$tender['Tender']['name']}";
|
$title = "Tender #{$tender['Tender']['id']}";
|
||||||
$this->set(compact('tender', 'title'));
|
$this->set(compact('tender', 'title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: edit
|
|
||||||
* - Edit tender information
|
|
||||||
*/
|
|
||||||
|
|
||||||
function edit($id = null) {
|
|
||||||
if (isset($this->data)) {
|
|
||||||
// Check to see if the operation was cancelled.
|
|
||||||
if (isset($this->params['form']['cancel'])) {
|
|
||||||
if (empty($this->data['Tender']['id']))
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
|
|
||||||
$this->redirect(array('action'=>'view', $this->data['Tender']['id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure we have tender data
|
|
||||||
if (empty($this->data['Tender']) || empty($this->data['Tender']['id']))
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
|
|
||||||
// Figure out which tender type was chosen
|
|
||||||
// REVISIT <AP>: 20090810; Not ready to change tender type
|
|
||||||
// $tender_type_id = $this->data['Tender']['tender_type_id'];
|
|
||||||
$tender_type_id = $this->Tender->field('tender_type_id');
|
|
||||||
if (empty($tender_type_id))
|
|
||||||
$this->redirect(array('action'=>'view', $this->data['Tender']['id']));
|
|
||||||
|
|
||||||
// Get data fields from the selected tender type
|
|
||||||
$this->data['Tender'] += $this->data['type'][$tender_type_id];
|
|
||||||
unset($this->data['type']);
|
|
||||||
|
|
||||||
// Save the tender and all associated data
|
|
||||||
$this->Tender->create();
|
|
||||||
$this->Tender->id = $this->data['Tender']['id'];
|
|
||||||
if (!$this->Tender->save($this->data, false)) {
|
|
||||||
$this->Session->setFlash("TENDER SAVE FAILED", true);
|
|
||||||
pr("TENDER SAVE FAILED");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->redirect(array('action'=>'view', $this->Tender->id));
|
|
||||||
|
|
||||||
// For debugging, only if the redirects above have been
|
|
||||||
// commented out, otherwise this section isn't reached.
|
|
||||||
$this->render('/fake');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($id) {
|
|
||||||
$this->data = $this->Tender->findById($id);
|
|
||||||
} else {
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$tender_types = $this->Tender->TenderType->find
|
|
||||||
('list', array('order' => array('name')));
|
|
||||||
$this->set(compact('tender_types'));
|
|
||||||
|
|
||||||
$types = $this->Tender->TenderType->find('all', array('contain' => false));
|
|
||||||
$this->set(compact('types'));
|
|
||||||
|
|
||||||
// Prepare to render.
|
|
||||||
$title = ('Tender #' . $this->data['Tender']['id'] .
|
|
||||||
' : ' . $this->data['Tender']['name'] .
|
|
||||||
" : Edit");
|
|
||||||
$this->set(compact('title'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,13 +35,7 @@ class TransactionsController extends AppController {
|
|||||||
function all() { $this->gridView('All Transactions', 'all'); }
|
function all() { $this->gridView('All Transactions', 'all'); }
|
||||||
function invoice() { $this->gridView('Invoices'); }
|
function invoice() { $this->gridView('Invoices'); }
|
||||||
function receipt() { $this->gridView('Receipts'); }
|
function receipt() { $this->gridView('Receipts'); }
|
||||||
function deposit() {
|
function deposit() { $this->gridView('Deposits'); }
|
||||||
$this->sidemenu_links = array
|
|
||||||
(array('name' => 'Operations', 'header' => true),
|
|
||||||
array('name' => 'New Deposit', 'url' => array('controller' => 'tenders',
|
|
||||||
'action' => 'deposit')));
|
|
||||||
$this->gridView('Deposits');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
@@ -120,7 +114,7 @@ class TransactionsController extends AppController {
|
|||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* action: postReceipt
|
* action: postReceipt
|
||||||
* - handles the creation of a receipt
|
* - handles the creation of a payment receipt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function postReceipt() {
|
function postReceipt() {
|
||||||
@@ -267,92 +261,6 @@ class TransactionsController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: postWriteOff
|
|
||||||
* - handles the write off of bad debt
|
|
||||||
*/
|
|
||||||
|
|
||||||
function postWriteOff() {
|
|
||||||
if (!$this->RequestHandler->isPost()) {
|
|
||||||
echo('<H2>THIS IS NOT A POST FOR SOME REASON</H2>');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $this->data;
|
|
||||||
if (empty($data['Customer']['id']))
|
|
||||||
$data['Customer']['id'] = null;
|
|
||||||
if (empty($data['Lease']['id']))
|
|
||||||
$data['Lease']['id'] = null;
|
|
||||||
|
|
||||||
pr(compact('data'));
|
|
||||||
|
|
||||||
if (!$this->Transaction->addWriteOff($data,
|
|
||||||
$data['Customer']['id'],
|
|
||||||
$data['Lease']['id'])) {
|
|
||||||
$this->Session->setFlash("WRITE OFF FAILED", true);
|
|
||||||
// REVISIT <AP> 20090706:
|
|
||||||
// Until we can work out the session problems,
|
|
||||||
// just die.
|
|
||||||
die("<H1>WRITE-OFF FAILED</H1>");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return to viewing the lease/customer
|
|
||||||
if (empty($data['Lease']['id']))
|
|
||||||
$this->redirect(array('controller' => 'customers',
|
|
||||||
'action' => 'view',
|
|
||||||
$data['Customer']['id']));
|
|
||||||
else
|
|
||||||
$this->redirect(array('controller' => 'leases',
|
|
||||||
'action' => 'view',
|
|
||||||
$data['Lease']['id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: postRefund
|
|
||||||
* - handles issuing a customer refund
|
|
||||||
*/
|
|
||||||
|
|
||||||
function postRefund() {
|
|
||||||
if (!$this->RequestHandler->isPost()) {
|
|
||||||
echo('<H2>THIS IS NOT A POST FOR SOME REASON</H2>');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = $this->data;
|
|
||||||
if (empty($data['Customer']['id']))
|
|
||||||
$data['Customer']['id'] = null;
|
|
||||||
if (empty($data['Lease']['id']))
|
|
||||||
$data['Lease']['id'] = null;
|
|
||||||
|
|
||||||
if (!$this->Transaction->addRefund($data,
|
|
||||||
$data['Customer']['id'],
|
|
||||||
$data['Lease']['id'])) {
|
|
||||||
$this->Session->setFlash("REFUND FAILED", true);
|
|
||||||
// REVISIT <AP> 20090706:
|
|
||||||
// Until we can work out the session problems,
|
|
||||||
// just die.
|
|
||||||
die("<H1>REFUND FAILED</H1>");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->render('/fake');
|
|
||||||
|
|
||||||
// Return to viewing the lease/customer
|
|
||||||
if (empty($data['Lease']['id']))
|
|
||||||
$this->redirect(array('controller' => 'customers',
|
|
||||||
'action' => 'view',
|
|
||||||
$data['Customer']['id']));
|
|
||||||
else
|
|
||||||
$this->redirect(array('controller' => 'leases',
|
|
||||||
'action' => 'view',
|
|
||||||
$data['Lease']['id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class UnitsController extends AppController {
|
|||||||
$fields = parent::gridDataFields($params, $model);
|
$fields = parent::gridDataFields($params, $model);
|
||||||
|
|
||||||
return array_merge($fields,
|
return array_merge($fields,
|
||||||
$this->Unit->Lease->StatementEntry->chargeDisbursementFields(true));
|
$this->Unit->Lease->StatementEntry->chargePaymentFields(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function gridDataConditions(&$params, &$model) {
|
function gridDataConditions(&$params, &$model) {
|
||||||
@@ -236,29 +236,19 @@ class UnitsController extends AppController {
|
|||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Operations', 'header' => true);
|
array('name' => 'Operations', 'header' => true);
|
||||||
|
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Edit', 'url' => array('action' => 'edit',
|
|
||||||
$id));
|
|
||||||
|
|
||||||
if (isset($unit['CurrentLease']['id']) &&
|
if (isset($unit['CurrentLease']['id']) &&
|
||||||
!isset($unit['CurrentLease']['moveout_date'])) {
|
!isset($unit['CurrentLease']['moveout_date'])) {
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Move-Out', 'url' => array('action' => 'move_out',
|
array('name' => 'Move-Out', 'url' => array('action' => 'move_out',
|
||||||
$id));
|
$id));
|
||||||
} elseif ($this->Unit->available($unit['Unit']['status'])) {
|
} else {
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Move-In', 'url' => array('action' => 'move_in',
|
array('name' => 'Move-In', 'url' => array('action' => 'move_in',
|
||||||
$id));
|
$id));
|
||||||
} else {
|
|
||||||
// Unit is unavailable (dirty, damaged, reserved, business-use, etc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($unit['CurrentLease']['id']) &&
|
if (isset($unit['CurrentLease']['id']) &&
|
||||||
!isset($unit['CurrentLease']['close_date'])) {
|
!isset($unit['CurrentLease']['close_date'])) {
|
||||||
$this->sidemenu_links[] =
|
|
||||||
array('name' => 'Charge', 'url' => array('controller' => 'leases',
|
|
||||||
'action' => 'invoice',
|
|
||||||
$unit['CurrentLease']['id']));
|
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Payment', 'url' => array('controller' => 'customers',
|
array('name' => 'Payment', 'url' => array('controller' => 'customers',
|
||||||
'action' => 'receipt',
|
'action' => 'receipt',
|
||||||
@@ -271,71 +261,4 @@ class UnitsController extends AppController {
|
|||||||
'outstanding_balance',
|
'outstanding_balance',
|
||||||
'outstanding_deposit'));
|
'outstanding_deposit'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: edit
|
|
||||||
* - Edit unit information
|
|
||||||
*/
|
|
||||||
|
|
||||||
function edit($id = null) {
|
|
||||||
if (isset($this->data)) {
|
|
||||||
// Check to see if the operation was cancelled.
|
|
||||||
if (isset($this->params['form']['cancel'])) {
|
|
||||||
if (empty($this->data['Unit']['id']))
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
|
|
||||||
$this->redirect(array('action'=>'view', $this->data['Unit']['id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure we have unit data
|
|
||||||
if (empty($this->data['Unit']))
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
|
|
||||||
// Make sure we have a rental rate
|
|
||||||
if (empty($this->data['Unit']['rent']))
|
|
||||||
$this->redirect(array('action'=>'view', $this->data['Unit']['id']));
|
|
||||||
|
|
||||||
// Save the unit and all associated data
|
|
||||||
$this->Unit->create();
|
|
||||||
$this->Unit->id = $this->data['Unit']['id'];
|
|
||||||
if (!$this->Unit->save($this->data, false)) {
|
|
||||||
$this->Session->setFlash("UNIT SAVE FAILED", true);
|
|
||||||
pr("UNIT SAVE FAILED");
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->redirect(array('action'=>'view', $this->Unit->id));
|
|
||||||
|
|
||||||
// For debugging, only if the redirects above have been
|
|
||||||
// commented out, otherwise this section isn't reached.
|
|
||||||
$this->render('/fake');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($id) {
|
|
||||||
$this->data = $this->Unit->findById($id);
|
|
||||||
$title = 'Unit ' . $this->data['Unit']['name'] . " : Edit";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$title = "Enter New Unit";
|
|
||||||
$this->data = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$statusEnums = $this->Unit->allowedStatusSet($id);
|
|
||||||
$statusEnums = array_combine(array_keys($statusEnums),
|
|
||||||
array_keys($statusEnums));
|
|
||||||
$this->set(compact('statusEnums'));
|
|
||||||
|
|
||||||
$unit_sizes = $this->Unit->UnitSize->find
|
|
||||||
('list', array('order' => array('unit_type_id', 'width', 'depth', 'id')));
|
|
||||||
$this->set(compact('unit_sizes'));
|
|
||||||
|
|
||||||
// Prepare to render.
|
|
||||||
pr($this->data);
|
|
||||||
$this->set(compact('title'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,13 +128,10 @@ class Account extends AppModel {
|
|||||||
function nsfChargeAccountID() { return $this->nameToID('NSF Charge'); }
|
function nsfChargeAccountID() { return $this->nameToID('NSF Charge'); }
|
||||||
function taxAccountID() { return $this->nameToID('Tax'); }
|
function taxAccountID() { return $this->nameToID('Tax'); }
|
||||||
function accountReceivableAccountID() { return $this->nameToID('A/R'); }
|
function accountReceivableAccountID() { return $this->nameToID('A/R'); }
|
||||||
function accountPayableAccountID() { return $this->nameToID('A/P'); }
|
|
||||||
function cashAccountID() { return $this->nameToID('Cash'); }
|
function cashAccountID() { return $this->nameToID('Cash'); }
|
||||||
function checkAccountID() { return $this->nameToID('Check'); }
|
function checkAccountID() { return $this->nameToID('Check'); }
|
||||||
function moneyOrderAccountID() { return $this->nameToID('Money Order'); }
|
function moneyOrderAccountID() { return $this->nameToID('Money Order'); }
|
||||||
function achAccountID() { return $this->nameToID('ACH'); }
|
|
||||||
function concessionAccountID() { return $this->nameToID('Concession'); }
|
function concessionAccountID() { return $this->nameToID('Concession'); }
|
||||||
function waiverAccountID() { return $this->nameToID('Waiver'); }
|
|
||||||
function pettyCashAccountID() { return $this->nameToID('Petty Cash'); }
|
function pettyCashAccountID() { return $this->nameToID('Petty Cash'); }
|
||||||
function invoiceAccountID() { return $this->nameToID('Invoice'); }
|
function invoiceAccountID() { return $this->nameToID('Invoice'); }
|
||||||
function receiptAccountID() { return $this->nameToID('Receipt'); }
|
function receiptAccountID() { return $this->nameToID('Receipt'); }
|
||||||
@@ -196,22 +193,18 @@ class Account extends AppModel {
|
|||||||
* - Returns an array of accounts suitable for activity xxx
|
* - Returns an array of accounts suitable for activity xxx
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function invoiceAccounts() {
|
function chargeAccounts() {
|
||||||
return $this->relatedAccounts('invoices', array('order' => 'name'));
|
return $this->relatedAccounts('charges', array('order' => 'name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function receiptAccounts() {
|
function paymentAccounts() {
|
||||||
return $this->relatedAccounts('receipts', array('order' => 'name'));
|
return $this->relatedAccounts('payments', array('order' => 'name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function depositAccounts() {
|
function depositAccounts() {
|
||||||
return $this->relatedAccounts('deposits', array('order' => 'name'));
|
return $this->relatedAccounts('deposits', array('order' => 'name'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function refundAccounts() {
|
|
||||||
return $this->relatedAccounts('refunds', array('order' => 'name'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -221,10 +214,9 @@ class Account extends AppModel {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function collectableAccounts() {
|
function collectableAccounts() {
|
||||||
$accounts = $this->receiptAccounts();
|
$accounts = $this->paymentAccounts();
|
||||||
|
|
||||||
foreach(array($this->nsfAccountID(),
|
foreach(array($this->nsfAccountID(),
|
||||||
$this->badDebtAccountID(),
|
|
||||||
$this->securityDepositAccountID())
|
$this->securityDepositAccountID())
|
||||||
AS $account_id) {
|
AS $account_id) {
|
||||||
$accounts[$account_id] = $this->name($account_id);
|
$accounts[$account_id] = $this->name($account_id);
|
||||||
|
|||||||
@@ -81,9 +81,14 @@ class Customer extends AppModel {
|
|||||||
$this->prEnter(compact('id', 'query'));
|
$this->prEnter(compact('id', 'query'));
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
$query['conditions'][] = array('StatementEntry.customer_id' => $id);
|
if (!isset($query['link']['Customer']))
|
||||||
|
$query['link']['Customer'] = array();
|
||||||
|
if (!isset($query['link']['Customer']['fields']))
|
||||||
|
$query['link']['Customer']['fields'] = array();
|
||||||
|
|
||||||
|
$query['conditions'][] = array('Customer.id' => $id);
|
||||||
$query['conditions'][] = array('StatementEntry.account_id' =>
|
$query['conditions'][] = array('StatementEntry.account_id' =>
|
||||||
$this->StatementEntry->Account->securityDepositAccountID());
|
$this->StatementEntry->LedgerEntry->Account->securityDepositAccountID());
|
||||||
|
|
||||||
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, false, true);
|
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, false, true);
|
||||||
return $this->prReturn($set);
|
return $this->prReturn($set);
|
||||||
@@ -101,12 +106,18 @@ class Customer extends AppModel {
|
|||||||
$this->prEnter(compact('id', 'query'));
|
$this->prEnter(compact('id', 'query'));
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
$query['conditions'][] = array('StatementEntry.customer_id' => $id);
|
if (!isset($query['link']['Lease']))
|
||||||
|
$query['link']['Lease'] = array();
|
||||||
|
if (!isset($query['link']['Lease']['fields']))
|
||||||
|
$query['link']['Lease']['fields'] = array();
|
||||||
|
|
||||||
|
$query['conditions'][] = array('Lease.id' => $id);
|
||||||
$query['conditions'][] = array('StatementEntry.account_id' =>
|
$query['conditions'][] = array('StatementEntry.account_id' =>
|
||||||
$this->StatementEntry->Account->securityDepositAccountID());
|
$this->StatementEntry->LedgerEntry->Account->securityDepositAccountID());
|
||||||
|
|
||||||
$stats = $this->StatementEntry->stats(null, $query);
|
$stats = $this->StatementEntry->stats(null, $query);
|
||||||
return $this->prReturn($stats['account_balance']);
|
$balance = $stats['Charge']['reconciled'] - $stats['Payment']['reconciled'];
|
||||||
|
return $this->prReturn($balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,12 +132,92 @@ class Customer extends AppModel {
|
|||||||
$this->prEnter(compact('id', 'query'));
|
$this->prEnter(compact('id', 'query'));
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
$query['conditions'][] = array('StatementEntry.customer_id' => $id);
|
if (!isset($query['link']['Customer']))
|
||||||
|
$query['link']['Customer'] = array();
|
||||||
|
if (!isset($query['link']['Customer']['fields']))
|
||||||
|
$query['link']['Customer']['fields'] = array();
|
||||||
|
/* if (!isset($query['link']['StatementEntry'])) */
|
||||||
|
/* $query['link']['StatementEntry'] = array(); */
|
||||||
|
/* if (!isset($query['link']['StatementEntry']['Customer'])) */
|
||||||
|
/* $query['link']['StatementEntry']['Customer'] = array(); */
|
||||||
|
/* if (!isset($query['link']['StatementEntry']['Customer']['fields'])) */
|
||||||
|
/* $query['link']['StatementEntry']['Customer']['fields'] = array(); */
|
||||||
|
|
||||||
|
$query['conditions'][] = array('Customer.id' => $id);
|
||||||
|
|
||||||
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, true);
|
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, true);
|
||||||
return $this->prReturn($set);
|
return $this->prReturn($set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: excessPayments
|
||||||
|
* - Returns payments which have not yet been fully utilized
|
||||||
|
*/
|
||||||
|
|
||||||
|
function excessPayments($id, $query = null) {
|
||||||
|
$this->prEnter(compact('id', 'query'));
|
||||||
|
$this->queryInit($query);
|
||||||
|
|
||||||
|
if (!isset($query['link']['StatementEntry']))
|
||||||
|
$query['link']['StatementEntry'] = array();
|
||||||
|
/* if (!isset($query['link']['StatementEntry']['Customer'])) */
|
||||||
|
/* $query['link']['StatementEntry']['Customer'] = array(); */
|
||||||
|
/* if (!isset($query['link']['StatementEntry']['Customer']['fields'])) */
|
||||||
|
/* $query['link']['StatementEntry']['Customer']['fields'] = array(); */
|
||||||
|
|
||||||
|
$query['conditions'][] = array('Customer.id' => $id);
|
||||||
|
|
||||||
|
$set = $this->StatementEntry->reconciledSet('PAYMENT', $query, true);
|
||||||
|
return $this->prReturn($set);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
**************************************************************************
|
||||||
|
* function: details
|
||||||
|
* - Returns detail information for the customer
|
||||||
|
*/
|
||||||
|
|
||||||
|
function details($id = null) {
|
||||||
|
$this->prEnter(compact('id'));
|
||||||
|
|
||||||
|
// Query the DB for need information.
|
||||||
|
$customer = $this->find
|
||||||
|
('first', array
|
||||||
|
('contain' => array
|
||||||
|
(// Models
|
||||||
|
'Contact' =>
|
||||||
|
array('order' => array('Contact.display_name'),
|
||||||
|
// Models
|
||||||
|
'ContactPhone',
|
||||||
|
'ContactEmail',
|
||||||
|
'ContactAddress',
|
||||||
|
),
|
||||||
|
'Lease' =>
|
||||||
|
array('Unit' =>
|
||||||
|
array('order' => array('sort_order'),
|
||||||
|
'fields' => array('id', 'name'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
'conditions' => array('Customer.id' => $id),
|
||||||
|
));
|
||||||
|
|
||||||
|
// Figure out the outstanding balance for this customer
|
||||||
|
$customer['stats'] = $this->stats($id);
|
||||||
|
|
||||||
|
// Figure out the total security deposit for the current lease.
|
||||||
|
$customer['deposits'] = $this->securityDeposits($id);
|
||||||
|
|
||||||
|
return $this->prReturn($customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -203,44 +294,6 @@ class Customer extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: updateLeaseCount
|
|
||||||
* - Updates the internal lease count
|
|
||||||
*/
|
|
||||||
|
|
||||||
function updateLeaseCount($id) {
|
|
||||||
$this->id = $id;
|
|
||||||
|
|
||||||
$lease_count =
|
|
||||||
$this->find('count',
|
|
||||||
array('link' => array('Lease' => array('type' => 'INNER')),
|
|
||||||
'conditions' => array('Customer.id' => $id)));
|
|
||||||
$current_count =
|
|
||||||
$this->find('count',
|
|
||||||
array('link' => array('CurrentLease' => array('type' => 'INNER')),
|
|
||||||
'conditions' => array('Customer.id' => $id)));
|
|
||||||
|
|
||||||
$this->saveField('lease_count', $lease_count);
|
|
||||||
$this->saveField('current_lease_count', $current_count);
|
|
||||||
$this->saveField('past_lease_count', $lease_count - $current_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: balance
|
|
||||||
* - Returns the balance of money owed on the lease
|
|
||||||
*/
|
|
||||||
|
|
||||||
function balance($id) {
|
|
||||||
$stats = $this->stats($id);
|
|
||||||
return $stats['balance'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -267,14 +320,14 @@ class Customer extends AppModel {
|
|||||||
/* $stats = $this->StatementEntry->find */
|
/* $stats = $this->StatementEntry->find */
|
||||||
/* ('first', array */
|
/* ('first', array */
|
||||||
/* ('contain' => false, */
|
/* ('contain' => false, */
|
||||||
/* 'fields' => $this->StatementEntry->chargeDisbursementFields(true), */
|
/* 'fields' => $this->StatementEntry->chargePaymentFields(true), */
|
||||||
/* 'conditions' => array('StatementEntry.customer_id' => $id), */
|
/* 'conditions' => array('StatementEntry.customer_id' => $id), */
|
||||||
/* )); */
|
/* )); */
|
||||||
|
|
||||||
$find_stats = $this->StatementEntry->find
|
$find_stats = $this->StatementEntry->find
|
||||||
('first', array
|
('first', array
|
||||||
('contain' => false,
|
('contain' => false,
|
||||||
'fields' => $this->StatementEntry->chargeDisbursementFields(true),
|
'fields' => $this->StatementEntry->chargePaymentFields(true),
|
||||||
'conditions' => array('StatementEntry.customer_id' => $id),
|
'conditions' => array('StatementEntry.customer_id' => $id),
|
||||||
));
|
));
|
||||||
$find_stats = $find_stats[0];
|
$find_stats = $find_stats[0];
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class Lease extends AppModel {
|
|||||||
'StatementEntry',
|
'StatementEntry',
|
||||||
);
|
);
|
||||||
|
|
||||||
//var $default_log_level = array('log' => 30, 'show' => 15);
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -24,11 +23,21 @@ class Lease extends AppModel {
|
|||||||
$this->prEnter(compact('id', 'query'));
|
$this->prEnter(compact('id', 'query'));
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
$query['conditions'][] = array('StatementEntry.lease_id' => $id);
|
if (!isset($query['link']['Lease']))
|
||||||
|
$query['link']['Lease'] = array();
|
||||||
|
if (!isset($query['link']['Lease']['fields']))
|
||||||
|
$query['link']['Lease']['fields'] = array();
|
||||||
|
|
||||||
|
$query['conditions'][] = array('Lease.id' => $id);
|
||||||
$query['conditions'][] = array('StatementEntry.account_id' =>
|
$query['conditions'][] = array('StatementEntry.account_id' =>
|
||||||
$this->StatementEntry->Account->securityDepositAccountID());
|
$this->StatementEntry->LedgerEntry->Account->securityDepositAccountID());
|
||||||
|
|
||||||
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, false, true);
|
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, false, true);
|
||||||
|
|
||||||
|
/* $set['summary'] = array('total' => $set['summary']['Charge']['total'], */
|
||||||
|
/* 'balance' => $set['summary']['Charge']['reconciled'], */
|
||||||
|
/* ); */
|
||||||
|
|
||||||
return $this->prReturn($set);
|
return $this->prReturn($set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,26 +53,18 @@ class Lease extends AppModel {
|
|||||||
$this->prEnter(compact('id', 'query'));
|
$this->prEnter(compact('id', 'query'));
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
// REVISIT <AP>: 20090807
|
if (!isset($query['link']['Lease']))
|
||||||
// Let's try simplifying the security deposit issue.
|
$query['link']['Lease'] = array();
|
||||||
// Presume that security deposits are NOT used at all,
|
if (!isset($query['link']['Lease']['fields']))
|
||||||
// until the customer moves out of the unit. At that
|
$query['link']['Lease']['fields'] = array();
|
||||||
// time, the ENTIRE deposit is converted to customer
|
|
||||||
// credit. Piece of cake.
|
|
||||||
// For more information, see file revision history,
|
|
||||||
// including the revision just before this, r503.
|
|
||||||
|
|
||||||
$this->id = $id;
|
$query['conditions'][] = array('Lease.id' => $id);
|
||||||
$moveout_date = $this->field('moveout_date');
|
|
||||||
if (!empty($moveout_date))
|
|
||||||
return $this->prReturn(0);
|
|
||||||
|
|
||||||
$query['conditions'][] = array('StatementEntry.lease_id' => $id);
|
|
||||||
$query['conditions'][] = array('StatementEntry.account_id' =>
|
$query['conditions'][] = array('StatementEntry.account_id' =>
|
||||||
$this->StatementEntry->Account->securityDepositAccountID());
|
$this->StatementEntry->LedgerEntry->Account->securityDepositAccountID());
|
||||||
|
|
||||||
$stats = $this->StatementEntry->stats(null, $query);
|
$stats = $this->StatementEntry->stats(null, $query);
|
||||||
return $this->prReturn($stats['Charge']['disbursement']);
|
$balance = $stats['Charge']['reconciled'] - $stats['Payment']['reconciled'];
|
||||||
|
return $this->prReturn($balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -72,18 +73,21 @@ class Lease extends AppModel {
|
|||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: releaseSecurityDeposits
|
* function: releaseSecurityDeposits
|
||||||
* - Releases all security deposits associated with this lease.
|
* - Releases all security deposits associated with this lease.
|
||||||
* That simply makes a disbursement out of them, which can be used
|
* That simply makes a payment out of them, which can be used
|
||||||
* to pay outstanding customer charges, or simply to become
|
* to pay outstanding customer charges, or simply to become
|
||||||
* a customer surplus (customer credit).
|
* a customer surplus (customer credit).
|
||||||
*/
|
*/
|
||||||
function releaseSecurityDeposits($id, $stamp = null, $query = null) {
|
function releaseSecurityDeposits($id, $query = null) {
|
||||||
//$this->prFunctionLevel(30);
|
$this->prFunctionLevel(30);
|
||||||
$this->prEnter(compact('id', 'stamp', 'query'));
|
$this->prEnter(compact('id', 'query'));
|
||||||
|
|
||||||
$secdeps = $this->securityDeposits($id, $query);
|
$secdeps = $this->securityDeposits($id, $query);
|
||||||
$secdeps = $secdeps['entries'];
|
$secdeps = $secdeps['entries'];
|
||||||
$this->pr(20, compact('secdeps'));
|
$this->pr(20, compact('secdeps'));
|
||||||
|
|
||||||
|
$this->securityDepositBalance($id, $query);
|
||||||
|
die();
|
||||||
|
|
||||||
// If there are no paid security deposits, then
|
// If there are no paid security deposits, then
|
||||||
// we can consider all security deposits released.
|
// we can consider all security deposits released.
|
||||||
if (count($secdeps) == 0)
|
if (count($secdeps) == 0)
|
||||||
@@ -91,34 +95,36 @@ class Lease extends AppModel {
|
|||||||
|
|
||||||
// Build a transaction
|
// Build a transaction
|
||||||
$release = array('Transaction' => array(), 'Entry' => array());
|
$release = array('Transaction' => array(), 'Entry' => array());
|
||||||
$release['Transaction']['stamp'] = $stamp;
|
|
||||||
$release['Transaction']['comment'] = "Security Deposit Release";
|
$release['Transaction']['comment'] = "Security Deposit Release";
|
||||||
foreach ($secdeps AS $charge) {
|
foreach ($secdeps AS $charge) {
|
||||||
if ($charge['StatementEntry']['type'] !== 'CHARGE')
|
if ($charge['StatementEntry']['type'] !== 'CHARGE')
|
||||||
die("INTERNAL ERROR: SECURITY DEPOSIT IS NOT CHARGE");
|
die("INTERNAL ERROR: SECURITY DEPOSIT IS NOT CHARGE");
|
||||||
|
|
||||||
// Since security deposits are being released, this also means
|
// Since security deposits are being released, this also means
|
||||||
// any unpaid (or only partially paid) security deposit should
|
// we're reducing any oustanding amount on a security deposit
|
||||||
// have the remaining balance reversed.
|
// since we no longer expect it to be owed.
|
||||||
if ($charge['StatementEntry']['balance'] > 0)
|
// REVISIT <AP>: 20090730
|
||||||
$this->StatementEntry->reverse($charge['StatementEntry']['id'], true, $stamp);
|
// This is kludgy, and I really don't like it. However, this
|
||||||
|
// is not presently something that even happens at the moment,
|
||||||
|
// so this solution will have to work until we come up with
|
||||||
|
// something more robust, like flagging those charges as defunct.
|
||||||
|
if ($charge['StatementEntry']['balance'] > 0) {
|
||||||
|
$this->StatementEntry->id = $charge['StatementEntry']['id'];
|
||||||
|
$this->StatementEntry->saveField('amount', $charge['StatementEntry']['reconciled']);
|
||||||
|
}
|
||||||
|
|
||||||
$release['Entry'][] =
|
$release['Entry'][] =
|
||||||
array('amount' => $charge['StatementEntry']['reconciled'],
|
array('amount' => $charge['StatementEntry']['reconciled'],
|
||||||
'account_id' => $this->StatementEntry->Account->securityDepositAccountID(),
|
'account_id' => $this->StatementEntry->LedgerEntry->Account->securityDepositAccountID(),
|
||||||
'comment' => "Released Security Deposit",
|
'comment' => "Released Security Deposit",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer_id = $secdeps[0]['StatementEntry']['customer_id'];
|
$customer_id = $secdeps[0]['StatementEntry']['customer_id'];
|
||||||
$lease_id = $secdeps[0]['StatementEntry']['lease_id'];
|
$lease_id = $secdeps[0]['StatementEntry']['lease_id'];
|
||||||
|
|
||||||
// Add receipt of the security deposit funds. Do NOT
|
|
||||||
// flag them as part of the lease, as all received funds
|
|
||||||
// are only associated with the customer, for future
|
|
||||||
// (or present) disbursement on any lease.
|
|
||||||
$result = $this->StatementEntry->Transaction->addReceipt
|
$result = $this->StatementEntry->Transaction->addReceipt
|
||||||
($release, $customer_id, null);
|
($release, $customer_id, $lease_id);
|
||||||
|
|
||||||
return $this->prReturn($result);
|
return $this->prReturn($result);
|
||||||
}
|
}
|
||||||
@@ -137,7 +143,7 @@ class Lease extends AppModel {
|
|||||||
|
|
||||||
function rentLastCharges($id) {
|
function rentLastCharges($id) {
|
||||||
$this->prEnter(compact('id'));
|
$this->prEnter(compact('id'));
|
||||||
$rent_account_id = $this->StatementEntry->Account->rentAccountID();
|
$rent_account_id = $this->StatementEntry->LedgerEntry->Account->rentAccountID();
|
||||||
$entries = $this->find
|
$entries = $this->find
|
||||||
('all',
|
('all',
|
||||||
array('link' =>
|
array('link' =>
|
||||||
@@ -168,35 +174,6 @@ class Lease extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: lateCharges
|
|
||||||
* - Returns a list of late charges from this lease
|
|
||||||
*/
|
|
||||||
|
|
||||||
function lateCharges($id) {
|
|
||||||
$this->prEnter(compact('id'));
|
|
||||||
$late_account_id = $this->StatementEntry->Account->lateChargeAccountID();
|
|
||||||
$entries = $this->StatementEntry->find
|
|
||||||
('all',
|
|
||||||
array('link' =>
|
|
||||||
array(// Models
|
|
||||||
'Lease',
|
|
||||||
),
|
|
||||||
|
|
||||||
//'fields' => array('id', 'amount', 'effective_date', 'through_date'),
|
|
||||||
'conditions' => array(array('Lease.id' => $id),
|
|
||||||
array('StatementEntry.type' => 'CHARGE'),
|
|
||||||
array('StatementEntry.account_id' => $late_account_id),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
return $this->prReturn($entries);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -244,7 +221,7 @@ class Lease extends AppModel {
|
|||||||
|
|
||||||
function rentPaidThrough($id) {
|
function rentPaidThrough($id) {
|
||||||
$this->prEnter(compact('id'));
|
$this->prEnter(compact('id'));
|
||||||
$rent_account_id = $this->StatementEntry->Account->rentAccountID();
|
$rent_account_id = $this->StatementEntry->LedgerEntry->Account->rentAccountID();
|
||||||
|
|
||||||
// First, see if we can find any unpaid entries. Of course,
|
// First, see if we can find any unpaid entries. Of course,
|
||||||
// the first unpaid entry gives us a very direct indication
|
// the first unpaid entry gives us a very direct indication
|
||||||
@@ -296,222 +273,6 @@ class Lease extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: assessMonthlyRent
|
|
||||||
* - Charges rent for the month, if not already charged.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function assessMonthlyRent($id, $date = null) {
|
|
||||||
$this->prEnter(compact('id', 'date'));
|
|
||||||
$this->id = $id;
|
|
||||||
|
|
||||||
if (empty($date))
|
|
||||||
$date = time();
|
|
||||||
|
|
||||||
if (is_string($date))
|
|
||||||
$date = strtotime($date);
|
|
||||||
|
|
||||||
// REVISIT <AP>: 20090808
|
|
||||||
// Anniversary Billing not supported
|
|
||||||
$anniversary = 0 && $this->field('anniversary_billing');
|
|
||||||
if (empty($anniversary)) {
|
|
||||||
$date_parts = getdate($date);
|
|
||||||
$date = mktime(0, 0, 0, $date_parts['mon'], 1, $date_parts['year']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure we're not trying to assess rent on a closed lease
|
|
||||||
$close_date = $this->field('close_date');
|
|
||||||
$this->pr(17, compact('close_date'));
|
|
||||||
if (!empty($close_date))
|
|
||||||
return $this->prReturn(null);
|
|
||||||
|
|
||||||
// Don't assess rent after customer has moved out
|
|
||||||
$moveout_date = $this->field('moveout_date');
|
|
||||||
$this->pr(17, compact('moveout_date'));
|
|
||||||
if (!empty($moveout_date) && strtotime($moveout_date) < $date)
|
|
||||||
return $this->prReturn(null);
|
|
||||||
|
|
||||||
// Determine when the customer has already been charged through
|
|
||||||
// and, of course, don't charge them if they've already been.
|
|
||||||
$charge_through_date = strtotime($this->rentChargeThrough($id));
|
|
||||||
$this->pr(17, compact('date', 'charge_through_date')
|
|
||||||
+ array('date_str' => date('Y-m-d', $date),
|
|
||||||
'charge_through_date_str' => date('Y-m-d', $charge_through_date)));
|
|
||||||
if ($charge_through_date >= $date)
|
|
||||||
return $this->prReturn(null);
|
|
||||||
|
|
||||||
// OK, it seems we're going to go ahead and charge the customer
|
|
||||||
// on this lease. Calculate the new charge through date, which
|
|
||||||
// is 1 day shy of 1 month from $date. For example, if we're
|
|
||||||
// charging for 8/1/09, charge through will be 8/31/09, and
|
|
||||||
// charging for 8/15/09, charge through will be 9/14/09.
|
|
||||||
$date_parts = getdate($date);
|
|
||||||
$charge_through_date = mktime(0, 0, 0,
|
|
||||||
$date_parts['mon']+1,
|
|
||||||
$date_parts['mday']-1,
|
|
||||||
$date_parts['year']);
|
|
||||||
|
|
||||||
// Build the invoice transaction
|
|
||||||
$invoice = array('Transaction' => array(), 'Entry' => array());
|
|
||||||
// REVISIT <AP>: 20090808
|
|
||||||
// Keeping Transaction.stamp until the existing facility
|
|
||||||
// is up to date. Then we want the stamp to be now()
|
|
||||||
// (and so can just delete the next line).
|
|
||||||
$invoice['Transaction']['stamp'] = date('Y-m-d', $date);
|
|
||||||
$invoice['Entry'][] =
|
|
||||||
array('effective_date' => date('Y-m-d', $date),
|
|
||||||
'through_date' => date('Y-m-d', $charge_through_date),
|
|
||||||
'amount' => $this->field('rent'),
|
|
||||||
'account_id' => $this->StatementEntry->Account->rentAccountId(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Record the invoice and return the result
|
|
||||||
$this->pr(21, compact('invoice'));
|
|
||||||
$result = $this->StatementEntry->Transaction->addInvoice
|
|
||||||
($invoice, null, $id);
|
|
||||||
return $this->prReturn($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: assessMonthlyRentAll
|
|
||||||
* - Ensures rent has been charged on all open leases
|
|
||||||
*/
|
|
||||||
|
|
||||||
function assessMonthlyRentAll($date = null) {
|
|
||||||
$this->prEnter(compact('date'));
|
|
||||||
$leases = $this->find
|
|
||||||
('all', array('contain' => false,
|
|
||||||
'conditions' => array('Lease.close_date' => null),
|
|
||||||
));
|
|
||||||
|
|
||||||
$ret = array('Lease' => array());
|
|
||||||
foreach ($leases AS $lease) {
|
|
||||||
$result = $this->assessMonthlyRent($lease['Lease']['id'], $date);
|
|
||||||
$ret['Lease'][$lease['Lease']['id']] = $result;
|
|
||||||
if ($result['error'])
|
|
||||||
$ret['error'] = true;
|
|
||||||
}
|
|
||||||
return $this->prReturn($ret + array('error' => false));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: assessMonthlyLate
|
|
||||||
* - Assess late charges for the month, if not already charged.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function assessMonthlyLate($id, $date = null) {
|
|
||||||
$this->prFunctionLevel(25);
|
|
||||||
$this->prEnter(compact('id', 'date'));
|
|
||||||
$this->id = $id;
|
|
||||||
|
|
||||||
if (empty($date))
|
|
||||||
$date = time();
|
|
||||||
|
|
||||||
if (is_string($date))
|
|
||||||
$date = strtotime($date);
|
|
||||||
|
|
||||||
// REVISIT <AP>: 20090808
|
|
||||||
// Anniversary Billing not supported
|
|
||||||
$anniversary = 0 && $this->field('anniversary_billing');
|
|
||||||
if (empty($anniversary)) {
|
|
||||||
$date_parts = getdate($date);
|
|
||||||
$date = mktime(0, 0, 0, $date_parts['mon'], 11, $date_parts['year']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure we're not trying to assess late charges on a closed lease
|
|
||||||
$close_date = $this->field('close_date');
|
|
||||||
$this->pr(17, compact('close_date'));
|
|
||||||
if (!empty($close_date))
|
|
||||||
return $this->prReturn(null);
|
|
||||||
|
|
||||||
// Don't assess late charges after customer has moved out
|
|
||||||
$moveout_date = $this->field('moveout_date');
|
|
||||||
$this->pr(17, compact('moveout_date'));
|
|
||||||
if (!empty($moveout_date) && strtotime($moveout_date) < $date)
|
|
||||||
return $this->prReturn(null);
|
|
||||||
|
|
||||||
// Determine when the customer has been charged through for rent
|
|
||||||
// and don't mark them as late if they haven't even been charged rent
|
|
||||||
$charge_through_date = strtotime($this->rentChargeThrough($id));
|
|
||||||
$this->pr(17, compact('date', 'charge_through_date')
|
|
||||||
+ array('date_str' => date('Y-m-d', $date),
|
|
||||||
'charge_through_date_str' => date('Y-m-d', $charge_through_date)));
|
|
||||||
if ($charge_through_date <= $date)
|
|
||||||
return $this->prReturn(null);
|
|
||||||
|
|
||||||
// Determine if the customer is actually late. This is based on
|
|
||||||
// when they've paid through, plus 10 days before they're late.
|
|
||||||
$paid_through_date = strtotime($this->rentPaidThrough($id));
|
|
||||||
$this->pr(17, compact('date', 'paid_through_date')
|
|
||||||
+ array('date_str' => date('Y-m-d', $date),
|
|
||||||
'paid_through_date_str' => date('Y-m-d', $paid_through_date)));
|
|
||||||
$date_parts = getdate($paid_through_date);
|
|
||||||
$paid_through_date = mktime(0, 0, 0, $date_parts['mon'], $date_parts['mday']+10, $date_parts['year']);
|
|
||||||
if ($paid_through_date >= $date)
|
|
||||||
return $this->prReturn(null);
|
|
||||||
|
|
||||||
// Determine if the customer has already been charged a late fee
|
|
||||||
// and, of course, don't charge them if they've already been.
|
|
||||||
$late_charges = $this->lateCharges($id);
|
|
||||||
foreach ($late_charges AS $late) {
|
|
||||||
if (strtotime($late['StatementEntry']['effective_date']) == $date)
|
|
||||||
return $this->prReturn(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the invoice transaction
|
|
||||||
$invoice = array('Transaction' => array(), 'Entry' => array());
|
|
||||||
// REVISIT <AP>: 20090808
|
|
||||||
// Keeping Transaction.stamp until the existing facility
|
|
||||||
// is up to date. Then we want the stamp to be now()
|
|
||||||
// (and so can just delete the next line).
|
|
||||||
$invoice['Transaction']['stamp'] = date('Y-m-d', $date);
|
|
||||||
$invoice['Entry'][] =
|
|
||||||
array('effective_date' => date('Y-m-d', $date),
|
|
||||||
'amount' => 10,
|
|
||||||
'account_id' => $this->StatementEntry->Account->lateChargeAccountId(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Record the invoice and return the result
|
|
||||||
$this->pr(21, compact('invoice'));
|
|
||||||
$result = $this->StatementEntry->Transaction->addInvoice
|
|
||||||
($invoice, null, $id);
|
|
||||||
return $this->prReturn($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: assessMonthlyLateAll
|
|
||||||
* - Ensures rent has been charged on all open leases
|
|
||||||
*/
|
|
||||||
|
|
||||||
function assessMonthlyLateAll($date = null) {
|
|
||||||
$this->prEnter(compact('date'));
|
|
||||||
$leases = $this->find
|
|
||||||
('all', array('contain' => false,
|
|
||||||
'conditions' => array('Lease.close_date' => null),
|
|
||||||
));
|
|
||||||
|
|
||||||
$ret = array('Lease' => array());
|
|
||||||
foreach ($leases AS $lease) {
|
|
||||||
$result = $this->assessMonthlyLate($lease['Lease']['id'], $date);
|
|
||||||
$ret['Lease'][$lease['Lease']['id']] = $result;
|
|
||||||
if ($result['error'])
|
|
||||||
$ret['error'] = true;
|
|
||||||
}
|
|
||||||
return $this->prReturn($ret + array('error' => false));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -584,10 +345,7 @@ class Lease extends AppModel {
|
|||||||
// Set the lease number to be the same as the lease ID
|
// Set the lease number to be the same as the lease ID
|
||||||
$this->id;
|
$this->id;
|
||||||
$this->saveField('number', $this->id);
|
$this->saveField('number', $this->id);
|
||||||
|
|
||||||
// Update the current lease count for the customer
|
|
||||||
$this->Customer->updateLeaseCount($customer_id);
|
|
||||||
|
|
||||||
// Update the unit status
|
// Update the unit status
|
||||||
$this->Unit->updateStatus($unit_id, 'OCCUPIED');
|
$this->Unit->updateStatus($unit_id, 'OCCUPIED');
|
||||||
|
|
||||||
@@ -628,16 +386,10 @@ class Lease extends AppModel {
|
|||||||
// Save it!
|
// Save it!
|
||||||
$this->save($this->data, false);
|
$this->save($this->data, false);
|
||||||
|
|
||||||
// Release the security deposit(s)
|
|
||||||
$this->releaseSecurityDeposits($id, $stamp);
|
|
||||||
|
|
||||||
// Close the lease, if so requested
|
// Close the lease, if so requested
|
||||||
if ($close)
|
if ($close)
|
||||||
$this->close($id, $stamp);
|
$this->close($id, $stamp);
|
||||||
|
|
||||||
// Update the current lease count for the customer
|
|
||||||
$this->Customer->updateLeaseCount($this->field('customer_id'));
|
|
||||||
|
|
||||||
// Finally, update the unit status
|
// Finally, update the unit status
|
||||||
$this->recursive = -1;
|
$this->recursive = -1;
|
||||||
$this->read();
|
$this->read();
|
||||||
@@ -671,10 +423,6 @@ class Lease extends AppModel {
|
|||||||
|
|
||||||
// Save it!
|
// Save it!
|
||||||
$this->save($this->data, false);
|
$this->save($this->data, false);
|
||||||
|
|
||||||
// Update the current lease count for the customer
|
|
||||||
$this->Customer->updateLeaseCount($this->field('customer_id'));
|
|
||||||
|
|
||||||
return $this->prReturn(true);
|
return $this->prReturn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,13 +448,12 @@ class Lease extends AppModel {
|
|||||||
if (isset($this->data['Lease']['close_date']))
|
if (isset($this->data['Lease']['close_date']))
|
||||||
return $this->prReturn(false);
|
return $this->prReturn(false);
|
||||||
|
|
||||||
// A lease can only be closed if there are no outstanding
|
$deposit_balance = $this->securityDepositBalance($id);
|
||||||
// security deposits ...
|
$stats = $this->stats($id);
|
||||||
if ($this->securityDepositBalance($id) != 0)
|
|
||||||
return $this->prReturn(false);
|
|
||||||
|
|
||||||
// ... and if the account balance is zero.
|
// A lease can only be closed if there are no outstanding
|
||||||
if ($this->balance($id) != 0)
|
// security deposits, and if the account balance is zero.
|
||||||
|
if ($deposit_balance != 0)
|
||||||
return $this->prReturn(false);
|
return $this->prReturn(false);
|
||||||
|
|
||||||
// Apparently this lease meets all the criteria!
|
// Apparently this lease meets all the criteria!
|
||||||
@@ -717,45 +464,12 @@ class Lease extends AppModel {
|
|||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: refund
|
* function: addCharge
|
||||||
* - Marks any lease balance as payable to the customer.
|
* - Adds an additional charge to the lease
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function refund($id, $stamp = null) {
|
function addCharge($id, $charge) {
|
||||||
$this->prEnter(compact('id'));
|
|
||||||
$balance = $this->balance($id);
|
|
||||||
|
|
||||||
if ($balance >= 0)
|
|
||||||
return $this->prReturn(array('error' => true));
|
|
||||||
|
|
||||||
$balance *= -1;
|
|
||||||
|
|
||||||
// Build a transaction
|
|
||||||
$refund = array('Transaction' => array(), 'Entry' => array());
|
|
||||||
$refund['Transaction']['stamp'] = $stamp;
|
|
||||||
$refund['Transaction']['comment'] = "Lease Refund";
|
|
||||||
|
|
||||||
$refund['Entry'][] =
|
|
||||||
array('amount' => $balance);
|
|
||||||
|
|
||||||
$result = $this->StatementEntry->Transaction->addRefund
|
|
||||||
($refund, null, $id);
|
|
||||||
|
|
||||||
return $this->prReturn($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: balance
|
|
||||||
* - Returns the balance of money owed on the lease
|
|
||||||
*/
|
|
||||||
|
|
||||||
function balance($id) {
|
|
||||||
$this->prEnter(compact('id'));
|
|
||||||
$stats = $this->stats($id);
|
|
||||||
return $this->prReturn($stats['balance']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -771,14 +485,42 @@ class Lease extends AppModel {
|
|||||||
if (!$id)
|
if (!$id)
|
||||||
return $this->prReturn(null);
|
return $this->prReturn(null);
|
||||||
|
|
||||||
$find_stats = $this->StatementEntry->find
|
$this->queryInit($query);
|
||||||
('first', array
|
|
||||||
('contain' => false,
|
//$query['link'] = array('Lease' => $query['link']);
|
||||||
'fields' => $this->StatementEntry->chargeDisbursementFields(true),
|
/* if (!isset($query['link']['StatementEntry'])) */
|
||||||
'conditions' => array('StatementEntry.lease_id' => $id),
|
/* $query['link']['StatementEntry'] = array(); */
|
||||||
));
|
/* if (!isset($query['link']['StatementEntry']['ChargeEntry'])) */
|
||||||
$find_stats = $find_stats[0];
|
/* $query['link']['StatementEntry']['ChargeEntry'] = array(); */
|
||||||
return $this->prReturn($find_stats);
|
|
||||||
|
/* $query['link']['StatementEntry']['fields'] = array(); */
|
||||||
|
/* $query['link']['ChargeEntry']['fields'] = array(); */
|
||||||
|
/* $query['link']['ChargeEntry']['Account']['fields'] = array(); */
|
||||||
|
/* $query['link']['ChargeEntry']['StatementEntry']['fields'] = array(); */
|
||||||
|
/* $query['link']['ChargeEntry']['StatementEntry']['Invoice']['fields'] = array(); */
|
||||||
|
|
||||||
|
if (!isset($query['fields']))
|
||||||
|
$query['fields'] = array();
|
||||||
|
|
||||||
|
$query['fields'] = array_merge($query['fields'],
|
||||||
|
$this->StatementEntry->chargePaymentFields(true));
|
||||||
|
|
||||||
|
$query['conditions'][] = array('StatementEntry.lease_id' => $id);
|
||||||
|
|
||||||
|
$query['group'] = null;
|
||||||
|
|
||||||
|
$stats = $this->StatementEntry->find('first', $query);
|
||||||
|
//$this->pr(20, compact('query', 'stats'));
|
||||||
|
|
||||||
|
// The fields are all tucked into the [0] index,
|
||||||
|
// and the rest of the array is useless (empty).
|
||||||
|
$stats = $stats[0];
|
||||||
|
|
||||||
|
// Make sure we have a non-null balance
|
||||||
|
if (!isset($stats['balance']))
|
||||||
|
$stats['balance'] = 0;
|
||||||
|
|
||||||
|
return $this->prReturn($stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,12 @@ class LedgerEntry extends AppModel {
|
|||||||
'foreignKey' => 'debit_entry_id',
|
'foreignKey' => 'debit_entry_id',
|
||||||
'associationForeignKey' => 'credit_entry_id',
|
'associationForeignKey' => 'credit_entry_id',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
//
|
||||||
|
'StatementEntry' => array(
|
||||||
|
'joinTable' => 'statement_fractions',
|
||||||
|
'fields' => 'StatementFraction.amount',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@@ -170,7 +176,7 @@ class LedgerEntry extends AppModel {
|
|||||||
|
|
||||||
//pr(array('stats()', compact('id', 'query', 'set')));
|
//pr(array('stats()', compact('id', 'query', 'set')));
|
||||||
|
|
||||||
$rtypes = array('charge', 'disbursement',
|
$rtypes = array('charge', 'payment',
|
||||||
// 'debit', 'credit',
|
// 'debit', 'credit',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -178,8 +184,10 @@ class LedgerEntry extends AppModel {
|
|||||||
foreach($rtypes AS $rtype) {
|
foreach($rtypes AS $rtype) {
|
||||||
$Rtype = ucfirst($rtype);
|
$Rtype = ucfirst($rtype);
|
||||||
|
|
||||||
if (($rtype == 'charge' && (!isset($set) || $set == 'DISBURSEMENT')) ||
|
if (($rtype == 'charge' && (!isset($set) || $set == 'PAYMENT')) ||
|
||||||
($rtype == 'disbursement' && (!isset($set) || $set == 'CHARGE'))
|
($rtype == 'payment' && (!isset($set) || $set == 'CHARGE'))
|
||||||
|
/* ($rtype == 'debit' && (!isset($set) || $set == 'CREDIT')) || */
|
||||||
|
/* ($rtype == 'credit' && (!isset($set) || $set == 'DEBIT')) */
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$rquery = $query;
|
$rquery = $query;
|
||||||
|
|||||||
@@ -5,81 +5,55 @@ class StatementEntry extends AppModel {
|
|||||||
'Transaction',
|
'Transaction',
|
||||||
'Customer',
|
'Customer',
|
||||||
'Lease',
|
'Lease',
|
||||||
'Account',
|
|
||||||
|
|
||||||
// The charge to which this disbursement applies (if it is one)
|
// The charge to which this payment applies (if it is one)
|
||||||
'ChargeEntry' => array(
|
'ChargeEntry' => array(
|
||||||
'className' => 'StatementEntry',
|
'className' => 'StatementEntry',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
var $hasMany = array(
|
var $hasMany = array(
|
||||||
// The disbursements that apply to this charge (if it is one)
|
// The payments that apply to this charge (if it is one)
|
||||||
'DisbursementEntry' => array(
|
'PaymentEntry' => array(
|
||||||
'className' => 'StatementEntry',
|
'className' => 'StatementEntry',
|
||||||
'foreignKey' => 'charge_entry_id',
|
'foreignKey' => 'charge_entry_id',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'StatementFraction',
|
||||||
);
|
);
|
||||||
|
|
||||||
//var $default_log_level = array('log' => 30, 'show' => 15);
|
var $hasAndBelongsToMany = array(
|
||||||
|
'LedgerEntry' => array(
|
||||||
|
'joinTable' => 'statement_fractions',
|
||||||
|
//'fields' => 'StatementFraction.amount',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
//var $default_log_level = 30;
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: debit/creditTypes
|
* function: chargePaymentFields
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function debitTypes() {
|
|
||||||
return array('CHARGE', 'PAYMENT', 'REFUND');
|
|
||||||
}
|
|
||||||
|
|
||||||
function creditTypes() {
|
|
||||||
return array('DISBURSEMENT', 'WAIVER', 'REVERSAL', 'WRITEOFF', 'SURPLUS');
|
|
||||||
}
|
|
||||||
|
|
||||||
function voidTypes() {
|
|
||||||
return array('VOID');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: chargeDisbursementFields
|
|
||||||
*/
|
|
||||||
|
|
||||||
function chargeDisbursementFields($sum = false, $entry_name = 'StatementEntry') {
|
|
||||||
$debits = $this->debitTypes();
|
|
||||||
$credits = $this->creditTypes();
|
|
||||||
$voids = $this->voidTypes();
|
|
||||||
|
|
||||||
foreach ($debits AS &$enum)
|
|
||||||
$enum = "'" . $enum . "'";
|
|
||||||
foreach ($credits AS &$enum)
|
|
||||||
$enum = "'" . $enum . "'";
|
|
||||||
foreach ($voids AS &$enum)
|
|
||||||
$enum = "'" . $enum . "'";
|
|
||||||
|
|
||||||
$debit_set = implode(", ", $debits);
|
|
||||||
$credit_set = implode(", ", $credits);
|
|
||||||
$void_set = implode(", ", $voids);
|
|
||||||
|
|
||||||
|
function chargePaymentFields($sum = false, $entry_name = 'StatementEntry') {
|
||||||
$fields = array
|
$fields = array
|
||||||
(
|
(
|
||||||
($sum ? 'SUM(' : '') .
|
($sum ? 'SUM(' : '') .
|
||||||
"IF({$entry_name}.type IN ({$debit_set})," .
|
"IF({$entry_name}.type = 'CHARGE'," .
|
||||||
" {$entry_name}.amount, NULL)" .
|
" {$entry_name}.amount, NULL)" .
|
||||||
($sum ? ')' : '') . ' AS charge' . ($sum ? 's' : ''),
|
($sum ? ')' : '') . ' AS charge' . ($sum ? 's' : ''),
|
||||||
|
|
||||||
($sum ? 'SUM(' : '') .
|
($sum ? 'SUM(' : '') .
|
||||||
"IF({$entry_name}.type IN({$credit_set})," .
|
"IF({$entry_name}.type = 'PAYMENT' OR {$entry_name}.type = 'SURPLUS'," .
|
||||||
" {$entry_name}.amount, NULL)" .
|
" {$entry_name}.amount, NULL)" .
|
||||||
($sum ? ')' : '') . ' AS disbursement' . ($sum ? 's' : ''),
|
($sum ? ')' : '') . ' AS payment' . ($sum ? 's' : ''),
|
||||||
|
|
||||||
($sum ? 'SUM(' : '') .
|
($sum ? 'SUM(' : '') .
|
||||||
"IF({$entry_name}.type IN ({$debit_set}), 1," .
|
"IF({$entry_name}.type = 'CHARGE', 1," .
|
||||||
" IF({$entry_name}.type IN ({$credit_set}), -1, 0))" .
|
" IF({$entry_name}.type = 'PAYMENT' OR {$entry_name}.type = 'SURPLUS', -1, 0))" .
|
||||||
" * IF({$entry_name}.amount, {$entry_name}.amount, 0)" .
|
" * IF({$entry_name}.amount, {$entry_name}.amount, 0)" .
|
||||||
($sum ? ')' : '') . ' AS balance',
|
($sum ? ')' : '') . ' AS balance',
|
||||||
);
|
);
|
||||||
@@ -99,12 +73,11 @@ class StatementEntry extends AppModel {
|
|||||||
* (not in a pre-existing statement entry)
|
* (not in a pre-existing statement entry)
|
||||||
*/
|
*/
|
||||||
function verifyStatementEntry($entry) {
|
function verifyStatementEntry($entry) {
|
||||||
$this->prFunctionLevel(10);
|
$this->prFunctionLevel(30);
|
||||||
$this->prEnter(compact('entry'));
|
$this->prEnter(compact('entry'));
|
||||||
|
|
||||||
if (empty($entry['type']) ||
|
if (empty($entry['type']) ||
|
||||||
//empty($entry['effective_date']) ||
|
//empty($entry['effective_date']) ||
|
||||||
empty($entry['account_id']) ||
|
|
||||||
empty($entry['amount'])
|
empty($entry['amount'])
|
||||||
) {
|
) {
|
||||||
return $this->prReturn(false);
|
return $this->prReturn(false);
|
||||||
@@ -125,142 +98,136 @@ class StatementEntry extends AppModel {
|
|||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
if (!$this->verifyStatementEntry($entry))
|
if (!$this->verifyStatementEntry($entry))
|
||||||
return $this->prReturn(array('error' => true, 'verify_data' => $entry) + $ret);
|
return array('error' => true, 'verify_data' => $entry) + $ret;
|
||||||
|
|
||||||
$this->pr(20, array('checkpoint' => 'Pre-Save')
|
$this->pr(20, array('checkpoint' => 'Pre-Save')
|
||||||
+ compact('entry'));
|
+ compact('entry'));
|
||||||
|
|
||||||
$this->create();
|
$this->create();
|
||||||
if (!$this->save($entry))
|
if (!$this->save($entry))
|
||||||
return $this->prReturn(array('error' => true, 'save_data' => $entry) + $ret);
|
return array('error' => true, 'save_data' => $entry) + $ret;
|
||||||
|
|
||||||
|
foreach ($entry['Fraction'] AS $fraction) {
|
||||||
|
$fraction['statement_entry_id'] = $this->id;
|
||||||
|
$this->StatementFraction->id = null;
|
||||||
|
$this->StatementFraction->save($fraction);
|
||||||
|
}
|
||||||
|
|
||||||
$ret['statement_entry_id'] = $this->id;
|
$ret['statement_entry_id'] = $this->id;
|
||||||
return $this->prReturn($ret + array('error' => false));
|
return $this->prReturn($ret + array('error' => false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: waive
|
|
||||||
* - Waives the charge balance
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function waive($id, $stamp = null) {
|
|
||||||
$this->prEnter(compact('id', 'stamp'));
|
|
||||||
|
|
||||||
// Get the basic information about the entry to be waived.
|
|
||||||
$this->recursive = -1;
|
|
||||||
$charge = $this->read(null, $id);
|
|
||||||
$charge = $charge['StatementEntry'];
|
|
||||||
|
|
||||||
if ($charge['type'] !== 'CHARGE')
|
|
||||||
INTERNAL_ERROR("Waiver item is not CHARGE.");
|
|
||||||
|
|
||||||
// Query the stats to get the remaining balance
|
|
||||||
$stats = $this->stats($id);
|
|
||||||
|
|
||||||
// Build a transaction
|
|
||||||
$waiver = array('Transaction' => array(), 'Entry' => array());
|
|
||||||
$waiver['Transaction']['stamp'] = $stamp;
|
|
||||||
$waiver['Transaction']['comment'] = "Charge Waiver";
|
|
||||||
|
|
||||||
// Add the charge waiver
|
|
||||||
$waiver['Entry'][] =
|
|
||||||
array('amount' => $stats['Charge']['balance'],
|
|
||||||
'account_id' => $this->Account->waiverAccountID(),
|
|
||||||
'comment' => null,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Record the waiver transaction
|
|
||||||
return $this->prReturn($this->Transaction->addWaiver
|
|
||||||
($waiver, $id, $charge['customer_id'], $charge['lease_id']));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: reverse
|
* function: reverse
|
||||||
* - Reverses the charges
|
* - Reverses the charges
|
||||||
*
|
*
|
||||||
|
* SAMPLE MOVE IN w/ PRE PAYMENT
|
||||||
|
* DEPOSIT RENT A/R RECEIPT CHECK PETTY BANK
|
||||||
|
* ------- ------- ------- ------- ------- ------- -------
|
||||||
|
* |25 | 25| | | | |
|
||||||
|
* | |20 20| | | | |
|
||||||
|
* | |20 20| | | | |
|
||||||
|
* | |20 20| | | | |
|
||||||
|
* | | |25 25| | | |
|
||||||
|
* | | |20 20| | | |
|
||||||
|
* | | |20 20| | | |
|
||||||
|
* | | |20 20| | | |
|
||||||
|
* | | | |85 85| | |
|
||||||
|
* | | | | |85 | 85|
|
||||||
|
|
||||||
|
* MOVE OUT and REFUND FINAL MONTH
|
||||||
|
* DEPOSIT RENT C/P RECEIPT CHECK PETTY BANK
|
||||||
|
* ------- ------- ------- ------- ------- ------- -------
|
||||||
|
* 25| | |25 | | | | t20 e20a
|
||||||
|
* | 20| |20 | | | | t20 e20b
|
||||||
|
|
||||||
|
* -ONE REFUND CHECK-
|
||||||
|
* | | 25| |25 | | | t30 e30a
|
||||||
|
* | | 20| |20 | | | t30 e30b
|
||||||
|
* | | | 45| | | |45 t40 e40
|
||||||
|
* -OR MULTIPLE-
|
||||||
|
* | | 15| |15 | | | t50a e50a
|
||||||
|
* | | | 15| | |15 | t60a e60a
|
||||||
|
* | | 30| |30 | | | t50b e50b
|
||||||
|
* | | | 30| | | |30 t60b e60b
|
||||||
|
* | | | | | | |
|
||||||
|
|
||||||
|
|
||||||
|
OPTION 1
|
||||||
|
* |-25 | -25| | | | |
|
||||||
|
* | |-20 -20| | | | |
|
||||||
|
* | | |-25 -25| | | |
|
||||||
|
* | | |-20 -20| | | |
|
||||||
|
|
||||||
|
OPTION 2
|
||||||
|
* |-25 | | -25| | | |
|
||||||
|
* | |-20 | -20| | | |
|
||||||
|
* | | | |-15 | -15| |
|
||||||
|
* | | | |-30 | | -30|
|
||||||
|
* | | | | | | |
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function reverse($id, $balance = false, $stamp = null) {
|
function reverse($ledger_entries, $stamp = null) {
|
||||||
$this->prEnter(compact('id', 'balance', 'stamp'));
|
$this->prEnter(compact('ledger_entries', 'stamp'));
|
||||||
|
|
||||||
$ret = array();
|
// If the user only wants to reverse one ID, we'll allow it
|
||||||
|
if (!is_array($ledger_entries))
|
||||||
|
$ledger_entries = $this->find
|
||||||
|
('all', array
|
||||||
|
('contain' => false,
|
||||||
|
'conditions' => array('Entry.id' => $ledger_entries)));
|
||||||
|
|
||||||
// Get the basic information about the entry to be reversed.
|
$A = new Account();
|
||||||
$this->recursive = -1;
|
|
||||||
$charge = $this->read(null, $id);
|
|
||||||
$charge = $charge['StatementEntry'];
|
|
||||||
|
|
||||||
if ($charge['type'] !== 'CHARGE')
|
$ar_account_id = $A->accountReceivableAccountID();
|
||||||
INTERNAL_ERROR("Reversal item is not CHARGE.");
|
$receipt_account_id = $A->receiptAccountID();
|
||||||
|
|
||||||
$voided_entry_transactions = array();
|
$transaction_id = null;
|
||||||
$reconciled = $this->reconciledEntries($id);
|
foreach ($ledger_entries AS $entry) {
|
||||||
$this->pr(21, compact('reconciled'));
|
$entry = $entry['Entry'];
|
||||||
|
$amount = -1*$entry['amount'];
|
||||||
|
|
||||||
if ($reconciled && !$balance) {
|
if (isset($entry['credit_account_id']))
|
||||||
foreach ($reconciled['entries'] AS $entry) {
|
$refund_account_id = $entry['credit_account_id'];
|
||||||
if ($entry['DisbursementEntry']['type'] === 'REVERSAL')
|
elseif (isset($entry['CreditLedger']['Account']['id']))
|
||||||
INTERNAL_ERROR("Charge has already been reversed");
|
$refund_account_id = $entry['CreditLedger']['Account']['id'];
|
||||||
|
elseif (isset($entry['credit_ledger_id']))
|
||||||
|
$refund_account_id = $this->Ledger->accountID($entry['credit_ledger_id']);
|
||||||
|
else
|
||||||
|
return $this->prReturn(null);
|
||||||
|
|
||||||
$voided_entry_transactions[$entry['DisbursementEntry']['transaction_id']]
|
// post new refund in the income account
|
||||||
= array_intersect_key($entry['DisbursementEntry'],
|
$ids = $A->postEntry
|
||||||
array('customer_id'=>1, 'lease_id'=>1));
|
(array('transaction_id' => $transaction_id),
|
||||||
|
|
||||||
$this->del($entry['DisbursementEntry']['id']);
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$DE = new StatementEntry();
|
|
||||||
$DE->id = $entry['DisbursementEntry']['id'];
|
|
||||||
$DE->saveField('type', 'VOID');
|
|
||||||
$DE->saveField('charge_entry_id', null);
|
|
||||||
}
|
|
||||||
$this->pr(17, compact('voided_entry_transactions'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query the stats to get the remaining balance
|
|
||||||
$stats = $this->stats($id);
|
|
||||||
|
|
||||||
// Build a transaction
|
|
||||||
$reversal = array('Transaction' => array(), 'Entry' => array());
|
|
||||||
$reversal['Transaction']['stamp'] = $stamp;
|
|
||||||
$reversal['Transaction']['comment'] = "Credit Note: Charge Reversal";
|
|
||||||
|
|
||||||
// Add the charge reversal
|
|
||||||
$reversal['Entry'][] =
|
|
||||||
array('amount' => $stats['Charge']['balance'],
|
|
||||||
'account_id' => $charge['account_id'],
|
|
||||||
'comment' => 'Charge Reversal',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Record the reversal transaction
|
|
||||||
$result = $this->Transaction->addReversal
|
|
||||||
($reversal, $id, $charge['customer_id'], $charge['lease_id']);
|
|
||||||
$this->pr(21, compact('result'));
|
|
||||||
$ret['reversal'] = $result;
|
|
||||||
if ($result['error'])
|
|
||||||
$ret['error'] = true;
|
|
||||||
|
|
||||||
foreach ($voided_entry_transactions AS $transaction_id => $tx) {
|
|
||||||
$result = $this->assignCredits
|
|
||||||
(null,
|
|
||||||
$transaction_id,
|
|
||||||
null,
|
null,
|
||||||
null,
|
array('debit_ledger_id' => $A->currentLedgerID($ar_account_id),
|
||||||
$tx['customer_id'],
|
'credit_ledger_id' => $A->currentLedgerID($refund_account_id),
|
||||||
$tx['lease_id']
|
'effective_date' => $entry['effective_date'],
|
||||||
|
'through_date' => $entry['through_date'],
|
||||||
|
'amount' => $amount,
|
||||||
|
'lease_id' => $entry['lease_id'],
|
||||||
|
'customer_id' => $entry['customer_id'],
|
||||||
|
'comment' => "Refund; Entry #{$entry['id']}",
|
||||||
|
),
|
||||||
|
array('debit' => array
|
||||||
|
(array('Entry' =>
|
||||||
|
array('id' => $entry['id'],
|
||||||
|
'amount' => $amount))),
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$this->pr(21, compact('result'));
|
|
||||||
$ret['assigned'][] = $result;
|
if ($ids['error'])
|
||||||
if ($result['error'])
|
return $this->prReturn(null);
|
||||||
$ret['error'] = true;
|
$transaction_id = $ids['transaction_id'];
|
||||||
|
|
||||||
|
$this->pr(15, compact('ids', 'amount', 'refund_account_id', 'ar_account_id'),
|
||||||
|
'Posted Refund Ledger Entry');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->prReturn($ret + array('error' => false));
|
return $this->prReturn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -274,21 +241,28 @@ class StatementEntry extends AppModel {
|
|||||||
function reconciledSetQuery($set, $query) {
|
function reconciledSetQuery($set, $query) {
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
if (in_array($set, $this->debitTypes()))
|
if ($set == 'CHARGE' || $set == 'PAYMENT')
|
||||||
$query['link']['DisbursementEntry'] = array('fields' => array("SUM(DisbursementEntry.amount) AS reconciled"));
|
$query['conditions'][] = array('StatementEntry.type' => $set);
|
||||||
elseif (in_array($set, $this->creditTypes()))
|
|
||||||
$query['link']['ChargeEntry'] = array('fields' => array("SUM(ChargeEntry.amount) AS reconciled"));
|
|
||||||
else
|
else
|
||||||
die("INVALID RECONCILE SET");
|
die("INVALID RECONCILE SET");
|
||||||
|
|
||||||
$query['conditions'][] = array('StatementEntry.type' => $set);
|
if ($set == 'CHARGE')
|
||||||
|
$query['link']['PaymentEntry'] = array('fields' => array("SUM(PaymentEntry.amount) AS reconciled"));
|
||||||
|
if ($set == 'PAYMENT')
|
||||||
|
$query['link']['ChargeEntry'] = array('fields' => array("SUM(ChargeEntry.amount) AS reconciled"));
|
||||||
|
|
||||||
$query['group'] = 'StatementEntry.id';
|
$query['group'] = 'StatementEntry.id';
|
||||||
|
|
||||||
|
// REVISIT: TESTING
|
||||||
|
//$query['link']['PaymentEntry'] = array('fields' => array("(`PaymentEntry.amount`+0) AS reconciled"));
|
||||||
|
//$query['group'] = null;
|
||||||
|
// END REVISIT
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function reconciledSet($set, $query = null, $unrec = false, $if_rec_include_partial = false) {
|
function reconciledSet($set, $query = null, $unrec = false, $if_rec_include_partial = false) {
|
||||||
//$this->prFunctionLevel(array('log' => 16, 'show' => 10));
|
//$this->prFunctionLevel(16);
|
||||||
$this->prEnter(compact('set', 'query', 'unrec', 'if_rec_include_partial'));
|
$this->prEnter(compact('set', 'query', 'unrec', 'if_rec_include_partial'));
|
||||||
$lquery = $this->reconciledSetQuery($set, $query);
|
$lquery = $this->reconciledSetQuery($set, $query);
|
||||||
$result = $this->find('all', $lquery);
|
$result = $this->find('all', $lquery);
|
||||||
@@ -312,7 +286,7 @@ class StatementEntry extends AppModel {
|
|||||||
$reconciled = true;
|
$reconciled = true;
|
||||||
elseif ($entry['StatementEntry']['reconciled'] == 0)
|
elseif ($entry['StatementEntry']['reconciled'] == 0)
|
||||||
$reconciled = false;
|
$reconciled = false;
|
||||||
else // Partial disbursement; depends on unrec
|
else // Partial payment; depends on unrec
|
||||||
$reconciled = (!$unrec && $if_rec_include_partial);
|
$reconciled = (!$unrec && $if_rec_include_partial);
|
||||||
|
|
||||||
// Add to the set, if it's been requested
|
// Add to the set, if it's been requested
|
||||||
@@ -330,7 +304,7 @@ class StatementEntry extends AppModel {
|
|||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: reconciledEntries
|
* function: reconciledEntries
|
||||||
* - Returns a list of entries that reconcile against the given entry.
|
* - Returns a list of entries that reconcile against the given entry.
|
||||||
* (such as disbursements towards a charge).
|
* (such as payments towards a charge).
|
||||||
*/
|
*/
|
||||||
function reconciledEntriesQuery($id, $query = null) {
|
function reconciledEntriesQuery($id, $query = null) {
|
||||||
$this->queryInit($query, false);
|
$this->queryInit($query, false);
|
||||||
@@ -341,14 +315,10 @@ class StatementEntry extends AppModel {
|
|||||||
|
|
||||||
$query['conditions'][] = array('StatementEntry.id' => $id);
|
$query['conditions'][] = array('StatementEntry.id' => $id);
|
||||||
|
|
||||||
if (in_array($this->data['StatementEntry']['type'], $this->debitTypes())) {
|
if ($this->data['StatementEntry']['type'] == 'CHARGE')
|
||||||
$query['link']['DisbursementEntry'] = array();
|
$query['link']['PaymentEntry'] = array();
|
||||||
$query['conditions'][] = array('DisbursementEntry.id !=' => null);
|
if ($this->data['StatementEntry']['type'] == 'PAYMENT')
|
||||||
}
|
|
||||||
if (in_array($this->data['StatementEntry']['type'], $this->creditTypes())) {
|
|
||||||
$query['link']['ChargeEntry'] = array();
|
$query['link']['ChargeEntry'] = array();
|
||||||
$query['conditions'][] = array('ChargeEntry.id !=' => null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@@ -373,121 +343,61 @@ class StatementEntry extends AppModel {
|
|||||||
*
|
*
|
||||||
* REVISIT <AP>: 20090726
|
* REVISIT <AP>: 20090726
|
||||||
* This algorithm shouldn't be hardcoded. We need to allow
|
* This algorithm shouldn't be hardcoded. We need to allow
|
||||||
* the user to specify how disbursements should be applied.
|
* the user to specify how payments should be applied.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function assignCredits($query = null, $receipt_id = null,
|
function assignCredits($query = null, $receipt_id = null) {
|
||||||
$charge_ids = null, $disbursement_type = null,
|
$this->prFunctionLevel(25);
|
||||||
$customer_id = null, $lease_id = null)
|
$this->prEnter( compact('query', 'receipt_id'));
|
||||||
{
|
|
||||||
//$this->prFunctionLevel(25);
|
|
||||||
$this->prEnter(compact('query', 'receipt_id',
|
|
||||||
'charge_ids', 'disbursement_type',
|
|
||||||
'customer_id', 'lease_id'));
|
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
|
|
||||||
if (!empty($customer_id))
|
|
||||||
$query['conditions'][] = array('StatementEntry.customer_id' => $customer_id);
|
|
||||||
|
|
||||||
if (empty($disbursement_type))
|
|
||||||
$disbursement_type = 'DISBURSEMENT';
|
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
// First, find all known credits, unless this call is to make
|
// First, find all known credits
|
||||||
// credit adjustments to a specific charge
|
$lquery = $query;
|
||||||
// REVISIT <AP>: 20090806
|
$lquery['conditions'][] = array('StatementEntry.type' => 'SURPLUS');
|
||||||
// If the theory below is correct, we should only search for
|
$lquery['order'][] = 'StatementEntry.effective_date ASC';
|
||||||
// explicit credits if we don't have a receipt_id
|
$credits = $this->find('all', $lquery);
|
||||||
if (empty($charge_ids)) {
|
$this->pr(18, compact('credits'),
|
||||||
$lquery = $query;
|
"Credits Established");
|
||||||
$lquery['conditions'][] = array('StatementEntry.type' => 'SURPLUS');
|
|
||||||
// REVISIT <AP>: 20090804
|
|
||||||
// We need to ensure that we're using surplus credits ONLY from either
|
|
||||||
// the given lease, or those that do not apply to any specific lease.
|
|
||||||
// However, by doing this, it forces any lease surplus amounts to
|
|
||||||
// remain frozen with that lease until either there is a lease charge,
|
|
||||||
// we refund the money, or we "promote" that surplus to the customer
|
|
||||||
// level and out of the leases direct control.
|
|
||||||
// That seems like a pain. Perhaps we should allow any customer
|
|
||||||
// surplus to be used on any customer charge.
|
|
||||||
$lquery['conditions'][] =
|
|
||||||
array('OR' =>
|
|
||||||
array(array('StatementEntry.lease_id' => null),
|
|
||||||
(!empty($lease_id)
|
|
||||||
? array('StatementEntry.lease_id' => $lease_id)
|
|
||||||
: array()),
|
|
||||||
));
|
|
||||||
$lquery['order'][] = 'StatementEntry.effective_date ASC';
|
|
||||||
$credits = $this->find('all', $lquery);
|
|
||||||
$this->pr(18, compact('credits'),
|
|
||||||
"Credits Established");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (empty($receipt_id))
|
|
||||||
INTERNAL_ERROR("Can't make adjustments to a charge without a receipt ID.");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next, establish credit from the newly added receipt
|
// Next, establish credit from the newly added receipt
|
||||||
$receipt_credit = null;
|
$receipt_credit = null;
|
||||||
if (!empty($receipt_id)) {
|
if (!empty($receipt_id)) {
|
||||||
$lquery =
|
$lquery = array
|
||||||
array('link' =>
|
('contain' => array
|
||||||
array('StatementEntry',
|
('LedgerEntry' =>
|
||||||
'LedgerEntry' =>
|
array('conditions' =>
|
||||||
array('conditions' =>
|
//array(LedgerEntry.'crdr'=>'DEBIT'),
|
||||||
array('LedgerEntry.account_id !=' =>
|
array('LedgerEntry.account_id !=' =>
|
||||||
$this->Account->accountReceivableAccountID()),
|
$this->LedgerEntry->Account->accountReceivableAccountID()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'conditions' => array('Transaction.id' => $receipt_id),
|
);
|
||||||
'fields' => array('Transaction.id', 'Transaction.stamp', 'Transaction.amount'),
|
|
||||||
);
|
$this->Transaction->id = $receipt_id;
|
||||||
$receipt_credit = $this->Transaction->find('first', $lquery);
|
$receipt_credit = $this->Transaction->find('first', $lquery);
|
||||||
if (!$receipt_credit)
|
if (!$receipt_credit)
|
||||||
INTERNAL_ERROR("Unable to locate receipt.");
|
die("INTERNAL ERROR: UNABLE TO LOCATE RECEIPT");
|
||||||
|
|
||||||
//$reconciled = $this->reconciledEntries($id);
|
$receipt_credit['balance'] = $receipt_credit['Transaction']['amount'];
|
||||||
|
|
||||||
$stats = $this->Transaction->stats($receipt_id);
|
|
||||||
$receipt_credit['balance'] =
|
|
||||||
$receipt_credit['Transaction']['amount'] - $stats['Disbursement']['total'];
|
|
||||||
|
|
||||||
$this->pr(18, compact('receipt_credit'),
|
$this->pr(18, compact('receipt_credit'),
|
||||||
"Receipt Credit Added");
|
"Receipt Credit Added");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now find all unpaid charges
|
// Now find all unpaid charges
|
||||||
if (isset($charge_ids)) {
|
$lquery = $query;
|
||||||
$lquery = array('contain' => false,
|
|
||||||
'conditions' => array('StatementEntry.id' => $charge_ids));
|
|
||||||
} else {
|
|
||||||
$lquery = $query;
|
|
||||||
// If we're working with a specific lease, then limit charges to it
|
|
||||||
if (!empty($lease_id))
|
|
||||||
$lquery['conditions'][] = array('StatementEntry.lease_id' => $lease_id);
|
|
||||||
}
|
|
||||||
$lquery['order'] = 'StatementEntry.effective_date ASC';
|
$lquery['order'] = 'StatementEntry.effective_date ASC';
|
||||||
$charges = array();
|
$charges = $this->reconciledSet('CHARGE', $lquery, true);
|
||||||
foreach ($this->debitTypes() AS $dtype) {
|
$this->pr(18, compact('charges'),
|
||||||
$rset = $this->reconciledSet($dtype, $lquery, true);
|
"Outstanding Charges Determined");
|
||||||
$entries = $rset['entries'];
|
|
||||||
$charges = array_merge($charges, $entries);
|
|
||||||
$this->pr(18, compact('dtype', 'entries'), "Outstanding Debit Entries");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize our list of used credits
|
// Initialize our list of used credits
|
||||||
$used_credits = array();
|
$used_credits = array();
|
||||||
|
|
||||||
// REVISIT <AP>: 20090806
|
// Work through all unpaid charges, applying payments as we go
|
||||||
// Testing a theory. We should never have
|
foreach ($charges['entries'] AS $charge) {
|
||||||
// explicit credits, as well as a new receipt,
|
|
||||||
// and yet have outstanding charges.
|
|
||||||
if (!empty($credits) && !empty($receipt_credit) && !empty($charges))
|
|
||||||
INTERNAL_ERROR("Explicit credits that haven't already been applied.");
|
|
||||||
|
|
||||||
// Work through all unpaid charges, applying disbursements as we go
|
|
||||||
foreach ($charges AS $charge) {
|
|
||||||
|
|
||||||
$this->pr(20, compact('charge'),
|
$this->pr(20, compact('charge'),
|
||||||
'Process Charge');
|
'Process Charge');
|
||||||
@@ -497,26 +407,26 @@ class StatementEntry extends AppModel {
|
|||||||
// will handle everything just fine. However, this
|
// will handle everything just fine. However, this
|
||||||
// just saves extra processing if/when there is no
|
// just saves extra processing if/when there is no
|
||||||
// means to resolve a charge anyway.
|
// means to resolve a charge anyway.
|
||||||
if (empty($credits) && empty($receipt_credit['balance'])) {
|
if (count($credits) == 0 && empty($receipt_credit['balance'])) {
|
||||||
$this->pr(17, 'No more available credits');
|
$this->pr(15, 'No more available credits');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$charge['balance'] = $charge['StatementEntry']['balance'];
|
$charge['balance'] = $charge['StatementEntry']['balance'];
|
||||||
while ($charge['balance'] > 0 &&
|
while ($charge['balance'] > 0 &&
|
||||||
(!empty($credits) || !empty($receipt_credit['balance']))) {
|
(count($credits) || !empty($receipt_credit['balance']))) {
|
||||||
|
|
||||||
$this->pr(20, compact('charge'),
|
$this->pr(20, compact('charge'),
|
||||||
'Attempt Charge Reconciliation');
|
'Attempt Charge Reconciliation');
|
||||||
|
|
||||||
// Use explicit credits before using implicit credits
|
// Use explicit credits before using implicit credits
|
||||||
// (Not sure it matters though).
|
// (Not sure it matters though).
|
||||||
if (!empty($credits)) {
|
if (count($credits)) {
|
||||||
// Peel off the first credit available
|
// Peel off the first credit available
|
||||||
$credit =& $credits[0];
|
$credit =& $credits[0];
|
||||||
$disbursement_date = $credit['StatementEntry']['effective_date'];
|
$payment_date = $credit['StatementEntry']['effective_date'];
|
||||||
$disbursement_transaction_id = $credit['StatementEntry']['transaction_id'];
|
$payment_transaction_id = $credit['StatementEntry']['transaction_id'];
|
||||||
$disbursement_account_id = $credit['StatementEntry']['account_id'];
|
$payment_account_id = $credit['StatementEntry']['account_id'];
|
||||||
|
|
||||||
if (!isset($credit['balance']))
|
if (!isset($credit['balance']))
|
||||||
$credit['balance'] = $credit['StatementEntry']['amount'];
|
$credit['balance'] = $credit['StatementEntry']['amount'];
|
||||||
@@ -524,57 +434,57 @@ class StatementEntry extends AppModel {
|
|||||||
elseif (!empty($receipt_credit['balance'])) {
|
elseif (!empty($receipt_credit['balance'])) {
|
||||||
// Use our only receipt credit
|
// Use our only receipt credit
|
||||||
$credit =& $receipt_credit;
|
$credit =& $receipt_credit;
|
||||||
$disbursement_date = $credit['Transaction']['stamp'];
|
$payment_date = $credit['Transaction']['stamp'];
|
||||||
$disbursement_transaction_id = $credit['Transaction']['id'];
|
$payment_transaction_id = $credit['Transaction']['id'];
|
||||||
$disbursement_account_id = $credit['LedgerEntry']['account_id'];
|
$payment_account_id = $credit['LedgerEntry']['account_id'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die("HOW DID WE GET HERE WITH NO SURPLUS?");
|
die("HOW DID WE GET HERE WITH NO SURPLUS?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the disbursement amount to the maximum amount
|
// Set the payment amount to the maximum amount
|
||||||
// possible without exceeding the charge or credit balance
|
// possible without exceeding the charge or credit balance
|
||||||
$disbursement_amount = min($charge['balance'], $credit['balance']);
|
$payment_amount = min($charge['balance'], $credit['balance']);
|
||||||
if (!isset($credit['applied']))
|
if (!isset($credit['applied']))
|
||||||
$credit['applied'] = 0;
|
$credit['applied'] = 0;
|
||||||
|
|
||||||
$credit['applied'] += $disbursement_amount;
|
$credit['applied'] += $payment_amount;
|
||||||
$credit['balance'] -= $disbursement_amount;
|
$credit['balance'] -= $payment_amount;
|
||||||
|
|
||||||
$this->pr(20, compact('credit'),
|
$this->pr(20, compact('credit'),
|
||||||
($credit['balance'] > 0 ? 'Utilized' : 'Exhausted') .
|
($credit['balance'] > 0 ? 'Utilized' : 'Exhausted') .
|
||||||
(!empty($credits) ? ' Credit' : ' Receipt'));
|
(count($credits) ? ' Credit' : ' Receipt'));
|
||||||
|
|
||||||
if ($credit['balance'] < 0)
|
if ($credit['balance'] < 0)
|
||||||
die("HOW DID WE END UP WITH NEGATIVE SURPLUS BALANCE?");
|
die("HOW DID WE END UP WITH NEGATIVE SURPLUS BALANCE?");
|
||||||
|
|
||||||
// If we've exhausted the credit, get it out of the
|
// If we've exhausted the credit, get it out of the
|
||||||
// available credit pool (but keep track of it for later).
|
// available credit pool (but keep track of it for later).
|
||||||
if ($credit['balance'] <= 0 && !empty($credits))
|
if ($credit['balance'] <= 0 && count($credits))
|
||||||
$used_credits[] = array_shift($credits);
|
$used_credits[] = array_shift($credits);
|
||||||
|
|
||||||
// Add a disbursement that uses the available credit to pay the charge
|
// Add a payment that uses the available credit to pay the charge
|
||||||
$disbursement = array('type' => $disbursement_type,
|
$payment = array('type' => 'PAYMENT',
|
||||||
'account_id' => $disbursement_account_id,
|
'account_id' => $payment_account_id,
|
||||||
'amount' => $disbursement_amount,
|
'amount' => $payment_amount,
|
||||||
'effective_date' => $disbursement_date,
|
'effective_date' => $payment_date,
|
||||||
'transaction_id' => $disbursement_transaction_id,
|
'transaction_id' => $payment_transaction_id,
|
||||||
'customer_id' => $charge['StatementEntry']['customer_id'],
|
'customer_id' => $charge['StatementEntry']['customer_id'],
|
||||||
'lease_id' => $charge['StatementEntry']['lease_id'],
|
'lease_id' => $charge['StatementEntry']['lease_id'],
|
||||||
'charge_entry_id' => $charge['StatementEntry']['id'],
|
'charge_entry_id' => $charge['StatementEntry']['id'],
|
||||||
'comment' => null,
|
'comment' => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->pr(20, compact('disbursement'),
|
$this->pr(20, compact('payment'),
|
||||||
'New Disbursement Entry');
|
'New Payment Entry');
|
||||||
|
|
||||||
$result = $this->addStatementEntry($disbursement);
|
$result = $this->addStatementEntry($payment);
|
||||||
$ret['Disbursement'][] = $result;
|
$ret['Payment'][] = $result;
|
||||||
if ($result['error'])
|
if ($result['error'])
|
||||||
$ret['error'] = true;
|
$ret['error'] = true;
|
||||||
|
|
||||||
// Adjust the charge balance to reflect the new disbursement
|
// Adjust the charge balance to reflect the new payment
|
||||||
$charge['balance'] -= $disbursement_amount;
|
$charge['balance'] -= $payment_amount;
|
||||||
if ($charge['balance'] < 0)
|
if ($charge['balance'] < 0)
|
||||||
die("HOW DID WE GET A NEGATIVE CHARGE AMOUNT?");
|
die("HOW DID WE GET A NEGATIVE CHARGE AMOUNT?");
|
||||||
|
|
||||||
@@ -589,7 +499,7 @@ class StatementEntry extends AppModel {
|
|||||||
$used_credits[] = array_shift($credits);
|
$used_credits[] = array_shift($credits);
|
||||||
|
|
||||||
$this->pr(18, compact('credits', 'used_credits', 'receipt_credit'),
|
$this->pr(18, compact('credits', 'used_credits', 'receipt_credit'),
|
||||||
'Disbursements added');
|
'Payments added');
|
||||||
|
|
||||||
// Clean up any explicit credits that have been used
|
// Clean up any explicit credits that have been used
|
||||||
foreach ($used_credits AS $credit) {
|
foreach ($used_credits AS $credit) {
|
||||||
@@ -612,37 +522,20 @@ class StatementEntry extends AppModel {
|
|||||||
if (!empty($receipt_credit['balance'])) {
|
if (!empty($receipt_credit['balance'])) {
|
||||||
$credit =& $receipt_credit;
|
$credit =& $receipt_credit;
|
||||||
|
|
||||||
$explicit_credit = $this->find
|
$this->pr(18, compact('credit'),
|
||||||
('first', array('contain' => false,
|
'Create Explicit Credit');
|
||||||
'conditions' =>
|
|
||||||
array(array('transaction_id' => $credit['Transaction']['id']),
|
|
||||||
array('type' => 'SURPLUS')),
|
|
||||||
));
|
|
||||||
|
|
||||||
if (empty($explicit_credit)) {
|
$result = $this->addStatementEntry
|
||||||
$this->pr(18, compact('credit'),
|
(array('type' => 'SURPLUS',
|
||||||
'Create Explicit Credit');
|
'account_id' => $credit['LedgerEntry']['account_id'],
|
||||||
|
'amount' => $credit['balance'],
|
||||||
$result = $this->addStatementEntry
|
'effective_date' => $credit['Transaction']['stamp'],
|
||||||
(array('type' => 'SURPLUS',
|
'transaction_id' => $credit['Transaction']['id'],
|
||||||
'account_id' => $credit['LedgerEntry']['account_id'],
|
'customer_id' => $credit['Customer']['id'],
|
||||||
'amount' => $credit['balance'],
|
));
|
||||||
'effective_date' => $credit['Transaction']['stamp'],
|
$ret['Credit'] = $result;
|
||||||
'transaction_id' => $credit['Transaction']['id'],
|
if ($result['error'])
|
||||||
'customer_id' => $customer_id,
|
$ret['error'] = true;
|
||||||
'lease_id' => $lease_id,
|
|
||||||
));
|
|
||||||
$ret['Credit'] = $result;
|
|
||||||
if ($result['error'])
|
|
||||||
$ret['error'] = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->pr(18, compact('explicit_credit', 'credit'),
|
|
||||||
'Update Explicit Credit');
|
|
||||||
$EC = new StatementEntry();
|
|
||||||
$EC->id = $explicit_credit['StatementEntry']['id'];
|
|
||||||
$EC->saveField('amount', $credit['balance']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->prReturn($ret + array('error' => false));
|
return $this->prReturn($ret + array('error' => false));
|
||||||
@@ -656,7 +549,6 @@ class StatementEntry extends AppModel {
|
|||||||
* - Returns summary data from the requested statement entry
|
* - Returns summary data from the requested statement entry
|
||||||
*/
|
*/
|
||||||
function stats($id = null, $query = null) {
|
function stats($id = null, $query = null) {
|
||||||
//$this->prFunctionLevel(array('log' => 19, 'show' => 10));
|
|
||||||
$this->prEnter(compact('id', 'query'));
|
$this->prEnter(compact('id', 'query'));
|
||||||
|
|
||||||
$this->queryInit($query);
|
$this->queryInit($query);
|
||||||
@@ -666,68 +558,48 @@ class StatementEntry extends AppModel {
|
|||||||
if (isset($id))
|
if (isset($id))
|
||||||
$query['conditions'][] = array('StatementEntry.id' => $id);
|
$query['conditions'][] = array('StatementEntry.id' => $id);
|
||||||
|
|
||||||
$types = array('Charge', 'Disbursement');
|
$rquery = $query;
|
||||||
foreach ($types AS $type_index => $this_name) {
|
unset($rquery['link']['ChargeEntry']);
|
||||||
$that_name = $types[($type_index + 1) % 2];
|
$rquery['link']['PaymentEntry'] = array('fields' => array());
|
||||||
if ($this_name === 'Charge') {
|
|
||||||
$this_types = $this->debitTypes();
|
|
||||||
$that_types = $this->creditTypes();
|
|
||||||
} else {
|
|
||||||
$this_types = $this->creditTypes();
|
|
||||||
$that_types = $this->debitTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this_query = $query;
|
$rquery['fields'] = array();
|
||||||
$this_query['fields'] = array();
|
$rquery['fields'][] = "StatementEntry.amount";
|
||||||
$this_query['fields'][] = "SUM(StatementEntry.amount) AS total";
|
$rquery['fields'][] = "SUM(PaymentEntry.amount) AS reconciled";
|
||||||
$this_query['conditions'][] = array('StatementEntry.type' => $this_types);
|
|
||||||
$result = $this->find('first', $this_query);
|
|
||||||
$stats[$this_name] = $result[0];
|
|
||||||
|
|
||||||
$this->pr(17, compact('this_query', 'result'), $this_name.'s');
|
$rquery['conditions'][] = array('StatementEntry.type' => 'CHARGE');
|
||||||
|
$rquery['group'] = 'StatementEntry.id';
|
||||||
|
|
||||||
// Tally the different types that result in credits towards the charges
|
$result = $this->find('all', $rquery);
|
||||||
$stats[$this_name]['reconciled'] = 0;
|
$stats['Charge'] = array('total' => 0, 'reconciled' => 0);
|
||||||
foreach ($that_types AS $that_type) {
|
foreach($result AS $charge) {
|
||||||
$lc_that_type = strtolower($that_type);
|
$stats['Charge']['total'] += $charge['StatementEntry']['amount'];
|
||||||
$that_query = $this_query;
|
$stats['Charge']['reconciled'] += $charge[0]['reconciled'];
|
||||||
$that_query['link']["{$that_name}Entry"] = array('fields' => array());
|
|
||||||
$that_query['fields'] = array();
|
|
||||||
if ($this_name == 'Charge')
|
|
||||||
$that_query['fields'][] = "COALESCE(SUM(${that_name}Entry.amount),0) AS $lc_that_type";
|
|
||||||
else
|
|
||||||
$that_query['fields'][] = "COALESCE(SUM(StatementEntry.amount), 0) AS $lc_that_type";
|
|
||||||
$that_query['conditions'][] = array("{$that_name}Entry.type" => $that_type);
|
|
||||||
$result = $this->find('first', $that_query);
|
|
||||||
$stats[$this_name] += $result[0];
|
|
||||||
|
|
||||||
$this->pr(17, compact('that_query', 'result'), "{$this_name}s: $that_type");
|
|
||||||
$stats[$this_name]['reconciled'] += $stats[$this_name][$lc_that_type];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute balance information for charges
|
|
||||||
$stats[$this_name]['balance'] =
|
|
||||||
$stats[$this_name]['total'] - $stats[$this_name]['reconciled'];
|
|
||||||
if (!isset($stats[$this_name]['balance']))
|
|
||||||
$stats[$this_name]['balance'] = 0;
|
|
||||||
}
|
}
|
||||||
|
$stats['Charge']['balance'] =
|
||||||
|
$stats['Charge']['total'] - $stats['Charge']['reconciled'];
|
||||||
|
|
||||||
|
$this->pr(17, compact('query', 'result'),
|
||||||
|
'Charges');
|
||||||
|
|
||||||
// 'balance' is simply the difference between
|
$rquery = $query;
|
||||||
// the balances of charges and disbursements
|
unset($rquery['link']['PaymentEntry']);
|
||||||
$stats['balance'] = $stats['Charge']['balance'] - $stats['Disbursement']['balance'];
|
$rquery['link']['ChargeEntry'] = array('fields' => array());
|
||||||
if (!isset($stats['balance']))
|
|
||||||
$stats['balance'] = 0;
|
|
||||||
|
|
||||||
// 'account_balance' is really only relevant to
|
$rquery['fields'] = array();
|
||||||
// callers that have requested charge and disbursement
|
$rquery['fields'][] = "SUM(StatementEntry.amount) AS total";
|
||||||
// stats with respect to a particular account.
|
$rquery['fields'][] = "SUM(IF(ChargeEntry.id IS NULL, 0, StatementEntry.amount)) AS reconciled";
|
||||||
// It represents the difference between inflow
|
$rquery['fields'][] = "SUM(IF(ChargeEntry.id IS NULL, StatementEntry.amount, 0)) AS balance";
|
||||||
// and outflow from that account.
|
|
||||||
$stats['account_balance'] = $stats['Charge']['reconciled'] - $stats['Disbursement']['total'];
|
$rquery['conditions'][] = array('StatementEntry.type' => 'PAYMENT');
|
||||||
if (!isset($stats['account_balance']))
|
$result = $this->find('first', $rquery);
|
||||||
$stats['account_balance'] = 0;
|
if (!isset($result[0]['balance']))
|
||||||
|
$result[0]['balance'] = 0;
|
||||||
|
$stats['Payment'] = $result[0];
|
||||||
|
|
||||||
|
$this->pr(17, compact('rquery', 'result'),
|
||||||
|
'Payments');
|
||||||
|
|
||||||
return $this->prReturn($stats);
|
return $this->prReturn($stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
9
site/models/statement_fraction.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
class StatementFraction extends AppModel {
|
||||||
|
|
||||||
|
var $belongsTo = array(
|
||||||
|
'StatementEntry',
|
||||||
|
'LedgerEntry',
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -14,41 +14,6 @@ class Tender extends AppModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: beforeSave
|
|
||||||
* - Performs any work needed before the save occurs
|
|
||||||
*/
|
|
||||||
|
|
||||||
function afterSave() {
|
|
||||||
// Come up with a (not necessarily unique) name for the tender.
|
|
||||||
// For checks & money orders, this will be based on the check
|
|
||||||
// number. For other types of tender, we'll just use the
|
|
||||||
// generic name of the tender type, and the tender ID
|
|
||||||
|
|
||||||
// Determine our tender type, and set the ID of that model
|
|
||||||
$this->TenderType->id = $this->field('tender_type_id');
|
|
||||||
|
|
||||||
// REVISIT <AP>: 20090810
|
|
||||||
// The only tender expected to have no tender type
|
|
||||||
// is our special "Closing" tender.
|
|
||||||
if (empty($this->TenderType->id))
|
|
||||||
$newname = 'Closing';
|
|
||||||
else {
|
|
||||||
$newname = $this->TenderType->field('name');
|
|
||||||
$naming_field = $this->TenderType->field('naming_field');
|
|
||||||
if (!empty($naming_field))
|
|
||||||
$newname .= ' #' . $this->field($naming_field);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($newname !== $this->field('name'))
|
|
||||||
$this->saveField('name', $newname);
|
|
||||||
|
|
||||||
return parent::afterSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -82,6 +47,25 @@ class Tender extends AppModel {
|
|||||||
if (!$this->verifyTender($tender))
|
if (!$this->verifyTender($tender))
|
||||||
return $this->prReturn(array('error' => true) + $ret);
|
return $this->prReturn(array('error' => true) + $ret);
|
||||||
|
|
||||||
|
// Come up with a (not necessarily unique) name for the tender.
|
||||||
|
// For checks & money orders, this will be based on the check
|
||||||
|
// number. For other types of tender, we'll just use the
|
||||||
|
// generic name of the monetary account.
|
||||||
|
// REVISIT <AP>: 20090723
|
||||||
|
// I would like to have cash named "Cash #1234", where
|
||||||
|
// the number would correspond to either the Tender ID
|
||||||
|
// or the LedgerEntry ID.
|
||||||
|
if (empty($tender['name']) && !empty($tender['account_id'])) {
|
||||||
|
$tender['name'] = $this->LedgerEntry->Account->name($tender['account_id']);
|
||||||
|
if ($tender['account_id'] == $this->LedgerEntry->Account->checkAccountID() ||
|
||||||
|
$tender['account_id'] == $this->LedgerEntry->Account->moneyOrderAccountID()) {
|
||||||
|
$tender['name'] .= ' #' . $tender['data1'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->pr(20, array('Tender' => $tender),
|
||||||
|
'Pre-Save');
|
||||||
|
|
||||||
$this->create();
|
$this->create();
|
||||||
if (!$this->save($tender))
|
if (!$this->save($tender))
|
||||||
return $this->prReturn(array('error' => true) + $ret);
|
return $this->prReturn(array('error' => true) + $ret);
|
||||||
@@ -96,10 +80,31 @@ class Tender extends AppModel {
|
|||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: nsf
|
* function: nsf
|
||||||
* - Flags the ledger entry as having insufficient funds
|
* - Flags the ledger entry as having insufficient funds
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Get information from Check (C1); for amount $A
|
||||||
|
* - Find Bank Deposit matching to Tender
|
||||||
|
* - New Transaction (T1)
|
||||||
|
* - New Bank Deposit (D1)
|
||||||
|
* - New Tender (N1); NSF; D1,
|
||||||
|
* - Add new LedgerEntry (L1a); T1; debit:bank; -$A
|
||||||
|
* - Add new LedgerEntry (L1b); T1; credit:NSF; -$A
|
||||||
|
* - Add new LedgerEntry (L2a); T1; debit:NSF; -$A; N1
|
||||||
|
* - Add new LedgerEntry (L2b); T1; credit:A/R; -$A
|
||||||
|
* - For Tx associated with LE associated with C1:
|
||||||
|
* - For each Payment SE of Tx:
|
||||||
|
* - Add new StatementEntry (S1n); T1; PAYMENT; -1*S1n.amount
|
||||||
|
* - New Transaction (T2) (?????)
|
||||||
|
* - Add new StatementEntry (S2); T2; CHARGE; NSF; $35
|
||||||
|
* - Add new LedgerEntry (L3a); T2; credit:NSF-Fee; $35
|
||||||
|
* - Add new LedgerEntry (L3b); T2; debit:A/R; $35
|
||||||
|
* - Set C1.nsf_tx = T1
|
||||||
|
* - Re-Reconcile (customer may have running credit)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function nsf($id, $stamp = null, $comment = null) {
|
function nsf($id, $stamp = null) {
|
||||||
$this->prEnter(compact('id', 'stamp', 'comment'));
|
$this->prFunctionLevel(30);
|
||||||
|
$this->prEnter(compact('id'));
|
||||||
|
|
||||||
// Get information about this NSF item.
|
// Get information about this NSF item.
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
@@ -123,15 +128,16 @@ class Tender extends AppModel {
|
|||||||
unset($tender['NsfTransaction']);
|
unset($tender['NsfTransaction']);
|
||||||
|
|
||||||
$T = new Transaction();
|
$T = new Transaction();
|
||||||
$result = $T->addNsf($tender, $stamp, $comment);
|
$result = $T->addNsf($tender, $stamp);
|
||||||
if (empty($result['error'])) {
|
if ($result['error'])
|
||||||
// Flag the tender as NSF, using the items created from addNsf
|
return $this->prReturn(false);
|
||||||
$this->id = $id;
|
|
||||||
$this->saveField('nsf_transaction_id', $result['nsf_transaction_id']);
|
|
||||||
$this->saveField('nsf_ledger_entry_id', $result['nsf_ledger_entry_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->prReturn($result);
|
// Flag the tender as NSF, using the items created from addNsf
|
||||||
|
$this->id = $id;
|
||||||
|
$this->saveField('nsf_transaction_id', $result['nsf_transaction_id']);
|
||||||
|
$this->saveField('nsf_ledger_entry_id', $result['nsf_ledger_entry_id']);
|
||||||
|
|
||||||
|
return $this->prReturn(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -112,4 +112,4 @@ class TenderType extends AppModel {
|
|||||||
return $stats[0];
|
return $stats[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ class Transaction extends AppModel {
|
|||||||
'conditions' => array('Charge.type' => 'CHARGE')
|
'conditions' => array('Charge.type' => 'CHARGE')
|
||||||
),
|
),
|
||||||
|
|
||||||
'Disbursement' => array(
|
'Payment' => array(
|
||||||
'className' => 'StatementEntry',
|
'className' => 'StatementEntry',
|
||||||
'conditions' => array('Disbursement.type' => 'DISBURSEMENT')
|
'conditions' => array('Payment.type' => 'PAYMENT')
|
||||||
),
|
),
|
||||||
|
|
||||||
'Debit' => array(
|
'Debit' => array(
|
||||||
@@ -37,7 +37,7 @@ class Transaction extends AppModel {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//var $default_log_level = array('log' => 30, 'show' => 15);
|
var $default_log_level = 30;
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -51,25 +51,23 @@ class Transaction extends AppModel {
|
|||||||
|
|
||||||
// Establish the transaction as an invoice
|
// Establish the transaction as an invoice
|
||||||
$invoice =& $data['Transaction'];
|
$invoice =& $data['Transaction'];
|
||||||
$invoice +=
|
$invoice['type'] = 'INVOICE';
|
||||||
array('type' => 'INVOICE',
|
$invoice['crdr'] = 'DEBIT';
|
||||||
'crdr' => 'DEBIT',
|
$invoice['account_id'] = $this->Account->accountReceivableAccountID();
|
||||||
'account_id' => $this->Account->accountReceivableAccountID(),
|
$invoice['customer_id'] = $customer_id;
|
||||||
'customer_id' => $customer_id,
|
$invoice['lease_id'] = $lease_id;
|
||||||
'lease_id' => $lease_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Go through the statement entries and flag as charges
|
// Go through the statement entries and flag as charges
|
||||||
foreach ($data['Entry'] AS &$entry)
|
foreach ($data['Entry'] AS &$entry) {
|
||||||
$entry += array('type' => 'CHARGE',
|
$entry['type'] = 'CHARGE';
|
||||||
'crdr' => 'CREDIT',
|
$entry['crdr'] = 'CREDIT';
|
||||||
);
|
}
|
||||||
|
|
||||||
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
||||||
if (isset($ids['transaction_id']))
|
if (isset($ids['transaction_id']))
|
||||||
$ids['invoice_id'] = $ids['transaction_id'];
|
$ids['invoice_id'] = $ids['transaction_id'];
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -85,30 +83,26 @@ class Transaction extends AppModel {
|
|||||||
|
|
||||||
// Establish the transaction as a receipt
|
// Establish the transaction as a receipt
|
||||||
$receipt =& $data['Transaction'];
|
$receipt =& $data['Transaction'];
|
||||||
$receipt +=
|
$receipt['type'] = 'RECEIPT';
|
||||||
array('type' => 'RECEIPT',
|
$receipt['crdr'] = 'CREDIT';
|
||||||
'crdr' => 'CREDIT',
|
$receipt['account_id'] = $this->Account->accountReceivableAccountID();
|
||||||
'account_id' => $this->Account->accountReceivableAccountID(),
|
$receipt['customer_id'] = $customer_id;
|
||||||
'customer_id' => $customer_id,
|
$receipt['lease_id'] = $lease_id;
|
||||||
'lease_id' => $lease_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Go through the statement entries and flag as disbursements
|
// Go through the statement entries and flag as payments
|
||||||
foreach ($data['Entry'] AS &$entry)
|
foreach ($data['Entry'] AS &$entry) {
|
||||||
$entry += array('type' => 'DISBURSEMENT', // not used
|
$entry['crdr'] = 'DEBIT';
|
||||||
'crdr' => 'DEBIT',
|
if (empty($entry['account_id']) && isset($entry['Tender']['tender_type_id'])) {
|
||||||
'account_id' =>
|
$entry['account_id'] = $this->LedgerEntry->Tender->TenderType->
|
||||||
(isset($entry['Tender']['tender_type_id'])
|
accountID($entry['Tender']['tender_type_id']);
|
||||||
? ($this->LedgerEntry->Tender->TenderType->
|
}
|
||||||
accountID($entry['Tender']['tender_type_id']))
|
}
|
||||||
: null),
|
|
||||||
);
|
|
||||||
|
|
||||||
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
||||||
if (isset($ids['transaction_id']))
|
if (isset($ids['transaction_id']))
|
||||||
$ids['receipt_id'] = $ids['transaction_id'];
|
$ids['receipt_id'] = $ids['transaction_id'];
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,78 +113,36 @@ class Transaction extends AppModel {
|
|||||||
* - Adds a new waiver
|
* - Adds a new waiver
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function addWaiver($data, $charge_id, $customer_id, $lease_id = null) {
|
function addWaiver($data, $customer_id, $lease_id = null) {
|
||||||
$this->prEnter(compact('data', 'charge_id', 'customer_id', 'lease_id'));
|
$this->prEnter(compact('data', 'customer_id', 'lease_id'));
|
||||||
|
// REVISIT <AP>: 20090802
|
||||||
|
// Completely un-implemented. Just copied from addReceipt
|
||||||
|
// and search-replace receipt with waiver.
|
||||||
|
return array('error' => true);
|
||||||
|
|
||||||
if (count($data['Entry']) != 1)
|
// Establish the transaction as a waiver
|
||||||
INTERNAL_ERROR("Should be one Entry for addWaiver");
|
$waiver =& $data['Transaction'];
|
||||||
|
$waiver['type'] = 'RECEIPT';
|
||||||
|
$waiver['crdr'] = 'CREDIT';
|
||||||
|
$waiver['account_id'] = $this->Account->accountReceivableAccountID();
|
||||||
|
$waiver['customer_id'] = $customer_id;
|
||||||
|
$waiver['lease_id'] = $lease_id;
|
||||||
|
|
||||||
// Just make sure the disbursement(s) are marked as waivers
|
// Go through the statement entries and flag as payments
|
||||||
// and that they go to cover the specific charge.
|
foreach ($data['Entry'] AS &$entry) {
|
||||||
$data['Transaction']['disbursement_type'] = 'WAIVER';
|
$entry['type'] = 'WAIVE';
|
||||||
$data['Transaction']['assign_charge_entry_id'] = $charge_id;
|
$entry['crdr'] = 'DEBIT';
|
||||||
|
if (empty($entry['account_id']) && isset($entry['Tender']['tender_type_id'])) {
|
||||||
|
$entry['account_id'] = $this->LedgerEntry->Tender->TenderType->
|
||||||
|
accountID($entry['Tender']['tender_type_id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In all other respects this is just a receipt.
|
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
||||||
$ids = $this->addReceipt($data, $customer_id, $lease_id);
|
|
||||||
if (isset($ids['transaction_id']))
|
if (isset($ids['transaction_id']))
|
||||||
$ids['waiver_id'] = $ids['transaction_id'];
|
$ids['waiver_id'] = $ids['transaction_id'];
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
return $ids;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: addReversal
|
|
||||||
* - Adds a new charge reversal
|
|
||||||
*/
|
|
||||||
|
|
||||||
function addReversal($data, $charge_id, $customer_id, $lease_id = null) {
|
|
||||||
$this->prEnter(compact('data', 'charge_id', 'customer_id', 'lease_id'));
|
|
||||||
|
|
||||||
if (count($data['Entry']) != 1)
|
|
||||||
INTERNAL_ERROR("Should be one Entry for addReversal");
|
|
||||||
|
|
||||||
// Just make sure the disbursement(s) are marked as reversals
|
|
||||||
// and that they go to cover the specific charge.
|
|
||||||
$data['Transaction']['type'] = 'CREDIT_NOTE';
|
|
||||||
$data['Transaction']['disbursement_type'] = 'REVERSAL';
|
|
||||||
$data['Transaction']['assign_charge_entry_id'] = $charge_id;
|
|
||||||
|
|
||||||
// In all other respects this is just a receipt.
|
|
||||||
$ids = $this->addReceipt($data, $customer_id, $lease_id);
|
|
||||||
if (isset($ids['transaction_id']))
|
|
||||||
$ids['reversal_id'] = $ids['transaction_id'];
|
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: addWriteOff
|
|
||||||
* - Adds a new write off of bad debt
|
|
||||||
*/
|
|
||||||
|
|
||||||
function addWriteOff($data, $customer_id, $lease_id = null) {
|
|
||||||
$this->prEnter(compact('data', 'charge_id', 'customer_id', 'lease_id'));
|
|
||||||
|
|
||||||
if (count($data['Entry']) != 1)
|
|
||||||
INTERNAL_ERROR("Should be one Entry for addWriteOff");
|
|
||||||
|
|
||||||
// Just make sure the disbursement(s) are marked as write offs,
|
|
||||||
// and that the write-off account is used.
|
|
||||||
$data['Transaction']['disbursement_type'] = 'WRITEOFF';
|
|
||||||
$data['Entry'][0]['account_id'] = $this->Account->badDebtAccountID();
|
|
||||||
|
|
||||||
// In all other respects this is just a receipt.
|
|
||||||
$ids = $this->addReceipt($data, $customer_id, $lease_id);
|
|
||||||
if (isset($ids['transaction_id']))
|
|
||||||
$ids['writeoff_id'] = $ids['transaction_id'];
|
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,13 +158,11 @@ class Transaction extends AppModel {
|
|||||||
|
|
||||||
// Establish the transaction as a deposit
|
// Establish the transaction as a deposit
|
||||||
$deposit =& $data['Transaction'];
|
$deposit =& $data['Transaction'];
|
||||||
$deposit +=
|
$deposit['type'] = 'DEPOSIT';
|
||||||
array('type' => 'DEPOSIT',
|
$deposit['crdr'] = 'DEBIT';
|
||||||
'crdr' => 'DEBIT',
|
$deposit['account_id'] = $account_id;
|
||||||
'account_id' => $account_id,
|
$deposit['customer_id'] = null;
|
||||||
'customer_id' => null,
|
$deposit['lease_id'] = null;
|
||||||
'lease_id' => null,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Save the list of IDs, so that we can mark their
|
// Save the list of IDs, so that we can mark their
|
||||||
// deposit transaction after it has been created.
|
// deposit transaction after it has been created.
|
||||||
@@ -225,7 +175,7 @@ class Transaction extends AppModel {
|
|||||||
if (!isset($group[$entry['account_id']]))
|
if (!isset($group[$entry['account_id']]))
|
||||||
$group[$entry['account_id']] =
|
$group[$entry['account_id']] =
|
||||||
array('account_id' => $entry['account_id'],
|
array('account_id' => $entry['account_id'],
|
||||||
'crdr' => strtoupper($this->Account->fundamentalOpposite($deposit['crdr'])),
|
'crdr' => 'CREDIT',
|
||||||
'amount' => 0);
|
'amount' => 0);
|
||||||
$group[$entry['account_id']]['amount'] += $entry['amount'];
|
$group[$entry['account_id']]['amount'] += $entry['amount'];
|
||||||
}
|
}
|
||||||
@@ -242,7 +192,7 @@ class Transaction extends AppModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
return $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,13 +208,10 @@ class Transaction extends AppModel {
|
|||||||
|
|
||||||
// Establish the transaction as a close
|
// Establish the transaction as a close
|
||||||
$close =& $data['Transaction'];
|
$close =& $data['Transaction'];
|
||||||
$close +=
|
$close['type'] = 'CLOSE';
|
||||||
array('type' => 'CLOSE',
|
$close['account_id'] = null;
|
||||||
'crdr' => null,
|
$close['customer_id'] = null;
|
||||||
'account_id' => null,
|
$close['lease_id'] = null;
|
||||||
'customer_id' => null,
|
|
||||||
'lease_id' => null,
|
|
||||||
);
|
|
||||||
|
|
||||||
$ledger_ids = array();
|
$ledger_ids = array();
|
||||||
$data['Entry'] = array();
|
$data['Entry'] = array();
|
||||||
@@ -302,73 +249,7 @@ class Transaction extends AppModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
return $ids;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: addRefund
|
|
||||||
* - Adds a new refund
|
|
||||||
*/
|
|
||||||
|
|
||||||
function addRefund($data, $customer_id, $lease_id = null) {
|
|
||||||
$this->prEnter(compact('data', 'customer_id', 'lease_id'));
|
|
||||||
|
|
||||||
// Establish the transaction as a Refund. This is just like a
|
|
||||||
// Payment, except instead of paying out of the account payable,
|
|
||||||
// it comes from the customer credit in the account receivable.
|
|
||||||
// Someday, perhaps we'll just issue a Credit Note or similar,
|
|
||||||
// but for now, a refund means it's time to actually PAY.
|
|
||||||
$refund =& $data['Transaction'];
|
|
||||||
$refund +=
|
|
||||||
array('account_id' => $this->Account->accountReceivableAccountID());
|
|
||||||
|
|
||||||
// Also, to make it clear to the user, we flag as a REFUND
|
|
||||||
// even though that type works and operates just as PAYMENT
|
|
||||||
foreach ($data['Entry'] AS &$entry)
|
|
||||||
$entry += array('type' => 'REFUND');
|
|
||||||
|
|
||||||
$ids = $this->addPayment($data, $customer_id, $lease_id);
|
|
||||||
if (isset($ids['transaction_id']))
|
|
||||||
$ids['refund_id'] = $ids['transaction_id'];
|
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: addPayment
|
|
||||||
* - Adds a new payment transaction, which is money outflow
|
|
||||||
*/
|
|
||||||
|
|
||||||
function addPayment($data, $customer_id, $lease_id = null) {
|
|
||||||
$this->prEnter(compact('data', 'customer_id', 'lease_id'));
|
|
||||||
|
|
||||||
// Establish the transaction as an payment
|
|
||||||
$payment =& $data['Transaction'];
|
|
||||||
$payment +=
|
|
||||||
array('type' => 'PAYMENT',
|
|
||||||
'crdr' => 'DEBIT',
|
|
||||||
'account_id' => $this->Account->accountPayableAccountID(),
|
|
||||||
'customer_id' => $customer_id,
|
|
||||||
'lease_id' => $lease_id,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Go through the statement entries and flag as payments
|
|
||||||
foreach ($data['Entry'] AS &$entry)
|
|
||||||
$entry += array('type' => 'PAYMENT',
|
|
||||||
'crdr' => 'CREDIT',
|
|
||||||
);
|
|
||||||
|
|
||||||
$ids = $this->addTransaction($data['Transaction'], $data['Entry']);
|
|
||||||
if (isset($ids['transaction_id']))
|
|
||||||
$ids['payment_id'] = $ids['transaction_id'];
|
|
||||||
|
|
||||||
return $this->prReturn($ids);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -441,7 +322,7 @@ class Transaction extends AppModel {
|
|||||||
*
|
*
|
||||||
* - Entry (array)
|
* - Entry (array)
|
||||||
* - [MANDATORY]
|
* - [MANDATORY]
|
||||||
* - type (CHARGE, DISBURSEMENT)
|
* - type (CHARGE, PAYMENT)
|
||||||
* - account_id
|
* - account_id
|
||||||
* - crdr
|
* - crdr
|
||||||
* - amount
|
* - amount
|
||||||
@@ -488,8 +369,9 @@ class Transaction extends AppModel {
|
|||||||
// Automatically figure out the customer if we have the lease
|
// Automatically figure out the customer if we have the lease
|
||||||
if (!empty($transaction['lease_id']) && empty($transaction['customer_id'])) {
|
if (!empty($transaction['lease_id']) && empty($transaction['customer_id'])) {
|
||||||
$L = new Lease();
|
$L = new Lease();
|
||||||
$L->id = $transaction['lease_id'];
|
$L->recursive = -1;
|
||||||
$transaction['customer_id'] = $L->field('customer_id');
|
$lease = $L->read(null, $transaction['lease_id']);
|
||||||
|
$transaction['customer_id'] = $lease['Lease']['customer_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Break each entry out of the combined statement/ledger entry
|
// Break each entry out of the combined statement/ledger entry
|
||||||
@@ -501,10 +383,6 @@ class Transaction extends AppModel {
|
|||||||
// accidentally pick up stale data.
|
// accidentally pick up stale data.
|
||||||
$le1 = $le1_tender = $le2 = $se = null;
|
$le1 = $le1_tender = $le2 = $se = null;
|
||||||
|
|
||||||
// Really, data should be sanitized at the controller,
|
|
||||||
// and not here. However, it's a one stop cleanup.
|
|
||||||
$entry['amount'] = str_replace('$', '', $entry['amount']);
|
|
||||||
|
|
||||||
// Add entry amount into the transaction total
|
// Add entry amount into the transaction total
|
||||||
$transaction['amount'] += $entry['amount'];
|
$transaction['amount'] += $entry['amount'];
|
||||||
|
|
||||||
@@ -549,21 +427,17 @@ class Transaction extends AppModel {
|
|||||||
// Create the statement entry
|
// Create the statement entry
|
||||||
$se =
|
$se =
|
||||||
array_intersect_key($entry,
|
array_intersect_key($entry,
|
||||||
array_flip(array('type', 'account_id', 'amount',
|
array_flip(array('type', 'amount',
|
||||||
'effective_date', 'through_date', 'due_date',
|
'effective_date', 'through_date', 'due_date',
|
||||||
'customer_id', 'lease_id',
|
'customer_id', 'lease_id',
|
||||||
'charge_entry_id'))) +
|
'charge_entry_id'))) +
|
||||||
array_intersect_key($transaction,
|
array_intersect_key($transaction,
|
||||||
array_flip(array('customer_id', 'lease_id')));
|
array_flip(array('customer_id', 'lease_id')));
|
||||||
$se['comment'] = $entry['statement_entry_comment'];
|
$se['comment'] = $entry['statement_entry_comment'];
|
||||||
if (!empty($entry['se_negative']))
|
|
||||||
$se['amount'] *= -1;
|
|
||||||
|
|
||||||
// (DISBURSEMENTS will have statement entries created below, when
|
// (PAYMENTS will have statement entries created below, when
|
||||||
// assigning credits, and DEPOSITS don't have statement entries)
|
// assigning credits, and DEPOSITS don't have statement entries)
|
||||||
if (empty($transaction['customer_id']) ||
|
if ($transaction['type'] != 'INVOICE' && $subtype !== 'NSF')
|
||||||
($transaction['account_id'] == $this->Account->accountReceivableAccountID() &&
|
|
||||||
$transaction['crdr'] == 'CREDIT'))
|
|
||||||
$se = null;
|
$se = null;
|
||||||
|
|
||||||
// NSF transactions don't use LedgerEntries
|
// NSF transactions don't use LedgerEntries
|
||||||
@@ -583,11 +457,11 @@ class Transaction extends AppModel {
|
|||||||
// that were created above before we nulled them out
|
// that were created above before we nulled them out
|
||||||
array_unshift($entries,
|
array_unshift($entries,
|
||||||
array('le1' => array('account_id' => $transaction['account_id'],
|
array('le1' => array('account_id' => $transaction['account_id'],
|
||||||
'crdr' => 'CREDIT',
|
|
||||||
'amount' => -1 * $transaction['amount']),
|
|
||||||
'le2' => array('account_id' => $this->Account->accountReceivableAccountID(),
|
|
||||||
'crdr' => 'DEBIT',
|
'crdr' => 'DEBIT',
|
||||||
'amount' => -1 * $transaction['amount'])
|
'amount' => $transaction['amount']),
|
||||||
|
'le2' => array('account_id' => $this->Account->accountReceivableAccountID(),
|
||||||
|
'crdr' => 'CREDIT',
|
||||||
|
'amount' => $transaction['amount'])
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,7 +476,6 @@ class Transaction extends AppModel {
|
|||||||
$this->create();
|
$this->create();
|
||||||
if (!$this->save($transaction))
|
if (!$this->save($transaction))
|
||||||
return $this->prReturn(array('error' => true) + $ret);
|
return $this->prReturn(array('error' => true) + $ret);
|
||||||
$transaction_stamp = $this->field('stamp');
|
|
||||||
|
|
||||||
// Set up our return ids array
|
// Set up our return ids array
|
||||||
$ret['transaction_id'] = $this->id;
|
$ret['transaction_id'] = $this->id;
|
||||||
@@ -629,9 +502,11 @@ class Transaction extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($se)) {
|
if (!empty($se)) {
|
||||||
|
//pr($ret['entries'][$e_index]['DoubleEntry']); die;
|
||||||
|
$le_id = $ret['entries'][0]['DoubleEntry']['Entry1']['ledger_entry_id'];
|
||||||
$se['transaction_id'] = $ret['transaction_id'];
|
$se['transaction_id'] = $ret['transaction_id'];
|
||||||
if (empty($se['effective_date']))
|
$se['Fraction'] = array(array('ledger_entry_id' => $le_id,
|
||||||
$se['effective_date'] = $transaction_stamp;
|
'amount' => $se['amount']));
|
||||||
$result = $this->StatementEntry->addStatementEntry($se);
|
$result = $this->StatementEntry->addStatementEntry($se);
|
||||||
$ret['entries'][$e_index]['StatementEntry'] = $result;
|
$ret['entries'][$e_index]['StatementEntry'] = $result;
|
||||||
if ($result['error']) {
|
if ($result['error']) {
|
||||||
@@ -641,22 +516,15 @@ class Transaction extends AppModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($transaction['account_id'] == $this->Account->accountReceivableAccountID()
|
if (($transaction['type'] == 'INVOICE' ||
|
||||||
&& !$ret['error']) {
|
$transaction['type'] == 'RECEIPT') &&
|
||||||
|
$subtype !== 'NSF' && !$ret['error']) {
|
||||||
$result = $this->StatementEntry->assignCredits
|
$result = $this->StatementEntry->assignCredits
|
||||||
(null,
|
(array('link' => array('Customer'),
|
||||||
($transaction['crdr'] == 'CREDIT'
|
'conditions' => array('Customer.id' => $transaction['customer_id'])),
|
||||||
|
($transaction['type'] == 'RECEIPT'
|
||||||
? $ret['transaction_id']
|
? $ret['transaction_id']
|
||||||
: null),
|
: null));
|
||||||
($transaction['crdr'] == 'CREDIT' && !empty($transaction['assign_charge_entry_id'])
|
|
||||||
? $transaction['assign_charge_entry_id']
|
|
||||||
: null),
|
|
||||||
(!empty($transaction['disbursement_type'])
|
|
||||||
? $transaction['disbursement_type']
|
|
||||||
: null),
|
|
||||||
$transaction['customer_id'],
|
|
||||||
$transaction['lease_id']
|
|
||||||
);
|
|
||||||
|
|
||||||
$ret['assigned'] = $result;
|
$ret['assigned'] = $result;
|
||||||
if ($result['error'])
|
if ($result['error'])
|
||||||
@@ -674,23 +542,20 @@ class Transaction extends AppModel {
|
|||||||
* - Adds NSF transaction
|
* - Adds NSF transaction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function addNsf($tender, $stamp = null, $comment = null) {
|
function addNsf($tender, $stamp) {
|
||||||
$this->prEnter(compact('tender', 'stamp', 'comment'));
|
$this->prEnter(compact('tender', 'stamp'));
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
|
||||||
// Enter the NSF
|
// Enter the NSF
|
||||||
// This is the transaction pulling money from the bank account
|
// This is the transaction pulling money from the bank account
|
||||||
// and recording it in the NSF account. It has nothing to do
|
// and recording it in the NSF account. It has nothing to do
|
||||||
// with the customer statement (charges, disbursements, credits, etc).
|
// with the customer statement (charges, payments, credits, etc).
|
||||||
$bounce_result = $this->addDeposit
|
$bounce_result = $this->addDeposit
|
||||||
(array('Transaction' => array('stamp' => $stamp,
|
(array('Transaction' => array(),
|
||||||
'crdr' => 'CREDIT'),
|
|
||||||
'Entry' => array(array('tender_id' => null,
|
'Entry' => array(array('tender_id' => null,
|
||||||
'account_id' => $this->Account->nsfAccountID(),
|
'account_id' => $this->Account->nsfAccountID(),
|
||||||
'crdr' => 'DEBIT',
|
'amount' => -1 * $tender['LedgerEntry']['amount'],
|
||||||
'amount' => $tender['LedgerEntry']['amount'],
|
|
||||||
'se_negative' => true,
|
|
||||||
))),
|
))),
|
||||||
$tender['Transaction']['account_id']);
|
$tender['Transaction']['account_id']);
|
||||||
|
|
||||||
@@ -730,38 +595,37 @@ class Transaction extends AppModel {
|
|||||||
|
|
||||||
$rollback['Transaction']['stamp'] = $stamp;
|
$rollback['Transaction']['stamp'] = $stamp;
|
||||||
$rollback['Transaction']['type'] = 'RECEIPT';
|
$rollback['Transaction']['type'] = 'RECEIPT';
|
||||||
$rollback['Transaction']['crdr'] = 'CREDIT'; // Unused... keeps verifyTx happy
|
$rollback['Transaction']['crdr'] = 'DEBIT'; // Unused... keeps verifyTx happy
|
||||||
$rollback['Transaction']['account_id'] = $this->Account->nsfAccountID();
|
$rollback['Transaction']['account_id'] = $this->Account->nsfAccountID();
|
||||||
$rollback['Transaction']['customer_id'] = $tender['Tender']['customer_id'];
|
$rollback['Transaction']['customer_id'] = $tender['Tender']['customer_id'];
|
||||||
$rollback['Transaction']['comment'] = $comment;
|
$rollback['Transaction']['amount'] = -1 * $tender['LedgerEntry']['amount'];
|
||||||
|
|
||||||
foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $disbursement) {
|
foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $payment) {
|
||||||
if ($disbursement['type'] === 'SURPLUS') {
|
if ($payment['type'] === 'SURPLUS') {
|
||||||
$disbursement['type'] = 'VOID';
|
$payment['type'] = 'VOID';
|
||||||
$this->StatementEntry->id = $disbursement['id'];
|
$this->StatementEntry->id = $payment['id'];
|
||||||
$this->StatementEntry->saveField('type', $disbursement['type']);
|
$this->StatementEntry->saveField('type', $payment['type']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rollback['Entry'][] =
|
$rollback['Entry'][] =
|
||||||
array('type' => $disbursement['type'],
|
array('type' => $payment['type'],
|
||||||
'amount' => -1 * $disbursement['amount'],
|
'amount' => -1 * $payment['amount'],
|
||||||
'account_id' => $this->Account->nsfAccountID(),
|
'account_id' => $this->Account->nsfAccountID(),
|
||||||
'customer_id' => $disbursement['customer_id'],
|
'customer_id' => $payment['customer_id'],
|
||||||
'lease_id' => $disbursement['lease_id'],
|
'lease_id' => $payment['lease_id'],
|
||||||
'charge_entry_id' => $disbursement['charge_entry_id'],
|
'charge_entry_id' => $payment['charge_entry_id'],
|
||||||
|
'effective_date' => $stamp,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record the transaction, which will un-pay previously paid
|
// Record the transaction, which will un-pay previously paid
|
||||||
// charges, void any credits, and other similar work.
|
// charges, void any credits, and other similar work.
|
||||||
if (count($rollback['Entry'])) {
|
$rollback_result = $this->addTransaction($rollback['Transaction'], $rollback['Entry'], 'NSF');
|
||||||
$rollback_result = $this->addTransaction($rollback['Transaction'], $rollback['Entry'], 'NSF');
|
$this->pr(20, compact('rollback', 'rollback_result'));
|
||||||
$this->pr(20, compact('rollback', 'rollback_result'));
|
$ret['rollback'] = $rollback_result;
|
||||||
$ret['rollback'] = $rollback_result;
|
if ($rollback_result['error'])
|
||||||
if ($rollback_result['error'])
|
return $this->prReturn(array('error' => true) + $ret);
|
||||||
return $this->prReturn(array('error' => true) + $ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add NSF Charge
|
// Add NSF Charge
|
||||||
$charge_result = $this->addInvoice
|
$charge_result = $this->addInvoice
|
||||||
@@ -787,8 +651,7 @@ class Transaction extends AppModel {
|
|||||||
return $this->prReturn(array('error' => true) + $ret);
|
return $this->prReturn(array('error' => true) + $ret);
|
||||||
|
|
||||||
$ret['nsf_transaction_id'] = $ret['bounce']['transaction_id'];
|
$ret['nsf_transaction_id'] = $ret['bounce']['transaction_id'];
|
||||||
if (!empty($ret['rollback']))
|
$ret['nsf_ledger_entry_id'] = $ret['rollback']['entries'][0]['DoubleEntry']['Entry1']['ledger_entry_id'];
|
||||||
$ret['nsf_ledger_entry_id'] = $ret['rollback']['entries'][0]['DoubleEntry']['Entry1']['ledger_entry_id'];
|
|
||||||
return $this->prReturn($ret + array('error' => false));
|
return $this->prReturn($ret + array('error' => false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -839,7 +702,7 @@ class Transaction extends AppModel {
|
|||||||
}
|
}
|
||||||
elseif ($table == 'StatementEntry') {
|
elseif ($table == 'StatementEntry') {
|
||||||
$squery['fields'] = array_merge($squery['fields'],
|
$squery['fields'] = array_merge($squery['fields'],
|
||||||
$this->StatementEntry->chargeDisbursementFields(true));
|
$this->StatementEntry->chargePaymentFields(true));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$squery['fields'][] = "SUM({$table}.amount) AS total";
|
$squery['fields'][] = "SUM({$table}.amount) AS total";
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ class Unit extends AppModel {
|
|||||||
'Lease',
|
'Lease',
|
||||||
);
|
);
|
||||||
|
|
||||||
//var $default_log_level = array('log' => 30, 'show' => 15);
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -52,53 +50,13 @@ class Unit extends AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function occupiedEnumValue() {
|
function occupiedEnumValue() {
|
||||||
return $this->statusValue('OCCUPIED');
|
return statusValue('OCCUPIED');
|
||||||
}
|
|
||||||
|
|
||||||
function statusCheck($id_or_enum,
|
|
||||||
$min = null, $min_strict = false,
|
|
||||||
$max = null, $max_strict = false)
|
|
||||||
{
|
|
||||||
$this->prEnter(compact('id_or_enum', 'min', 'min_strict', 'max', 'max_strict'));
|
|
||||||
|
|
||||||
if (is_int($id_or_enum)) {
|
|
||||||
$this->id = $id_or_enum;
|
|
||||||
$id_or_enum = $this->field('status');
|
|
||||||
}
|
|
||||||
|
|
||||||
$enum_val = $this->statusValue($id_or_enum);
|
|
||||||
if (isset($min) && is_string($min))
|
|
||||||
$min = $this->statusValue($min);
|
|
||||||
if (isset($max) && is_string($max))
|
|
||||||
$max = $this->statusValue($max);
|
|
||||||
|
|
||||||
$this->pr(17, compact('enum_val', 'min', 'min_strict', 'max', 'max_strict'));
|
|
||||||
|
|
||||||
if (isset($min) &&
|
|
||||||
($enum_val < $min ||
|
|
||||||
($min_strict && $enum_val == $min)))
|
|
||||||
return $this->prReturn(false);
|
|
||||||
|
|
||||||
if (isset($max) &&
|
|
||||||
($enum_val > $max ||
|
|
||||||
($max_strict && $enum_val == $max)))
|
|
||||||
return $this->prReturn(false);
|
|
||||||
|
|
||||||
return $this->prReturn(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function occupied($enum) {
|
|
||||||
return $this->statusCheck($enum, 'OCCUPIED', false, null, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function conditionOccupied() {
|
function conditionOccupied() {
|
||||||
return ('Unit.status >= ' . $this->statusValue('OCCUPIED'));
|
return ('Unit.status >= ' . $this->statusValue('OCCUPIED'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function vacant($enum) {
|
|
||||||
return $this->statusCheck($enum, 'UNAVAILABLE', true, 'OCCUPIED', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function conditionVacant() {
|
function conditionVacant() {
|
||||||
return ('Unit.status BETWEEN ' .
|
return ('Unit.status BETWEEN ' .
|
||||||
($this->statusValue('UNAVAILABLE')+1) .
|
($this->statusValue('UNAVAILABLE')+1) .
|
||||||
@@ -106,81 +64,22 @@ class Unit extends AppModel {
|
|||||||
($this->statusValue('OCCUPIED')-1));
|
($this->statusValue('OCCUPIED')-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
function unavailable($enum) {
|
|
||||||
return $this->statusCheck($enum, null, false, 'UNAVAILABLE', false);
|
|
||||||
}
|
|
||||||
|
|
||||||
function conditionUnavailable() {
|
function conditionUnavailable() {
|
||||||
return ('Unit.status <= ' . $this->statusValue('UNAVAILABLE'));
|
return ('Unit.status <= ' . $this->statusValue('UNAVAILABLE'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function available($enum) { return $this->vacant($enum); }
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* function: allowedStatusSet
|
|
||||||
* - Returns the status set allowed for the given unit
|
|
||||||
*/
|
|
||||||
function allowedStatusSet($id) {
|
|
||||||
$this->prEnter(compact('id'));
|
|
||||||
$this->id = $id;
|
|
||||||
$old_status = $this->field('status');
|
|
||||||
$old_val = $this->statusValue($old_status);
|
|
||||||
$this->pr(17, compact('old_status', 'old_val'));
|
|
||||||
|
|
||||||
$enums = $this->activeStatusEnums();
|
|
||||||
$this->pr(21, compact('enums'));
|
|
||||||
|
|
||||||
foreach ($enums AS $enum => $val) {
|
|
||||||
if (($old_val < $this->occupiedEnumValue()) !=
|
|
||||||
($val < $this->occupiedEnumValue())) {
|
|
||||||
unset($enums[$enum]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->prReturn($enums);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
* function: updateStatus
|
* function: updateStatus
|
||||||
* - Update the given unit to the given status
|
* - Update the given unit to the given status
|
||||||
*/
|
*/
|
||||||
function updateStatus($id, $status, $check = false) {
|
function updateStatus($id, $status) {
|
||||||
$this->prEnter(compact('id', 'status', 'check'));
|
|
||||||
|
|
||||||
/* if ($check) { */
|
|
||||||
/* $old_status = $this->field('status'); */
|
|
||||||
/* $this->pr(17, compact('old_status')); */
|
|
||||||
/* if ($this->statusValue($old_status) < $this->occupiedEnumValue() && */
|
|
||||||
/* $this->statusValue($status) >= $this->occupiedEnumValue()) */
|
|
||||||
/* { */
|
|
||||||
/* die("Can't transition a unit from vacant to occupied"); */
|
|
||||||
/* return $this->prReturn(false); */
|
|
||||||
/* } */
|
|
||||||
/* if ($this->statusValue($old_status) >= $this->occupiedEnumValue() && */
|
|
||||||
/* $this->statusValue($status) < $this->occupiedEnumValue()) */
|
|
||||||
/* { */
|
|
||||||
/* die("Can't transition a unit from occupied to vacant"); */
|
|
||||||
/* return $this->prReturn(false); */
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
if ($check) {
|
|
||||||
if (!array_key_exists($status, $this->allowedStatusSet($id)))
|
|
||||||
return $this->prReturn(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
//pr(compact('id', 'status'));
|
||||||
$this->saveField('status', $status);
|
$this->saveField('status', $status);
|
||||||
return $this->prReturn(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ echo '<div class="account collected">' . "\n";
|
|||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
<?php /* REVISIT <AP>: 20090810; Hate to do this, but first data is wrong... */ ?>
|
/* updateEntriesGrid(); */
|
||||||
setTimeout(updateEntriesGrid, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onGridLoadComplete() {
|
function onGridLoadComplete() {
|
||||||
@@ -165,9 +164,9 @@ echo $this->element('statement_entries', array
|
|||||||
//'grid_setup' => array('hiddengrid' => true),
|
//'grid_setup' => array('hiddengrid' => true),
|
||||||
//'caption' => '<SPAN id="receipt-charges-caption"></SPAN>',
|
//'caption' => '<SPAN id="receipt-charges-caption"></SPAN>',
|
||||||
'caption' => 'Collected ' . Inflector::pluralize($account['name']),
|
'caption' => 'Collected ' . Inflector::pluralize($account['name']),
|
||||||
'filter' => array(//'StatementEntry.type' => 'DISBURSEMENT',
|
'filter' => array('StatementEntry.type' => 'PAYMENT',
|
||||||
'ChargeEntry.account_id' => $account['id']),
|
'ChargeEntry.account_id' => $account['id']),
|
||||||
'exclude' => array('Account', 'Charge', 'Type'),
|
'exclude' => array('Account', 'Charge'),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ echo $this->element('ledger_entries', array
|
|||||||
"(". $current_ledger['name'] .")"),
|
"(". $current_ledger['name'] .")"),
|
||||||
'filter' => array('Ledger.id' => $current_ledger['id']),
|
'filter' => array('Ledger.id' => $current_ledger['id']),
|
||||||
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance',
|
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance',
|
||||||
empty($account['receipts']) ? 'Tender' : null),
|
empty($account['payments']) ? 'Tender' : null),
|
||||||
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ echo $this->element('ledger_entries', array
|
|||||||
'caption' => "Entire Ledger",
|
'caption' => "Entire Ledger",
|
||||||
'filter' => array('Account.id' => $account['id']),
|
'filter' => array('Account.id' => $account['id']),
|
||||||
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance',
|
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Balance',
|
||||||
empty($account['receipts']) ? 'Tender' : null),
|
empty($account['payments']) ? 'Tender' : null),
|
||||||
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ echo($this->element
|
|||||||
'comment' => true,
|
'comment' => true,
|
||||||
))) . "\n");
|
))) . "\n");
|
||||||
|
|
||||||
echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n";
|
echo $form->submit('Update') . "\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div CLASS="dynamic-set">
|
<div CLASS="dynamic-set">
|
||||||
@@ -268,7 +268,7 @@ echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer
|
|||||||
<?php
|
<?php
|
||||||
; // Alignment
|
; // Alignment
|
||||||
|
|
||||||
echo $form->submit(isset($this->data['Customer']) ? 'Update' : 'Add New Customer') . "\n";
|
echo $form->submit('Update') . "\n";
|
||||||
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
||||||
echo $form->end() . "\n";
|
echo $form->end() . "\n";
|
||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
|
|||||||
@@ -11,9 +11,6 @@
|
|||||||
* Javascript
|
* Javascript
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Warnings _really_ screw up javascript
|
|
||||||
$saved_debug_state = Configure::read('debug');
|
|
||||||
Configure::write('debug', '0');
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
@@ -26,8 +23,14 @@ Configure::write('debug', '0');
|
|||||||
success: showResponse, // post-submit callback
|
success: showResponse, // post-submit callback
|
||||||
|
|
||||||
// other available options:
|
// other available options:
|
||||||
|
//url: url, // override for form's 'action' attribute
|
||||||
|
//type: 'get', // 'get' or 'post', override for form's 'method' attribute
|
||||||
|
//dataType: null, // 'xml', 'script', or 'json' (expected server response type)
|
||||||
//clearForm: true, // clear all form fields after successful submit
|
//clearForm: true, // clear all form fields after successful submit
|
||||||
//resetForm: true, // reset the form after successful submit
|
//resetForm: true, // reset the form after successful submit
|
||||||
|
|
||||||
|
// $.ajax options can be used here too, for example:
|
||||||
|
//timeout: 3000,
|
||||||
};
|
};
|
||||||
|
|
||||||
// bind form using 'ajaxForm'
|
// bind form using 'ajaxForm'
|
||||||
@@ -36,7 +39,16 @@ Configure::write('debug', '0');
|
|||||||
|
|
||||||
// pre-submit callback
|
// pre-submit callback
|
||||||
function verifyRequest(formData, jqForm, options) {
|
function verifyRequest(formData, jqForm, options) {
|
||||||
$('#results').html('Working <BLINK>...</BLINK>');
|
// formData is an array; here we use $.param to convert it to a string to display it
|
||||||
|
// but the form plugin does this for you automatically when it submits the data
|
||||||
|
//var_dump(formData);
|
||||||
|
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
||||||
|
$('#request-debug').html('Ommitted');
|
||||||
|
//return false;
|
||||||
|
|
||||||
|
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
|
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
|
|
||||||
// here we could return false to prevent the form from being submitted;
|
// here we could return false to prevent the form from being submitted;
|
||||||
// returning anything other than false will allow the form submit to continue
|
// returning anything other than false will allow the form submit to continue
|
||||||
return true;
|
return true;
|
||||||
@@ -44,32 +56,27 @@ function verifyRequest(formData, jqForm, options) {
|
|||||||
|
|
||||||
// post-submit callback
|
// post-submit callback
|
||||||
function showResponse(responseText, statusText) {
|
function showResponse(responseText, statusText) {
|
||||||
|
// for normal html responses, the first argument to the success callback
|
||||||
|
// is the XMLHttpRequest object's responseText property
|
||||||
|
|
||||||
|
// if the ajaxForm method was passed an Options Object with the dataType
|
||||||
|
// property set to 'xml' then the first argument to the success callback
|
||||||
|
// is the XMLHttpRequest object's responseXML property
|
||||||
|
|
||||||
|
// if the ajaxForm method was passed an Options Object with the dataType
|
||||||
|
// property set to 'json' then the first argument to the success callback
|
||||||
|
// is the json data object returned by the server
|
||||||
|
|
||||||
if (statusText == 'success') {
|
if (statusText == 'success') {
|
||||||
var amount = 0;
|
|
||||||
$("input.payment.amount").each(function(i) {
|
|
||||||
amount += $(this).val();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#results').html('<H3>Receipt Saved<BR>' +
|
|
||||||
$("#receipt-customer-name").html() +
|
|
||||||
' : ' + fmtCurrency(amount) +
|
|
||||||
'</H3>');
|
|
||||||
|
|
||||||
if (!$("#repeat").attr("checked")) {
|
|
||||||
window.location.href =
|
|
||||||
"<?php echo $html->url(array('controller' => 'customers',
|
|
||||||
'action' => 'view')); ?>"
|
|
||||||
+ "/" + $("#customer-id").val();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get a clean slate
|
// get a clean slate
|
||||||
resetForm();
|
//resetForm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#results').html('<H2>Failed to save receipt!</H2>');
|
alert('not successful??');
|
||||||
alert('Failed to save receipt.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
@@ -77,8 +84,13 @@ function resetForm() {
|
|||||||
$('#payment-entry-id').val(1);
|
$('#payment-entry-id').val(1);
|
||||||
$('#payments').html('');
|
$('#payments').html('');
|
||||||
|
|
||||||
|
$("#receipt-customer-id").html("INTERNAL ERROR");
|
||||||
|
$("#receipt-customer-name").html("INTERNAL ERROR");
|
||||||
|
$("#receipt-balance").html("INTERNAL ERROR");
|
||||||
|
$("#receipt-charges-caption").html("Outstanding Charges");
|
||||||
|
|
||||||
addPaymentSource(false);
|
addPaymentSource(false);
|
||||||
updateCharges($("#customer-id").val());
|
datepickerNow('TransactionStamp');
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRowSelect(grid_id, customer_id) {
|
function onRowSelect(grid_id, customer_id) {
|
||||||
@@ -97,6 +109,8 @@ function onRowSelect(grid_id, customer_id) {
|
|||||||
$(grid_id).getCell(customer_id, 'Customer-id') +
|
$(grid_id).getCell(customer_id, 'Customer-id') +
|
||||||
'</A>');
|
'</A>');
|
||||||
$("#receipt-customer-name").html($(grid_id).getCell(customer_id, 'Customer-name'));
|
$("#receipt-customer-name").html($(grid_id).getCell(customer_id, 'Customer-name'));
|
||||||
|
$("#receipt-balance").html("Calculating...");
|
||||||
|
$("#receipt-charges-caption").html("Please Wait...");
|
||||||
|
|
||||||
// Hide the "no customer" message and show the current customer
|
// Hide the "no customer" message and show the current customer
|
||||||
$(".customer-selection-invalid").hide();
|
$(".customer-selection-invalid").hide();
|
||||||
@@ -129,8 +143,7 @@ function addPaymentSource(flash) {
|
|||||||
addDiv('payment-entry-id', 'payment', 'payments', flash,
|
addDiv('payment-entry-id', 'payment', 'payments', flash,
|
||||||
// HTML section
|
// HTML section
|
||||||
'<FIELDSET CLASS="payment subset">' +
|
'<FIELDSET CLASS="payment subset">' +
|
||||||
<?php /* '<LEGEND>Payment #%{id} (%{remove})</LEGEND>' + */ ?>
|
'<LEGEND>Payment #%{id} (%{remove})</LEGEND>' +
|
||||||
'<LEGEND>Payment</LEGEND>' +
|
|
||||||
|
|
||||||
'<DIV ID="payment-div-%{id}">' +
|
'<DIV ID="payment-div-%{id}">' +
|
||||||
<?php
|
<?php
|
||||||
@@ -160,7 +173,7 @@ function addPaymentSource(flash) {
|
|||||||
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
|
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
|
||||||
' <INPUT TYPE="text" SIZE="20"' +
|
' <INPUT TYPE="text" SIZE="20"' +
|
||||||
' NAME="data[Entry][%{id}][amount]"' +
|
' NAME="data[Entry][%{id}][amount]"' +
|
||||||
' CLASS="payment amount"' +
|
' CLASS="payment"' +
|
||||||
' ID="payment-amount-%{id}" />' +
|
' ID="payment-amount-%{id}" />' +
|
||||||
' <LABEL CLASS="payment" FOR="payment-amount-%{id}">Amount</LABEL>' +
|
' <LABEL CLASS="payment" FOR="payment-amount-%{id}">Amount</LABEL>' +
|
||||||
'</DIV>' +
|
'</DIV>' +
|
||||||
@@ -206,19 +219,14 @@ function addPaymentSource(flash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function switchPaymentType(paymentid_base, paymentid, radioid) {
|
function switchPaymentType(paymentid_base, paymentid, radioid) {
|
||||||
|
$("."+paymentid_base+"-"+paymentid).slideUp();
|
||||||
var type_id = $("#"+radioid).val();
|
var type_id = $("#"+radioid).val();
|
||||||
$("."+paymentid_base+"-"+paymentid+
|
|
||||||
":not(" +
|
|
||||||
"#"+paymentid_base+"-"+paymentid+"-"+type_id +
|
|
||||||
")").slideUp();
|
|
||||||
$("#"+paymentid_base+"-"+paymentid+"-"+type_id).slideDown();
|
$("#"+paymentid_base+"-"+paymentid+"-"+type_id).slideDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateChargesGrid(idlist) {
|
function updateChargesGrid(idlist) {
|
||||||
var dynamic_post = new Array();
|
$('#charge-entries-jqGrid').setPostDataItem('idlist', serialize(idlist));
|
||||||
dynamic_post['idlist'] = idlist;
|
|
||||||
|
|
||||||
$('#charge-entries-jqGrid').setPostDataItem('dynamic_post_replace', serialize(dynamic_post));
|
|
||||||
$('#charge-entries-jqGrid')
|
$('#charge-entries-jqGrid')
|
||||||
.setGridParam({ page: 1 })
|
.setGridParam({ page: 1 })
|
||||||
.trigger("reloadGrid");
|
.trigger("reloadGrid");
|
||||||
@@ -230,8 +238,6 @@ function updateCharges(id) {
|
|||||||
url += '/'+id;
|
url += '/'+id;
|
||||||
|
|
||||||
$('#charge-entries-jqGrid').clearGridData();
|
$('#charge-entries-jqGrid').clearGridData();
|
||||||
$("#receipt-balance").html("Calculating...");
|
|
||||||
$("#receipt-charges-caption").html("Please Wait...");
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@@ -245,23 +251,16 @@ function updateCharges(id) {
|
|||||||
$('#receipt-balance').html(fmtCurrency($('entries',xml).attr('balance')));
|
$('#receipt-balance').html(fmtCurrency($('entries',xml).attr('balance')));
|
||||||
$("#receipt-charges-caption").html("Outstanding Charges");
|
$("#receipt-charges-caption").html("Outstanding Charges");
|
||||||
updateChargesGrid(ids);
|
updateChargesGrid(ids);
|
||||||
},
|
}
|
||||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
|
||||||
/* alert('ERROR'); */
|
|
||||||
/* $('#debug').html('<P>request<BR>'+escape(XMLHttpRequest)); */
|
|
||||||
/* $('#debug').append('<P>status<BR>'+escape(textStatus)); */
|
|
||||||
/* $('#debug').append('<P>error<BR>'+escape(errorThrown)); */
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
; // align
|
; // align
|
||||||
// Re-Enable warnings
|
//echo '<DIV ID="dialog">' . "\n";
|
||||||
Configure::write('debug', $saved_debug_state);
|
|
||||||
|
|
||||||
echo $this->element('customers', array
|
echo $this->element('customers', array
|
||||||
('config' => array
|
('config' => array
|
||||||
@@ -352,37 +351,25 @@ echo $this->element('form_table',
|
|||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
echo "<BR>\n";
|
|
||||||
echo $form->input('repeat', array('type' => 'checkbox',
|
|
||||||
'id' => 'repeat',
|
|
||||||
'label' => 'Enter Multiple Receipts')) . "\n";
|
|
||||||
echo $form->submit('Generate Receipt') . "\n";
|
echo $form->submit('Generate Receipt') . "\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php /*
|
|
||||||
<fieldset CLASS="payment superset">
|
<fieldset CLASS="payment superset">
|
||||||
<legend>Payments</legend>
|
<legend>Payments</legend>
|
||||||
*/ ?>
|
|
||||||
<input type="hidden" id="payment-entry-id" value="0">
|
<input type="hidden" id="payment-entry-id" value="0">
|
||||||
<div id="payments"></div>
|
<div id="payments"></div>
|
||||||
<?php /*
|
|
||||||
<fieldset> <legend>
|
<fieldset> <legend>
|
||||||
<a href="#" onClick="addPaymentSource(true); return false;">Add Another Payment</a>
|
<a href="#" onClick="addPaymentSource(true); return false;">Add Another Payment</a>
|
||||||
</legend> </fieldset>
|
</legend> </fieldset>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
*/ ?>
|
|
||||||
|
|
||||||
<?php echo $form->end('Generate Receipt'); ?>
|
<?php echo $form->end('Generate Receipt'); ?>
|
||||||
|
|
||||||
<?php /* echo '</DIV>' . "\n"; // End of the dialog DIV */ ?>
|
<?php /* echo '</DIV>' . "\n"; // End of the dialog DIV */ ?>
|
||||||
|
|
||||||
<div id="results"></div>
|
<div><H4>Request</H4><div id="request-debug"></div></div>
|
||||||
<div id="output-debug" style="display:none"></div>
|
<div><H4>Response</H4><div id="response-debug"></div></div>
|
||||||
|
<div><H4>Output</H4><div id="output-debug"></div></div>
|
||||||
<?php
|
|
||||||
// Warnings _really_ screw up javascript
|
|
||||||
Configure::write('debug', '0');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
@@ -393,13 +380,6 @@ Configure::write('debug', '0');
|
|||||||
showCurrentAtPos: 0,
|
showCurrentAtPos: 0,
|
||||||
dateFormat: 'mm/dd/yy' });
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
datepickerNow('TransactionStamp');
|
|
||||||
|
|
||||||
$("#receipt-customer-id").html("INTERNAL ERROR");
|
|
||||||
$("#receipt-customer-name").html("INTERNAL ERROR");
|
|
||||||
$("#receipt-balance").html("INTERNAL ERROR");
|
|
||||||
$("#receipt-charges-caption").html("Outstanding Charges");
|
|
||||||
|
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
||||||
<?php if (isset($customer['id'])): ?>
|
<?php if (isset($customer['id'])): ?>
|
||||||
@@ -417,7 +397,37 @@ Configure::write('debug', '0');
|
|||||||
onGridState(null, 'visible');
|
onGridState(null, 'visible');
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* $("#dialog").dialog({ */
|
||||||
|
/* bgiframe: true, */
|
||||||
|
/* autoOpen: false, */
|
||||||
|
/* height: 500, */
|
||||||
|
/* width: 600, */
|
||||||
|
/* modal: true, */
|
||||||
|
/* buttons: { */
|
||||||
|
/* 'Post a Payment': function() { */
|
||||||
|
/* var bValid = true; */
|
||||||
|
/* if (bValid) { */
|
||||||
|
/* $('#debug').append('<H2>POSTED!</H2>'); */
|
||||||
|
/* $(this).dialog('close'); */
|
||||||
|
/* } */
|
||||||
|
/* }, */
|
||||||
|
/* Cancel: function() { */
|
||||||
|
/* $(this).dialog('close'); */
|
||||||
|
/* } */
|
||||||
|
/* }, */
|
||||||
|
/* close: function() { */
|
||||||
|
/* } */
|
||||||
|
/* }); */
|
||||||
|
|
||||||
|
/* $('#post-payment').click(function() { */
|
||||||
|
/* $('#dialog').dialog('open'); */
|
||||||
|
/* }); */
|
||||||
|
|
||||||
});
|
});
|
||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a href="#" onClick="$('#debug').html(''); return false;">Clear Debug Output</a>
|
||||||
|
|||||||
@@ -11,9 +11,6 @@ echo '<div class="customer view">' . "\n";
|
|||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array('Name', $customer['Customer']['name']);
|
$rows[] = array('Name', $customer['Customer']['name']);
|
||||||
$rows[] = array('Since', FormatHelper::date($since, true));
|
|
||||||
if (!empty($until))
|
|
||||||
$rows[] = array('Until', FormatHelper::date($until, true));
|
|
||||||
$rows[] = array('Comment', $customer['Customer']['comment']);
|
$rows[] = array('Comment', $customer['Customer']['comment']);
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
@@ -30,9 +27,7 @@ echo $this->element('table',
|
|||||||
echo '<div class="infobox">' . "\n";
|
echo '<div class="infobox">' . "\n";
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array('Security Deposit:', FormatHelper::currency($outstandingDeposit));
|
$rows[] = array('Security Deposit:', FormatHelper::currency($outstandingDeposit));
|
||||||
//$rows[] = array('Charges:', FormatHelper::currency($stats['charges']));
|
$rows[] = array('Balance:', FormatHelper::currency($outstandingBalance));
|
||||||
//$rows[] = array('Payments:', FormatHelper::currency($stats['disbursements']));
|
|
||||||
$rows[] = array('Balance Owed:', FormatHelper::currency($outstandingBalance));
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'summary',
|
array('class' => 'summary',
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
@@ -85,31 +80,35 @@ echo $this->element('leases', array
|
|||||||
echo $this->element('statement_entries', array
|
echo $this->element('statement_entries', array
|
||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => 'Customer Statement',
|
('caption' => 'Account',
|
||||||
'filter' => array('Customer.id' => $customer['Customer']['id'],
|
'filter' => array('Customer.id' => $customer['Customer']['id'],
|
||||||
'type !=' => 'VOID'),
|
'type !=' => 'VOID'),
|
||||||
'exclude' => array('Customer'),
|
'exclude' => array('Customer'),
|
||||||
'sort_column' => 'Effective',
|
|
||||||
'sort_order' => 'DESC',
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Receipt History
|
* Customer Ledger History
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REVISIT <AP>: 20090724
|
||||||
|
* It's not my intention to really include this, as I believe it
|
||||||
|
* just will confuse folks. However, I've added it at the moment
|
||||||
|
* to help me see the picture of what's happening. It may prove
|
||||||
|
* useful with respect to identifying pre-payments, so after using
|
||||||
|
* it for a while, maybe we can get a feeling for that. I suspect
|
||||||
|
* it will be MUCH more useful just to add the pre-pay amount to
|
||||||
|
* the info box, or provide a list of ledger entries that are JUST
|
||||||
|
* pre-payments. We'll see...
|
||||||
|
*/
|
||||||
echo $this->element('ledger_entries', array
|
echo $this->element('ledger_entries', array
|
||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => 'Receipts',
|
('caption' => 'Ledger Entries',
|
||||||
'filter' => array('Customer.id' => $customer['Customer']['id'],
|
'filter' => array('Customer.id' => $customer['Customer']['id'],
|
||||||
'Transaction.type' => 'RECEIPT',
|
'Account.id !=' => '-AR-'),
|
||||||
'Tender.id !=' => null,
|
'exclude' => array('Customer'),
|
||||||
//'Account.id !=' => '-AR-'
|
|
||||||
),
|
|
||||||
'exclude' => array('Account', 'Cr/Dr'),
|
|
||||||
'sort_column' => 'Date',
|
|
||||||
'sort_order' => 'DESC',
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ $cols['Relationship'] = array('index' => 'ContactsCustomer.type', 'formatt
|
|||||||
$cols['Name'] = array('index' => 'Customer.name', 'formatter' => 'longname');
|
$cols['Name'] = array('index' => 'Customer.name', 'formatter' => 'longname');
|
||||||
$cols['Last Name'] = array('index' => 'PrimaryContact.last_name', 'formatter' => 'name');
|
$cols['Last Name'] = array('index' => 'PrimaryContact.last_name', 'formatter' => 'name');
|
||||||
$cols['First Name'] = array('index' => 'PrimaryContact.first_name', 'formatter' => 'name');
|
$cols['First Name'] = array('index' => 'PrimaryContact.first_name', 'formatter' => 'name');
|
||||||
$cols['Leases'] = array('index' => 'current_lease_count', 'formatter' => 'number');
|
$cols['Leases'] = array('index' => 'lease_count', 'formatter' => 'number');
|
||||||
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
|
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
|
||||||
$cols['Comment'] = array('index' => 'Customer.comment', 'formatter' => 'comment');
|
$cols['Comment'] = array('index' => 'Customer.comment', 'formatter' => 'comment');
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ foreach ($fields AS $field => $config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
compact('id', 'class', 'caption', 'headers',
|
compact('class', 'caption', 'headers',
|
||||||
'rows', 'row_class', 'suppress_alternate_rows',
|
'rows', 'row_class', 'suppress_alternate_rows',
|
||||||
'column_class')
|
'column_class')
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -46,12 +46,12 @@ if (!isset($grid_setup))
|
|||||||
$grid_setup = array();
|
$grid_setup = array();
|
||||||
|
|
||||||
// Do some prework to bring in the appropriate libraries
|
// Do some prework to bring in the appropriate libraries
|
||||||
$html->css('jqGrid/ui.jqgrid', null, null, false);
|
$imgpath = '/pmgr/site/css/jqGrid/basic/images';
|
||||||
//$html->css('jqGrid/jqModal', null, null, false);
|
$html->css('jqGrid/basic/grid', null, null, false);
|
||||||
$javascript->link('jqGrid/grid.locale-en', false);
|
$html->css('jqGrid/jqModal', null, null, false);
|
||||||
$javascript->link('jqGrid/jquery.jqGrid.min', false);
|
$javascript->link('jqGrid/jquery.jqGrid.js', false);
|
||||||
//$javascript->link('jqGrid/js/jqModal', false);
|
$javascript->link('jqGrid/js/jqModal', false);
|
||||||
//$javascript->link('jqGrid/js/jqDnR', false);
|
$javascript->link('jqGrid/js/jqDnR', false);
|
||||||
$javascript->link('pmgr_jqGrid', false);
|
$javascript->link('pmgr_jqGrid', false);
|
||||||
|
|
||||||
|
|
||||||
@@ -231,8 +231,8 @@ $jqGrid_setup = array_merge
|
|||||||
'sortname' => $sortname,
|
'sortname' => $sortname,
|
||||||
'sortorder' => $sortorder,
|
'sortorder' => $sortorder,
|
||||||
'caption' => $caption,
|
'caption' => $caption,
|
||||||
|
'imgpath' => $imgpath,
|
||||||
'viewrecords' => true,
|
'viewrecords' => true,
|
||||||
'gridview' => true,
|
|
||||||
'pager' => $grid_id.'-pager',
|
'pager' => $grid_id.'-pager',
|
||||||
),
|
),
|
||||||
$grid_events,
|
$grid_events,
|
||||||
@@ -251,16 +251,16 @@ $jqGrid_setup = array_merge
|
|||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
jQuery(document).ready(function(){
|
jQuery(document).ready(function(){
|
||||||
currencyFormatter = function(cellval, opts, rowObject) {
|
currencyFormatter = function(el, cellval, opts) {
|
||||||
if (!cellval)
|
if (!cellval)
|
||||||
return "";
|
return;
|
||||||
return fmtCurrency(cellval);
|
$(el).html(fmtCurrency(cellval));
|
||||||
}
|
}
|
||||||
|
|
||||||
idFormatter = function(cellval, opts, rowObject) {
|
idFormatter = function(el, cellval, opts) {
|
||||||
if (!cellval)
|
if (!cellval)
|
||||||
return cellval;
|
return;
|
||||||
return '#'+cellval;
|
$(el).html('#'+cellval);
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery('#<?php echo $grid_id; ?>').jqGrid(
|
jQuery('#<?php echo $grid_id; ?>').jqGrid(
|
||||||
@@ -272,6 +272,36 @@ jQuery(document).ready(function(){
|
|||||||
del:false,
|
del:false,
|
||||||
search:true,
|
search:true,
|
||||||
refresh:true});
|
refresh:true});
|
||||||
|
|
||||||
|
<?php
|
||||||
|
/* jQuery('#t_<?php echo $grid_id; ?>').height(25).hide() */
|
||||||
|
/* .filterGrid('#<?php echo $grid_id; ?>', { */
|
||||||
|
/* gridModel:true, */
|
||||||
|
/* gridToolbar:true, */
|
||||||
|
/* autosearch:true, */
|
||||||
|
/* }); */
|
||||||
|
|
||||||
|
/* jQuery('#<?php echo $grid_id; ?>').navGrid('#<?php echo $grid_id; ?>-pager', */
|
||||||
|
/* { view:false, */
|
||||||
|
/* edit:false, */
|
||||||
|
/* add:false, */
|
||||||
|
/* del:false, */
|
||||||
|
/* search:false, */
|
||||||
|
/* refresh:false}) */
|
||||||
|
/* .navButtonAdd('#<?php echo $grid_id; ?>-pager',{ */
|
||||||
|
/* caption:"Search", */
|
||||||
|
/* title:"Toggle Search", */
|
||||||
|
/* buttonimg:'<?php echo $imgpath; ?>' + '/find.gif', */
|
||||||
|
/* onClickButton:function(){ */
|
||||||
|
/* if(jQuery('#t_<?php echo $grid_id; ?>').css("display")=="none") { */
|
||||||
|
/* jQuery('#t_<?php echo $grid_id; ?>').css("display",""); */
|
||||||
|
/* } else { */
|
||||||
|
/* jQuery('#t_<?php echo $grid_id; ?>').css("display","none"); */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
/* }); */
|
||||||
|
?>
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ $cols['Deposit'] = array('index' => 'Lease.deposit', 'formatter' => 'cur
|
|||||||
$cols['Signed'] = array('index' => 'Lease.lease_date', 'formatter' => 'date');
|
$cols['Signed'] = array('index' => 'Lease.lease_date', 'formatter' => 'date');
|
||||||
$cols['Move-In'] = array('index' => 'Lease.movein_date', 'formatter' => 'date');
|
$cols['Move-In'] = array('index' => 'Lease.movein_date', 'formatter' => 'date');
|
||||||
$cols['Move-Out'] = array('index' => 'Lease.moveout_date', 'formatter' => 'date');
|
$cols['Move-Out'] = array('index' => 'Lease.moveout_date', 'formatter' => 'date');
|
||||||
$cols['Closed'] = array('index' => 'Lease.close_date', 'formatter' => 'date');
|
|
||||||
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
|
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
|
||||||
$cols['Comment'] = array('index' => 'Lease.comment', 'formatter' => 'comment');
|
$cols['Comment'] = array('index' => 'Lease.comment', 'formatter' => 'comment');
|
||||||
|
|
||||||
|
|||||||
@@ -17,9 +17,8 @@ $cols['Unit'] = array('index' => 'Unit.name', 'formatter' =>
|
|||||||
|
|
||||||
$cols['Comment'] = array('index' => 'StatementEntry.comment', 'formatter' => 'comment', 'width'=>150);
|
$cols['Comment'] = array('index' => 'StatementEntry.comment', 'formatter' => 'comment', 'width'=>150);
|
||||||
|
|
||||||
$cols['Type'] = array('index' => 'StatementEntry.type', 'formatter' => 'enum', 'width'=>120);
|
$cols['Charge'] = array('index' => 'charge', 'formatter' => 'currency');
|
||||||
$cols['Debit'] = array('index' => 'charge', 'formatter' => 'currency');
|
$cols['Payment'] = array('index' => 'payment', 'formatter' => 'currency');
|
||||||
$cols['Credit'] = array('index' => 'disbursement', 'formatter' => 'currency');
|
|
||||||
|
|
||||||
$cols['Applied'] = array('index' => "applied", 'formatter' => 'currency');
|
$cols['Applied'] = array('index' => "applied", 'formatter' => 'currency');
|
||||||
$cols['Sub-Total'] = array('index' => 'subtotal-balance', 'formatter' => 'currency', 'sortable' => false);
|
$cols['Sub-Total'] = array('index' => 'subtotal-balance', 'formatter' => 'currency', 'sortable' => false);
|
||||||
|
|||||||
@@ -64,10 +64,7 @@ if (isset($rows) && is_array($rows) && count($rows)) {
|
|||||||
$class = implode(' ', $class);
|
$class = implode(' ', $class);
|
||||||
|
|
||||||
// OK, output the table HTML
|
// OK, output the table HTML
|
||||||
echo('<TABLE' .
|
echo('<TABLE' . (isset($class) ? ' CLASS="'.$class.'"' : '') . '>' . "\n");
|
||||||
(isset($id) ? ' ID="'.$id.'"' : '') .
|
|
||||||
(isset($class) ? ' CLASS="'.$class.'"' : '') .
|
|
||||||
'>' . "\n");
|
|
||||||
|
|
||||||
if (isset($caption))
|
if (isset($caption))
|
||||||
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
|
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ $cols['ID'] = array('index' => 'Unit.id', 'formatter' => 'id');
|
|||||||
$cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'shortname');
|
$cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'shortname');
|
||||||
$cols['Size'] = array('index' => 'UnitSize.name', 'formatter' => 'shortname');
|
$cols['Size'] = array('index' => 'UnitSize.name', 'formatter' => 'shortname');
|
||||||
$cols['Rent'] = array('index' => 'Unit.rent', 'formatter' => 'currency');
|
$cols['Rent'] = array('index' => 'Unit.rent', 'formatter' => 'currency');
|
||||||
$cols['Deposit'] = array('index' => 'Unit.deposit', 'formatter' => 'currency');
|
|
||||||
$cols['Status'] = array('index' => 'Unit.status', 'formatter' => 'name'); // We have enough real estate
|
$cols['Status'] = array('index' => 'Unit.status', 'formatter' => 'name'); // We have enough real estate
|
||||||
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
|
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
|
||||||
$cols['Comment'] = array('index' => 'Unit.comment', 'formatter' => 'comment');
|
$cols['Comment'] = array('index' => 'Unit.comment', 'formatter' => 'comment');
|
||||||
@@ -20,4 +19,4 @@ $grid
|
|||||||
->defaultFields(array('Sort', 'ID', 'Unit'))
|
->defaultFields(array('Sort', 'ID', 'Unit'))
|
||||||
->searchFields(array('Unit', 'Size', 'Status'))
|
->searchFields(array('Unit', 'Size', 'Status'))
|
||||||
->render($this, isset($config) ? $config : null,
|
->render($this, isset($config) ? $config : null,
|
||||||
array_diff(array_keys($cols), array('Walk', 'Deposit', 'Comment')));
|
array_diff(array_keys($cols), array('Walk', 'Comment')));
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ class FormatHelper extends AppHelper {
|
|||||||
true));
|
true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function currency($amount, $spans = false, $dollar_sign = null) {
|
function currency($amount, $spans = false) {
|
||||||
if (!isset($amount))
|
if (!isset($amount))
|
||||||
return '-';
|
return '-';
|
||||||
//return null;
|
//return null;
|
||||||
|
|
||||||
$currency = self::$number->currency($amount,
|
$currency = self::$number->currency($amount,
|
||||||
isset($dollar_sign) ? $dollar_sign : 'USD',
|
'USD',
|
||||||
$spans ? array('before'=>'', 'after'=>'') : array());
|
$spans ? array('before'=>'', 'after'=>'') : array());
|
||||||
|
|
||||||
if ($spans)
|
if ($spans)
|
||||||
|
|||||||
@@ -211,9 +211,8 @@ class GridHelper extends AppHelper {
|
|||||||
|
|
||||||
// Incorporate all other user options
|
// Incorporate all other user options
|
||||||
if (isset($config))
|
if (isset($config))
|
||||||
$this->jqGrid_options = array_merge($this->jqGrid_options, $config);
|
$this->jqGrid_options = array_merge_recursive($this->jqGrid_options, $config);
|
||||||
|
|
||||||
//pr(compact('config') + array('jqGrid_options' => $this->jqGrid_options));
|
|
||||||
echo $view->element('jqGrid', $this->jqGrid_options);
|
echo $view->element('jqGrid', $this->jqGrid_options);
|
||||||
|
|
||||||
// Since we only have one instance of this class
|
// Since we only have one instance of this class
|
||||||
|
|||||||
@@ -35,12 +35,12 @@
|
|||||||
echo $html->css('layout') . "\n";
|
echo $html->css('layout') . "\n";
|
||||||
echo $html->css('print', null, array('media' => 'print')) . "\n";
|
echo $html->css('print', null, array('media' => 'print')) . "\n";
|
||||||
echo $html->css('sidemenu') . "\n";
|
echo $html->css('sidemenu') . "\n";
|
||||||
echo $javascript->link('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js') . "\n";
|
//echo $html->css('jquery/base/ui.all') . "\n";
|
||||||
echo $javascript->link('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js') . "\n";
|
//echo $html->css('jquery/smoothness/ui.all') . "\n";
|
||||||
//echo $html->css('themes/base/ui.all') . "\n";
|
//echo $html->css('jquery/dotluv/ui.all') . "\n";
|
||||||
//echo $html->css('themes/smoothness/ui.all') . "\n";
|
echo $html->css('jquery/start/ui.all') . "\n";
|
||||||
//echo $html->css('themes/dotluv/ui.all') . "\n";
|
echo $javascript->link('jquery/jquery') . "\n";
|
||||||
echo $html->css('themes/start/ui.all') . "\n";
|
echo $javascript->link('jquery/jquery-ui') . "\n";
|
||||||
echo $javascript->link('jquery.form') . "\n";
|
echo $javascript->link('jquery.form') . "\n";
|
||||||
echo $javascript->link('pmgr') . "\n";
|
echo $javascript->link('pmgr') . "\n";
|
||||||
echo $scripts_for_layout . "\n";
|
echo $scripts_for_layout . "\n";
|
||||||
|
|||||||
88
site/views/leases/apply_deposit.ctp
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
<?php /* -*- mode:PHP -*- */
|
||||||
|
|
||||||
|
echo '<div class="apply-deposit input">' . "\n";
|
||||||
|
|
||||||
|
echo ('<DIV CLASS="apply-deposit grid-selection-text">' .
|
||||||
|
|
||||||
|
'Lease #' . $lease['number'] .
|
||||||
|
' / Customer #' . $customer['id'] .
|
||||||
|
': ' . $customer['name'] .
|
||||||
|
' / Unit ' . $unit['name'] .
|
||||||
|
|
||||||
|
'<DIV CLASS="supporting">' .
|
||||||
|
'<TABLE>' .
|
||||||
|
|
||||||
|
/* '<TR><TD CLASS="field">Balance:</TD><TD CLASS="value">' . */
|
||||||
|
/* FormatHelper::currency($lease['stats']['balance']) . */
|
||||||
|
/* '</TD></TR>' . */
|
||||||
|
|
||||||
|
'<TR><TD CLASS="field">Deposit:</TD><TD CLASS="value">' .
|
||||||
|
FormatHelper::currency($depositBalance) .
|
||||||
|
'</TD></TR>' .
|
||||||
|
|
||||||
|
'</TABLE>' .
|
||||||
|
'</DIV>' .
|
||||||
|
|
||||||
|
'</DIV>' . "\n");
|
||||||
|
|
||||||
|
|
||||||
|
echo $form->create(null, array('id' => 'apply-deposit-form',
|
||||||
|
'url' => array('controller' => 'leases',
|
||||||
|
'action' => 'apply_deposit')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
echo $form->input("Customer.id",
|
||||||
|
array('id' => 'customer-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => $customer['id']));
|
||||||
|
|
||||||
|
echo $form->input("Lease.id",
|
||||||
|
array('id' => 'lease-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => $lease['id']));
|
||||||
|
|
||||||
|
echo $form->input("LedgerEntry.Account.id",
|
||||||
|
array('id' => 'account-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => $account['id']));
|
||||||
|
|
||||||
|
|
||||||
|
echo $this->element('form_table',
|
||||||
|
array('class' => "item receipt transaction entry",
|
||||||
|
//'with_name_after' => ':',
|
||||||
|
'field_prefix' => 'Transaction',
|
||||||
|
'fields' => array
|
||||||
|
("stamp" => array('opts' => array('type' => 'text'),
|
||||||
|
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
|
||||||
|
),
|
||||||
|
"amount" => array('prefix' => 'LedgerEntry',
|
||||||
|
'opts' => array('value' => $depositBalance),
|
||||||
|
),
|
||||||
|
"comment" => array('opts' => array('size' => 50),
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
|
||||||
|
echo $form->end('Utilize Deposit');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
|
// Reset the form
|
||||||
|
function resetForm() {
|
||||||
|
datepickerNow('TransactionStamp');
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#TransactionStamp")
|
||||||
|
.attr('autocomplete', 'off')
|
||||||
|
.datepicker({ constrainInput: true,
|
||||||
|
numberOfMonths: [1, 1],
|
||||||
|
showCurrentAtPos: 0,
|
||||||
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
|
resetForm();
|
||||||
|
});
|
||||||
|
--></script>
|
||||||
|
|
||||||
|
</div>
|
||||||
80
site/views/leases/bad_debt.ctp
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
<?php /* -*- mode:PHP -*- */
|
||||||
|
|
||||||
|
echo '<div class="bad-debt input">' . "\n";
|
||||||
|
|
||||||
|
echo ('<DIV CLASS="bad-debt grid-selection-text">' .
|
||||||
|
|
||||||
|
'Lease #' . $lease['number'] .
|
||||||
|
' / Customer #' . $customer['id'] .
|
||||||
|
': ' . $customer['name'] .
|
||||||
|
' / Unit ' . $unit['name'] .
|
||||||
|
|
||||||
|
'<DIV CLASS="supporting">' .
|
||||||
|
'<TABLE>' .
|
||||||
|
'<TR><TD CLASS="field">Balance:</TD><TD CLASS="value">'.$lease['stats']['balance'].'</TD></TR>' .
|
||||||
|
'</TABLE>' .
|
||||||
|
'</DIV>' .
|
||||||
|
|
||||||
|
'</DIV>' . "\n");
|
||||||
|
|
||||||
|
|
||||||
|
echo $form->create(null, array('id' => 'receipt-form',
|
||||||
|
'url' => array('controller' => 'transactions',
|
||||||
|
'action' => 'postReceipt')));
|
||||||
|
|
||||||
|
echo $form->input("Customer.id",
|
||||||
|
array('id' => 'customer-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => $customer['id']));
|
||||||
|
|
||||||
|
echo $form->input("Lease.id",
|
||||||
|
array('id' => 'lease-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => $lease['id']));
|
||||||
|
|
||||||
|
echo $form->input("LedgerEntry.0.account_id",
|
||||||
|
array('id' => 'account-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => $account['id']));
|
||||||
|
|
||||||
|
echo $form->input("LedgerEntry.0.amount",
|
||||||
|
array('id' => 'amount',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => $lease['stats']['balance']));
|
||||||
|
|
||||||
|
|
||||||
|
echo $this->element('form_table',
|
||||||
|
array('class' => "item receipt transaction entry",
|
||||||
|
//'with_name_after' => ':',
|
||||||
|
'field_prefix' => 'Transaction',
|
||||||
|
'fields' => array
|
||||||
|
("stamp" => array('opts' => array('type' => 'text'),
|
||||||
|
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
|
||||||
|
),
|
||||||
|
"comment" => array('opts' => array('size' => 50),
|
||||||
|
),
|
||||||
|
)));
|
||||||
|
|
||||||
|
echo $form->end('Write Off Remaining Balance');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
|
// Reset the form
|
||||||
|
function resetForm() {
|
||||||
|
datepickerNow('TransactionStamp');
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#TransactionStamp")
|
||||||
|
.attr('autocomplete', 'off')
|
||||||
|
.datepicker({ constrainInput: true,
|
||||||
|
numberOfMonths: [1, 1],
|
||||||
|
showCurrentAtPos: 0,
|
||||||
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
|
resetForm();
|
||||||
|
});
|
||||||
|
--></script>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -4,13 +4,6 @@
|
|||||||
<?php
|
<?php
|
||||||
; // Editor alignment
|
; // Editor alignment
|
||||||
|
|
||||||
$unit = $lease['Unit'];
|
|
||||||
$customer = $lease['Customer'];
|
|
||||||
|
|
||||||
if (isset($lease['Lease']))
|
|
||||||
$lease = $lease['Lease'];
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
@@ -18,9 +11,6 @@ if (isset($lease['Lease']))
|
|||||||
* Javascript
|
* Javascript
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Warnings _really_ screw up javascript
|
|
||||||
$saved_debug_state = Configure::read('debug');
|
|
||||||
Configure::write('debug', '0');
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
@@ -33,8 +23,14 @@ Configure::write('debug', '0');
|
|||||||
success: showResponse, // post-submit callback
|
success: showResponse, // post-submit callback
|
||||||
|
|
||||||
// other available options:
|
// other available options:
|
||||||
|
//url: url, // override for form's 'action' attribute
|
||||||
|
//type: 'get', // 'get' or 'post', override for form's 'method' attribute
|
||||||
|
//dataType: null, // 'xml', 'script', or 'json' (expected server response type)
|
||||||
//clearForm: true, // clear all form fields after successful submit
|
//clearForm: true, // clear all form fields after successful submit
|
||||||
//resetForm: true, // reset the form after successful submit
|
//resetForm: true, // reset the form after successful submit
|
||||||
|
|
||||||
|
// $.ajax options can be used here too, for example:
|
||||||
|
//timeout: 3000,
|
||||||
};
|
};
|
||||||
|
|
||||||
// bind form using 'ajaxForm'
|
// bind form using 'ajaxForm'
|
||||||
@@ -43,7 +39,16 @@ Configure::write('debug', '0');
|
|||||||
|
|
||||||
// pre-submit callback
|
// pre-submit callback
|
||||||
function verifyRequest(formData, jqForm, options) {
|
function verifyRequest(formData, jqForm, options) {
|
||||||
$('#results').html('Working <BLINK>...</BLINK>');
|
// formData is an array; here we use $.param to convert it to a string to display it
|
||||||
|
// but the form plugin does this for you automatically when it submits the data
|
||||||
|
//var_dump(formData);
|
||||||
|
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
|
||||||
|
$('#request-debug').html('Ommitted');
|
||||||
|
//return false;
|
||||||
|
|
||||||
|
$('#response-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
|
$('#output-debug').html('Loading <BLINK>...</BLINK>');
|
||||||
|
|
||||||
// here we could return false to prevent the form from being submitted;
|
// here we could return false to prevent the form from being submitted;
|
||||||
// returning anything other than false will allow the form submit to continue
|
// returning anything other than false will allow the form submit to continue
|
||||||
return true;
|
return true;
|
||||||
@@ -51,41 +56,42 @@ function verifyRequest(formData, jqForm, options) {
|
|||||||
|
|
||||||
// post-submit callback
|
// post-submit callback
|
||||||
function showResponse(responseText, statusText) {
|
function showResponse(responseText, statusText) {
|
||||||
|
// for normal html responses, the first argument to the success callback
|
||||||
|
// is the XMLHttpRequest object's responseText property
|
||||||
|
|
||||||
|
// if the ajaxForm method was passed an Options Object with the dataType
|
||||||
|
// property set to 'xml' then the first argument to the success callback
|
||||||
|
// is the XMLHttpRequest object's responseXML property
|
||||||
|
|
||||||
|
// if the ajaxForm method was passed an Options Object with the dataType
|
||||||
|
// property set to 'json' then the first argument to the success callback
|
||||||
|
// is the json data object returned by the server
|
||||||
|
|
||||||
if (statusText == 'success') {
|
if (statusText == 'success') {
|
||||||
var amount = 0;
|
|
||||||
$("input.invoice.amount").each(function(i) {
|
|
||||||
amount += (+ $(this).val().replace(/\$/,''));
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#results').html('<H3>Invoice Saved<BR>' +
|
|
||||||
$("#invoice-customer").html() +
|
|
||||||
' : ' + fmtCurrency(amount) +
|
|
||||||
'</H3>');
|
|
||||||
|
|
||||||
if (!$("#repeat").attr("checked")) {
|
|
||||||
window.location.href =
|
|
||||||
"<?php echo $html->url(array('controller' => 'leases',
|
|
||||||
'action' => 'view')); ?>"
|
|
||||||
+ "/" + $("#lease-id").val();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get a clean slate
|
// get a clean slate
|
||||||
//resetForm();
|
//resetForm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#results').html('<H2>Failed to save invoice!</H2>');
|
alert('not successful??');
|
||||||
alert('Failed to save invoice.');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('#response-debug').html('<PRE>'+dump(statusText)+'</PRE>');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
function resetForm(nocharge) {
|
function resetForm() {
|
||||||
$('#charge-entry-id').val(1);
|
$("#charge-entry-id").val(1);
|
||||||
$('#charges').html('');
|
|
||||||
|
|
||||||
if (!nocharge)
|
$("#invoice-lease").html("INTERNAL ERROR");
|
||||||
addChargeSource(false);
|
$("#invoice-unit").html("INTERNAL ERROR");
|
||||||
|
$("#invoice-customer").html("INTERNAL ERROR");
|
||||||
|
$("#invoice-rent").html("INTERNAL ERROR");
|
||||||
|
$("#invoice-late").html("INTERNAL ERROR");
|
||||||
|
$("#invoice-deposit").html("INTERNAL ERROR");
|
||||||
|
|
||||||
|
addChargeSource(false);
|
||||||
|
datepickerNow('TransactionStamp');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,8 +152,7 @@ function addChargeSource(flash) {
|
|||||||
<?php
|
<?php
|
||||||
echo FormatHelper::phpVarToJavascript
|
echo FormatHelper::phpVarToJavascript
|
||||||
($this->element('form_table',
|
($this->element('form_table',
|
||||||
array('id' => 'Entry%{id}Form',
|
array('class' => "item invoice ledger-entry entry",
|
||||||
'class' => "item invoice ledger-entry entry",
|
|
||||||
//'with_name_after' => ':',
|
//'with_name_after' => ':',
|
||||||
'field_prefix' => 'Entry.%{id}',
|
'field_prefix' => 'Entry.%{id}',
|
||||||
'fields' => array
|
'fields' => array
|
||||||
@@ -165,7 +170,7 @@ function addChargeSource(flash) {
|
|||||||
array('type' => 'text'),
|
array('type' => 'text'),
|
||||||
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'Entry%{id}EffectiveDate\',\'Entry%{id}ThroughDate\'); return false;">EOM</A>',
|
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'Entry%{id}EffectiveDate\',\'Entry%{id}ThroughDate\'); return false;">EOM</A>',
|
||||||
),
|
),
|
||||||
"amount" => array('opts' => array('class' => 'invoice amount')),
|
"amount" => true,
|
||||||
"comment" => array('opts' => array('size' => 50)),
|
"comment" => array('opts' => array('size' => 50)),
|
||||||
),
|
),
|
||||||
))) . "+\n";
|
))) . "+\n";
|
||||||
@@ -187,16 +192,12 @@ function addChargeSource(flash) {
|
|||||||
numberOfMonths: [1, 1],
|
numberOfMonths: [1, 1],
|
||||||
showCurrentAtPos: 0,
|
showCurrentAtPos: 0,
|
||||||
dateFormat: 'mm/dd/yy' });
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
; // align
|
; // align
|
||||||
// Re-Enable warnings
|
|
||||||
Configure::write('debug', $saved_debug_state);
|
|
||||||
|
|
||||||
echo $this->element('leases', array
|
echo $this->element('leases', array
|
||||||
('config' => array
|
('config' => array
|
||||||
@@ -204,7 +205,7 @@ echo $this->element('leases', array
|
|||||||
'grid_div_class' => 'text-below',
|
'grid_div_class' => 'text-below',
|
||||||
'caption' => ('<A HREF="#" ONCLICK="$(\'#leases-list .HeaderButton\').click();'.
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#leases-list .HeaderButton\').click();'.
|
||||||
' return false;">Select Lease</A>'),
|
' return false;">Select Lease</A>'),
|
||||||
'grid_setup' => array('hiddengrid' => isset($lease['id'])),
|
'grid_setup' => array('hiddengrid' => isset($lease['Lease']['id'])),
|
||||||
'grid_events' => array('onSelectRow' =>
|
'grid_events' => array('onSelectRow' =>
|
||||||
array('ids' =>
|
array('ids' =>
|
||||||
'if (ids != null){onRowSelect("#"+$(this).attr("id"), ids);}'),
|
'if (ids != null){onRowSelect("#"+$(this).attr("id"), ids);}'),
|
||||||
@@ -266,10 +267,6 @@ echo $this->element('form_table',
|
|||||||
|
|
||||||
/* echo '</fieldset>' . "\n"; */
|
/* echo '</fieldset>' . "\n"; */
|
||||||
|
|
||||||
echo "<BR>\n";
|
|
||||||
echo $form->input('repeat', array('type' => 'checkbox',
|
|
||||||
'id' => 'repeat',
|
|
||||||
'label' => 'Enter Multiple Invoices')) . "\n";
|
|
||||||
echo $form->submit('Generate Invoice') . "\n";
|
echo $form->submit('Generate Invoice') . "\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -284,20 +281,11 @@ echo $form->submit('Generate Invoice') . "\n";
|
|||||||
|
|
||||||
<?php echo $form->end('Generate Invoice'); ?>
|
<?php echo $form->end('Generate Invoice'); ?>
|
||||||
|
|
||||||
<div id="results"></div>
|
<div><H4>Request</H4><div id="request-debug"></div></div>
|
||||||
<div id="output-debug" style="display:none"></div>
|
<div><H4>Response</H4><div id="response-debug"></div></div>
|
||||||
|
<div><H4>Output</H4><div id="output-debug"></div></div>
|
||||||
<?php
|
|
||||||
// Warnings _really_ screw up javascript
|
|
||||||
Configure::write('debug', '0');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
$.fn.removeCol = function(col){
|
|
||||||
if(!col){ col = 1; }
|
|
||||||
$('tr td:nth-child('+col+'), tr th:nth-child('+col+')', this).remove();
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#TransactionStamp")
|
$("#TransactionStamp")
|
||||||
.attr('autocomplete', 'off')
|
.attr('autocomplete', 'off')
|
||||||
@@ -306,96 +294,21 @@ Configure::write('debug', '0');
|
|||||||
showCurrentAtPos: 0,
|
showCurrentAtPos: 0,
|
||||||
dateFormat: 'mm/dd/yy' });
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
$("#invoice-lease").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-unit").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-customer").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-rent").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-late").html("INTERNAL ERROR");
|
|
||||||
$("#invoice-deposit").html("INTERNAL ERROR");
|
|
||||||
|
|
||||||
<?php if (empty($movein)): ?>
|
|
||||||
|
|
||||||
resetForm();
|
resetForm();
|
||||||
datepickerNow('TransactionStamp');
|
|
||||||
|
|
||||||
<?php else: ?>
|
<?php if (isset($lease['Lease']['id'])): ?>
|
||||||
|
$("#lease-id").val(<?php echo $lease['Lease']['id']; ?>);
|
||||||
var id;
|
//$("#invoice-lease").html("<?php echo '#'.$lease['Lease']['number']; ?>");
|
||||||
resetForm(true);
|
|
||||||
|
|
||||||
$("#TransactionStamp").datepicker('disable');
|
|
||||||
$("#TransactionStamp").val("<?php echo date('m/d/Y', $movein['time']); ?>");
|
|
||||||
$('#TransactionStamp').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Transaction][stamp]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['time']); ?>">');
|
|
||||||
$("#TransactionComment").val('Move-In Charges');
|
|
||||||
|
|
||||||
id = addChargeSource(false);
|
|
||||||
$('#Entry'+id+'Form').removeCol(2);
|
|
||||||
$('#Entry'+id+'Form input, #Entry'+id+'Form select').attr('disabled', true);
|
|
||||||
$('#Entry'+id+'EffectiveDate').val("<?php echo date('m/d/Y', $movein['effective_time']); ?>");
|
|
||||||
$('#Entry'+id+'EffectiveDate').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][effective_date]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['effective_time']); ?>">');
|
|
||||||
$('#Entry'+id+'AccountId').val(<?php echo $securityDepositAccount; ?>);
|
|
||||||
$('#Entry'+id+'AccountId').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][account_id]"' +
|
|
||||||
' value="<?php echo $securityDepositAccount; ?>">');
|
|
||||||
$('#Entry'+id+'Amount').val("<?php echo FormatHelper::currency($movein['deposit']); ?>");
|
|
||||||
$('#Entry'+id+'Amount').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][amount]"' +
|
|
||||||
' value="<?php echo FormatHelper::currency($movein['deposit']); ?>">');
|
|
||||||
//$('#Entry'+id+'Comment').val('Move-In Security Deposit');
|
|
||||||
$('#Entry'+id+'Comment').removeAttr('disabled');
|
|
||||||
|
|
||||||
|
|
||||||
id = addChargeSource(false);
|
|
||||||
$('#Entry'+id+'Form').removeCol(2);
|
|
||||||
$('#Entry'+id+'Form input, #Entry'+id+'Form select').attr('disabled', true);
|
|
||||||
$('#Entry'+id+'EffectiveDate').val("<?php echo date('m/d/Y', $movein['effective_time']); ?>");
|
|
||||||
$('#Entry'+id+'EffectiveDate').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][effective_date]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['effective_time']); ?>">');
|
|
||||||
$('#Entry'+id+'ThroughDate').val("<?php echo date('m/d/Y', $movein['through_time']); ?>");
|
|
||||||
$('#Entry'+id+'ThroughDate').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][through_date]"' +
|
|
||||||
' value="<?php echo date('m/d/Y', $movein['through_time']); ?>">');
|
|
||||||
$('#Entry'+id+'AccountId').val(<?php echo $rentAccount; ?>);
|
|
||||||
$('#Entry'+id+'AccountId').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][account_id]"' +
|
|
||||||
' value="<?php echo $rentAccount; ?>">');
|
|
||||||
$('#Entry'+id+'Amount').val("<?php echo FormatHelper::currency($movein['prorated_rent']); ?>");
|
|
||||||
$('#Entry'+id+'Amount').after
|
|
||||||
('<input type="hidden"' +
|
|
||||||
' name="data[Entry]['+id+'][amount]"' +
|
|
||||||
' value="<?php echo FormatHelper::currency($movein['prorated_rent']); ?>">');
|
|
||||||
$('#Entry'+id+'Comment').val('Move-In Rent'
|
|
||||||
<?php if ($movein['prorated']) echo "+ ' (Prorated)'" ?>);
|
|
||||||
$('#Entry'+id+'Comment').removeAttr('disabled');
|
|
||||||
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php if (isset($lease['id'])): ?>
|
|
||||||
$("#lease-id").val(<?php echo $lease['id']; ?>);
|
|
||||||
//$("#invoice-lease").html("<?php echo '#'.$lease['number']; ?>");
|
|
||||||
$("#invoice-lease").html('<A HREF="/pmgr/site/leases/view/' +
|
$("#invoice-lease").html('<A HREF="/pmgr/site/leases/view/' +
|
||||||
"<?php echo $lease['id']; ?>" +
|
"<?php echo $lease['Lease']['id']; ?>" +
|
||||||
'">#' +
|
'">#' +
|
||||||
"<?php echo $lease['number']; ?>" +
|
"<?php echo $lease['Lease']['number']; ?>" +
|
||||||
'</A>');
|
'</A>');
|
||||||
$("#invoice-unit").html("<?php echo $unit['name']; ?>");
|
$("#invoice-unit").html("<?php echo $lease['Unit']['name']; ?>");
|
||||||
$("#invoice-customer").html("<?php echo $customer['name']; ?>");
|
$("#invoice-customer").html("<?php echo $lease['Customer']['name']; ?>");
|
||||||
$("#invoice-rent").html("<?php echo FormatHelper::currency($lease['rent']); ?>");
|
$("#invoice-rent").html("<?php echo FormatHelper::currency($lease['Lease']['rent']); ?>");
|
||||||
$("#invoice-late").html("<?php echo FormatHelper::currency($defaultLate); ?>");
|
$("#invoice-late").html('$10.00');
|
||||||
$("#invoice-deposit").html("<?php echo FormatHelper::currency($lease['deposit']); ?>");
|
$("#invoice-deposit").html("<?php echo FormatHelper::currency($lease['Lease']['deposit']); ?>");
|
||||||
onGridState(null, 'hidden');
|
onGridState(null, 'hidden');
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
onGridState(null, 'visible');
|
onGridState(null, 'visible');
|
||||||
@@ -404,3 +317,5 @@ Configure::write('debug', '0');
|
|||||||
--></script>
|
--></script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<a href="#" onClick="$('#debug').html(''); return false;">Clear Debug Output</a>
|
||||||
|
|||||||
@@ -41,12 +41,6 @@ function onRowSelect(grid_id, item_type, item_id) {
|
|||||||
// Get the item name from the grid
|
// Get the item name from the grid
|
||||||
$("#move-"+item_type).html($(grid_id).getCell(item_id, cell_name));
|
$("#move-"+item_type).html($(grid_id).getCell(item_id, cell_name));
|
||||||
|
|
||||||
// If a unit was selected, update the rent and deposit
|
|
||||||
if (item_type == 'unit') {
|
|
||||||
$("#LeaseRent").val($(grid_id).getCell(item_id, 'Unit-rent'));
|
|
||||||
$("#LeaseDeposit").val($(grid_id).getCell(item_id, 'Unit-deposit'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide the "no customer" message and show the current customer
|
// Hide the "no customer" message and show the current customer
|
||||||
$("."+item_type+"-selection-invalid").hide();
|
$("."+item_type+"-selection-invalid").hide();
|
||||||
$("."+item_type+"-selection-valid").show();
|
$("."+item_type+"-selection-valid").show();
|
||||||
@@ -126,8 +120,6 @@ if ($move_type !== 'out') {
|
|||||||
array('gridstate' =>
|
array('gridstate' =>
|
||||||
'onGridState("#"+$(this).attr("id"), "unit", gridstate)'),
|
'onGridState("#"+$(this).attr("id"), "unit", gridstate)'),
|
||||||
),
|
),
|
||||||
'include' => array('Deposit'),
|
|
||||||
'exclude' => array('Balance'),
|
|
||||||
'action' => 'unoccupied',
|
'action' => 'unoccupied',
|
||||||
'nolinks' => true,
|
'nolinks' => true,
|
||||||
'limit' => 10,
|
'limit' => 10,
|
||||||
@@ -177,20 +169,7 @@ echo $this->element('form_table',
|
|||||||
'id' => "LeaseMoveDate"),
|
'id' => "LeaseMoveDate"),
|
||||||
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'LeaseMoveDate\', false); return false;">Now</A>',
|
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'LeaseMoveDate\', false); return false;">Now</A>',
|
||||||
),
|
),
|
||||||
) +
|
"comment" =>
|
||||||
($move_type === 'in' ? array
|
|
||||||
("deposit" =>
|
|
||||||
array('opts' => array
|
|
||||||
('value' => (!empty($unit)
|
|
||||||
? FormatHelper::currency($unit['deposit'])
|
|
||||||
: null))),
|
|
||||||
"rent" =>
|
|
||||||
array('opts' => array
|
|
||||||
('value' => (!empty($unit)
|
|
||||||
? FormatHelper::currency($unit['rent'])
|
|
||||||
: null))),
|
|
||||||
) : array()) + array
|
|
||||||
("comment" =>
|
|
||||||
($move_type !== 'out'
|
($move_type !== 'out'
|
||||||
? array('opts' => array('size' => 50))
|
? array('opts' => array('size' => 50))
|
||||||
: null),
|
: null),
|
||||||
|
|||||||
74
site/views/leases/refund.ctp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php /* -*- mode:PHP -*- */
|
||||||
|
|
||||||
|
echo '<div class="account deposit">' . "\n";
|
||||||
|
echo '<H2>Perform Bank Deposit</H2>' . "\n";
|
||||||
|
echo '<P>Make sure to select the checkboxes below for only those types of currency (Cash, Check, etc) which you intend to actually deposit (you can see all the individual items by dropping down the list below the checkbox). Then, select the Deposit Account where you will make the deposit, and click "Perform Deposit" to close the books on the selected currency types and reset them to a zero balance. On the next page, you will be provided with a deposit slip to prepare the actual deposit.' . "\n";
|
||||||
|
echo '<P><BR>' . "\n";
|
||||||
|
|
||||||
|
//pr(compact('tillableAccount', 'depositableAccount'));
|
||||||
|
|
||||||
|
echo $form->create(null, array('id' => 'deposit-form',
|
||||||
|
'url' => array('controller' => 'accounts',
|
||||||
|
'action' => 'deposit')));
|
||||||
|
|
||||||
|
foreach ($tillableAccount AS $acct) {
|
||||||
|
//$acct = $acct['Account'];
|
||||||
|
|
||||||
|
echo "\n";
|
||||||
|
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.checked',
|
||||||
|
array(//'label' => $acct['Account']['name'],
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checked' => true,
|
||||||
|
'value' => true,
|
||||||
|
'label' => (" I have exactly " .
|
||||||
|
FormatHelper::currency($acct['Account']['stats']['Ledger']['balance']) .
|
||||||
|
" in " . ($acct['Account']['name'] === 'Cash'
|
||||||
|
? 'Cash'
|
||||||
|
: Inflector::pluralize($acct['Account']['name'])) .
|
||||||
|
" and will be depositing it all.")
|
||||||
|
));
|
||||||
|
echo "\n";
|
||||||
|
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.amount',
|
||||||
|
array('type' => 'hidden',
|
||||||
|
'value' => $acct['Account']['stats']['Ledger']['balance'],
|
||||||
|
));
|
||||||
|
echo "\n";
|
||||||
|
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.account_id',
|
||||||
|
array('type' => 'hidden',
|
||||||
|
'value' => $acct['Account']['id'],
|
||||||
|
));
|
||||||
|
echo "\n";
|
||||||
|
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.account_name',
|
||||||
|
array('type' => 'hidden',
|
||||||
|
'value' => $acct['Account']['name'],
|
||||||
|
));
|
||||||
|
echo "\n";
|
||||||
|
|
||||||
|
$grid_div_id = 'ledger_entries'.$acct['CurrentLedger']['id'].'-list';
|
||||||
|
echo $this->element('ledger_entries', array
|
||||||
|
(// Element configuration
|
||||||
|
'ledger_id' => $acct['CurrentLedger']['id'],
|
||||||
|
'no_account' => true,
|
||||||
|
|
||||||
|
// Grid configuration
|
||||||
|
'config' => array
|
||||||
|
(
|
||||||
|
'grid_div_id' => $grid_div_id,
|
||||||
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#'.$grid_div_id.' .HeaderButton\').click();'.
|
||||||
|
' return false;">Items in '.$acct['Account']['name'].' Ledger</A>'),
|
||||||
|
'grid_setup' => array('hiddengrid' => true),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = array();
|
||||||
|
foreach ($depositableAccount AS $acct) {
|
||||||
|
$options[$acct['Account']['id']] = $acct['Account']['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $form->input('Deposit.Account.id', array('label' => 'Deposit Account ',
|
||||||
|
'options' => $options));
|
||||||
|
echo $form->end('Perform Deposit');
|
||||||
|
|
||||||
|
/* End page div */
|
||||||
|
echo '</div>' . "\n";
|
||||||
@@ -57,7 +57,7 @@ echo $this->element('table',
|
|||||||
echo '<div class="infobox">' . "\n";
|
echo '<div class="infobox">' . "\n";
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array('Security Deposit:', FormatHelper::currency($outstandingDeposit));
|
$rows[] = array('Security Deposit:', FormatHelper::currency($outstandingDeposit));
|
||||||
$rows[] = array('Balance Owed:', FormatHelper::currency($outstandingBalance));
|
$rows[] = array('Balance:', FormatHelper::currency($outstandingBalance));
|
||||||
echo $this->element('table',
|
echo $this->element('table',
|
||||||
array('class' => 'summary',
|
array('class' => 'summary',
|
||||||
'rows' => $rows,
|
'rows' => $rows,
|
||||||
@@ -84,31 +84,10 @@ echo '<div CLASS="detail supporting">' . "\n";
|
|||||||
echo $this->element('statement_entries', array
|
echo $this->element('statement_entries', array
|
||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
('caption' => 'Lease Statement',
|
('caption' => 'Account',
|
||||||
'filter' => array('Lease.id' => $lease['id']),
|
'filter' => array('Lease.id' => $lease['id']),
|
||||||
'include' => array('Through'),
|
'include' => array('Through'),
|
||||||
'exclude' => array('Customer', 'Lease', 'Unit'),
|
'exclude' => array('Customer', 'Lease', 'Unit'),
|
||||||
'sort_column' => 'Effective',
|
|
||||||
'sort_order' => 'DESC',
|
|
||||||
)));
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* Receipt History
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo $this->element('ledger_entries', array
|
|
||||||
(// Grid configuration
|
|
||||||
'config' => array
|
|
||||||
('caption' => 'Customer Receipts',
|
|
||||||
'filter' => array('Customer.id' => $customer['id'],
|
|
||||||
'Transaction.type' => 'RECEIPT',
|
|
||||||
'Tender.id !=' => null,
|
|
||||||
//'Account.id !=' => '-AR-'
|
|
||||||
),
|
|
||||||
'exclude' => array('Account', 'Cr/Dr'),
|
|
||||||
'sort_column' => 'Date',
|
|
||||||
'sort_order' => 'DESC',
|
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ echo $this->element('ledger_entries', array
|
|||||||
'filter' => array('Ledger.id' => $ledger['id']),
|
'filter' => array('Ledger.id' => $ledger['id']),
|
||||||
'exclude' => array('Ledger', 'Account',
|
'exclude' => array('Ledger', 'Account',
|
||||||
'Amount', 'Cr/Dr', 'Balance',
|
'Amount', 'Cr/Dr', 'Balance',
|
||||||
empty($account['receipts']) ? 'Tender' : null),
|
empty($account['payments']) ? 'Tender' : null),
|
||||||
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
'include' => array('Debit', 'Credit', 'Sub-Total'),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|||||||
@@ -10,23 +10,20 @@ echo '<div class="statement-entry view">' . "\n";
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$transaction = $entry['Transaction'];
|
$transaction = $entry['Transaction'];
|
||||||
$account = $entry['Account'];
|
$account = $entry['LedgerEntry'][0]['Account'];
|
||||||
$customer = $entry['Customer'];
|
$customer = $entry['Customer'];
|
||||||
$lease = $entry['Lease'];
|
$lease = $entry['Lease'];
|
||||||
$entry = $entry['StatementEntry'];
|
$entry = $entry['StatementEntry'];
|
||||||
|
|
||||||
$Ttype = ucfirst(strtolower($transaction['type']));
|
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array('ID', $entry['id']);
|
$rows[] = array('ID', $entry['id']);
|
||||||
$rows[] = array($Ttype, $html->link('#'.$transaction['id'],
|
$rows[] = array('Transaction', $html->link('#'.$transaction['id'],
|
||||||
array('controller' => 'transactions',
|
array('controller' => 'transactions',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
$transaction['id'])));
|
$transaction['id'])));
|
||||||
$rows[] = array('Timestamp', FormatHelper::datetime($transaction['stamp']));
|
$rows[] = array('Timestamp', FormatHelper::datetime($transaction['stamp']));
|
||||||
$rows[] = array('Effective', FormatHelper::date($entry['effective_date']));
|
$rows[] = array('Effective', FormatHelper::date($entry['effective_date']));
|
||||||
if (in_array($entry['type'], array('CHARGE', 'PAYMENT')))
|
$rows[] = array('Through', FormatHelper::date($entry['through_date']));
|
||||||
$rows[] = array('Through', FormatHelper::date($entry['through_date']));
|
|
||||||
$rows[] = array('Type', $entry['type']);
|
$rows[] = array('Type', $entry['type']);
|
||||||
$rows[] = array('Amount', FormatHelper::currency($entry['amount']));
|
$rows[] = array('Amount', FormatHelper::currency($entry['amount']));
|
||||||
$rows[] = array('Account', $html->link($account['name'],
|
$rows[] = array('Account', $html->link($account['name'],
|
||||||
@@ -59,12 +56,12 @@ echo $this->element('table',
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (strtoupper($entry['type']) === 'CHARGE') {
|
if (strtoupper($entry['type']) === 'CHARGE') {
|
||||||
$applied_caption = "Disbursements Applied";
|
$applied_caption = "Payments Applied";
|
||||||
//$remaining_caption = "Charge Balance";
|
//$remaining_caption = "Charge Balance";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$applied_caption = "Disbursed to Charges";
|
$applied_caption = "Applied to Charges";
|
||||||
//$remaining_caption = "Disbursement Balance";
|
//$remaining_caption = "Payment Balance";
|
||||||
}
|
}
|
||||||
|
|
||||||
$remaining_caption = "Remaining Balance";
|
$remaining_caption = "Remaining Balance";
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
<?php /* -*- mode:PHP -*- */
|
|
||||||
|
|
||||||
echo '<div class="tender edit">' . "\n";
|
|
||||||
|
|
||||||
?>
|
|
||||||
<script type="text/javascript"><!--
|
|
||||||
function switchTenderType(base, radioid) {
|
|
||||||
var type_id = $("#"+radioid).val();
|
|
||||||
if (!$("#"+base+"-"+type_id).is(':visible')) {
|
|
||||||
$("."+base).slideUp();
|
|
||||||
$("#"+base+"-"+type_id).slideDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$(document).ready(function(){
|
|
||||||
switchTenderType("tender-type-div", "TenderTenderTypeId");
|
|
||||||
});
|
|
||||||
|
|
||||||
--></script>
|
|
||||||
<?php
|
|
||||||
; // align
|
|
||||||
|
|
||||||
echo $form->create('Tender', array('action' => 'edit')) . "\n";
|
|
||||||
echo $form->input('id') . "\n";
|
|
||||||
|
|
||||||
if (empty($this->data['Tender']))
|
|
||||||
INTERNAL_ERROR('Creation of new Tender not allowed.');
|
|
||||||
|
|
||||||
echo $form->input('tender_type_id',
|
|
||||||
array('div' => 'tender',
|
|
||||||
// REVISIT <AP>: 20090810
|
|
||||||
// We're not ready to allow changing the type
|
|
||||||
// of a tender, since it will force us to deal
|
|
||||||
// with changing the LedgerEntry account (easy)
|
|
||||||
// and the associated StatementEntry accounts
|
|
||||||
// (not too hard), and make sure the tender has
|
|
||||||
// not been deposited (easy), and then deal with
|
|
||||||
// any corner cases that pop up.
|
|
||||||
'disabled' => true,
|
|
||||||
'onclick' => ('switchTenderType(' .
|
|
||||||
'"tender-type-div", ' .
|
|
||||||
'$(this).attr("id")' .
|
|
||||||
')'),
|
|
||||||
)) . "\n";
|
|
||||||
|
|
||||||
$form->input('comment');
|
|
||||||
foreach ($types AS $type) {
|
|
||||||
$type = $type['TenderType'];
|
|
||||||
echo('<DIV' .
|
|
||||||
' ID="tender-type-div-'.$type['id'].'"' .
|
|
||||||
' CLASS="tender-type-div"' .
|
|
||||||
($type['id'] != $this->data['TenderType']['id']
|
|
||||||
? ' STYLE="display:none;"' : '') .
|
|
||||||
'>' . "\n");
|
|
||||||
|
|
||||||
echo ('<INPUT TYPE="hidden"' .
|
|
||||||
' NAME="data[type]['.$type['id'].'][tender_type_id]"' .
|
|
||||||
' VALUE="'.$type['id'].'"' .
|
|
||||||
'>' . "\n");
|
|
||||||
|
|
||||||
for ($i=1; $i<=4; ++$i) {
|
|
||||||
if (!empty($type["data{$i}_name"])) {
|
|
||||||
echo ("<!-- data{$i}_name -->\n");
|
|
||||||
echo $form->input("type.{$type['id']}.data$i",
|
|
||||||
array('label' => $type["data{$i}_name"],
|
|
||||||
'div' => 'input text tender',
|
|
||||||
'value' =>
|
|
||||||
($type['id'] == $this->data['TenderType']['id']
|
|
||||||
? $this->data['Tender']["data$i"] : null),
|
|
||||||
)) . "\n";
|
|
||||||
|
|
||||||
/* echo ('<DIV CLASS="input text required">' . */
|
|
||||||
/* ' <INPUT TYPE="text" SIZE="20"' . */
|
|
||||||
/* ' NAME="data[type]['.$type['id'].'][data'.$i.']"' . */
|
|
||||||
/* ' CLASS="tender"' . */
|
|
||||||
/* ' ID= */
|
|
||||||
/* '<LABEL' . */
|
|
||||||
/* ' CLASS="tender"' . */
|
|
||||||
/* ' FOR="tender-data'.$i.'">' . */
|
|
||||||
/* $type["data{$i}_name"] . */
|
|
||||||
/* '</LABEL>' . "\n" . */
|
|
||||||
/* '</DIV>' . "\n"); */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo('</DIV>' . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
echo $form->submit('Update') . "\n";
|
|
||||||
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
|
||||||
echo $form->end() . "\n";
|
|
||||||
echo '</div>' . "\n";
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
<?php /* -*- mode:PHP -*- */
|
|
||||||
|
|
||||||
echo '<div class="nsf input">' . "\n";
|
|
||||||
|
|
||||||
$customer = $tender['Customer'];
|
|
||||||
$entry = $tender['LedgerEntry'];
|
|
||||||
$transaction = $entry['Transaction'];
|
|
||||||
|
|
||||||
if (isset($tender['Tender']))
|
|
||||||
$tender = $tender['Tender'];
|
|
||||||
|
|
||||||
// We're not actually using a grid to select the customer,
|
|
||||||
// but selection-text makes for reasonable formatting
|
|
||||||
echo ('<DIV CLASS="nsf grid-selection-text">' .
|
|
||||||
'<TABLE>' . "\n");
|
|
||||||
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">' . $customer['name'] . '</TD>' .
|
|
||||||
' <TD>' . '(Customer #' . $customer['id'] . ')' . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">' . $tender['name'] . '</TD>' .
|
|
||||||
' <TD>' . '(Tender #' . $tender['id'] . ')' . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">Amount:</TD>' .
|
|
||||||
' <TD>' . FormatHelper::currency($entry['amount']) . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
echo ('</TABLE>' .
|
|
||||||
'</DIV>' . "\n");
|
|
||||||
|
|
||||||
|
|
||||||
echo $form->create(null, array('id' => 'nsf-form',
|
|
||||||
'url' => array('action' => 'nsf'))) . "\n";
|
|
||||||
|
|
||||||
echo $form->input("Tender.id",
|
|
||||||
array('type' => 'hidden',
|
|
||||||
'value' => $tender['id'])) . "\n";
|
|
||||||
|
|
||||||
echo $this->element('form_table',
|
|
||||||
array('class' => "item receipt transaction entry",
|
|
||||||
//'with_name_after' => ':',
|
|
||||||
'field_prefix' => 'Transaction',
|
|
||||||
'fields' => array
|
|
||||||
("stamp" => array('opts' => array('type' => 'text'),
|
|
||||||
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
|
|
||||||
),
|
|
||||||
"comment" => array('opts' => array('size' => 50),
|
|
||||||
),
|
|
||||||
))) . "\n";
|
|
||||||
|
|
||||||
echo $form->end('Record Item as NSF');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
|
||||||
|
|
||||||
// Reset the form
|
|
||||||
function resetForm() {
|
|
||||||
datepickerNow('TransactionStamp');
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
$("#TransactionStamp")
|
|
||||||
.attr('autocomplete', 'off')
|
|
||||||
.datepicker({ constrainInput: true,
|
|
||||||
numberOfMonths: [1, 1],
|
|
||||||
showCurrentAtPos: 0,
|
|
||||||
dateFormat: 'mm/dd/yy' });
|
|
||||||
|
|
||||||
resetForm();
|
|
||||||
});
|
|
||||||
--></script>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
<?php /* -*- mode:PHP -*- */
|
|
||||||
|
|
||||||
echo '<div class="bad-debt input">' . "\n";
|
|
||||||
|
|
||||||
if (isset($lease)) {
|
|
||||||
$customer = $lease['Customer'];
|
|
||||||
$unit = $lease['Unit'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($customer['Customer']))
|
|
||||||
$customer = $customer['Customer'];
|
|
||||||
|
|
||||||
if (isset($lease['Lease']))
|
|
||||||
$lease = $lease['Lease'];
|
|
||||||
|
|
||||||
// We're not actually using a grid to select the customer / lease
|
|
||||||
// but we could/should be, and the result would be selection-text
|
|
||||||
echo ('<DIV CLASS="bad-debt grid-selection-text">' .
|
|
||||||
'<TABLE>' . "\n");
|
|
||||||
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">' . $customer['name'] . '</TD>' .
|
|
||||||
' <TD>' . '(Customer #' . $customer['id'] . ')' . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
if (isset($lease))
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">' . 'Unit ' . $unit['name'] . '</TD>' .
|
|
||||||
' <TD>' . '(Lease #' . $lease['number'] . ')' . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">Remaining Balance:</TD>' .
|
|
||||||
' <TD>' . FormatHelper::currency($balance) . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
echo ('</TABLE>' .
|
|
||||||
'</DIV>' . "\n");
|
|
||||||
|
|
||||||
|
|
||||||
echo $form->create(null, array('id' => 'receipt-form',
|
|
||||||
'url' => array('controller' => 'transactions',
|
|
||||||
'action' => 'postWriteOff'))) . "\n";
|
|
||||||
|
|
||||||
echo $form->input("Customer.id",
|
|
||||||
array('type' => 'hidden',
|
|
||||||
'value' => $customer['id'])) . "\n";
|
|
||||||
|
|
||||||
if (isset($lease['id']))
|
|
||||||
echo $form->input("Lease.id",
|
|
||||||
array('type' => 'hidden',
|
|
||||||
'value' => $lease['id'])) . "\n";
|
|
||||||
|
|
||||||
echo $form->input("Entry.0.amount",
|
|
||||||
array('type' => 'hidden',
|
|
||||||
'value' => $balance)) . "\n";
|
|
||||||
|
|
||||||
echo $this->element('form_table',
|
|
||||||
array('class' => "item receipt transaction entry",
|
|
||||||
//'with_name_after' => ':',
|
|
||||||
'field_prefix' => 'Transaction',
|
|
||||||
'fields' => array
|
|
||||||
("stamp" => array('opts' => array('type' => 'text'),
|
|
||||||
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
|
|
||||||
),
|
|
||||||
"comment" => array('opts' => array('size' => 50),
|
|
||||||
),
|
|
||||||
))) . "\n";
|
|
||||||
|
|
||||||
echo $form->end('Write Off Remaining Balance');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
|
||||||
|
|
||||||
// Reset the form
|
|
||||||
function resetForm() {
|
|
||||||
datepickerNow('TransactionStamp');
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
$("#TransactionStamp")
|
|
||||||
.attr('autocomplete', 'off')
|
|
||||||
.datepicker({ constrainInput: true,
|
|
||||||
numberOfMonths: [1, 1],
|
|
||||||
showCurrentAtPos: 0,
|
|
||||||
dateFormat: 'mm/dd/yy' });
|
|
||||||
|
|
||||||
resetForm();
|
|
||||||
});
|
|
||||||
--></script>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
<?php /* -*- mode:PHP -*- */
|
|
||||||
|
|
||||||
echo '<div class="refund input">' . "\n";
|
|
||||||
echo '<H2>Issue Refund</H2>' . "\n";
|
|
||||||
echo '<P>Enter the amount to refund, and the account to pay it from.' . "\n";
|
|
||||||
echo '<P><BR>' . "\n";
|
|
||||||
|
|
||||||
if (isset($lease)) {
|
|
||||||
$customer = $lease['Customer'];
|
|
||||||
$unit = $lease['Unit'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($customer['Customer']))
|
|
||||||
$customer = $customer['Customer'];
|
|
||||||
|
|
||||||
if (isset($lease['Lease']))
|
|
||||||
$lease = $lease['Lease'];
|
|
||||||
|
|
||||||
// We're not actually using a grid to select the customer / lease
|
|
||||||
// but we could/should be, and the result would be selection-text
|
|
||||||
echo ('<DIV CLASS="refund grid-selection-text">' .
|
|
||||||
'<TABLE>' . "\n");
|
|
||||||
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">' . $customer['name'] . '</TD>' .
|
|
||||||
' <TD>' . '(Customer #' . $customer['id'] . ')' . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
if (isset($lease))
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">' . 'Unit ' . $unit['name'] . '</TD>' .
|
|
||||||
' <TD>' . '(Lease #' . $lease['number'] . ')' . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
echo ('<TR><TD style="padding-right: 1em;">Refundable Balance:</TD>' .
|
|
||||||
' <TD>' . FormatHelper::currency($balance) . '</TD>' .
|
|
||||||
'</TR>' . "\n");
|
|
||||||
|
|
||||||
echo ('</TABLE>' .
|
|
||||||
'</DIV>' . "\n");
|
|
||||||
|
|
||||||
|
|
||||||
echo $form->create(null, array('id' => 'refund-form',
|
|
||||||
'url' => array('controller' => 'transactions',
|
|
||||||
'action' => 'postRefund')));
|
|
||||||
|
|
||||||
|
|
||||||
// REVISIT <AP>: 20090805
|
|
||||||
// Add Tender information to log specifically _how_ refund was paid.
|
|
||||||
|
|
||||||
echo $this->element('form_table',
|
|
||||||
array('class' => "item refund transaction entry",
|
|
||||||
//'with_name_after' => ':',
|
|
||||||
'field_prefix' => 'Transaction',
|
|
||||||
'fields' => array
|
|
||||||
("stamp" => array('opts' =>
|
|
||||||
array('type' => 'text'),
|
|
||||||
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
|
|
||||||
),
|
|
||||||
"amount" => array('prefix' => 'Entry.0',
|
|
||||||
'opts' =>
|
|
||||||
array('value' =>
|
|
||||||
FormatHelper::currency($balance, false, ''),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
"account_id" => array('prefix' => 'Entry.0',
|
|
||||||
'name' => 'Account',
|
|
||||||
'opts' =>
|
|
||||||
array('options' => $refundAccounts,
|
|
||||||
'value' => $defaultAccount,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
"comment" => array('opts' => array('size' => 50),
|
|
||||||
),
|
|
||||||
))) . "\n";
|
|
||||||
|
|
||||||
echo $form->input("Customer.id",
|
|
||||||
array('type' => 'hidden',
|
|
||||||
'value' => $customer['id'])) . "\n";
|
|
||||||
|
|
||||||
if (isset($lease['id']))
|
|
||||||
echo $form->input("Lease.id",
|
|
||||||
array('type' => 'hidden',
|
|
||||||
'value' => $lease['id'])) . "\n";
|
|
||||||
|
|
||||||
echo $form->end('Issue Refund');
|
|
||||||
?>
|
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
|
||||||
|
|
||||||
// Reset the form
|
|
||||||
function resetForm() {
|
|
||||||
datepickerNow('TransactionStamp');
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
$("#TransactionStamp")
|
|
||||||
.attr('autocomplete', 'off')
|
|
||||||
.datepicker({ constrainInput: true,
|
|
||||||
numberOfMonths: [1, 1],
|
|
||||||
showCurrentAtPos: 0,
|
|
||||||
dateFormat: 'mm/dd/yy' });
|
|
||||||
|
|
||||||
resetForm();
|
|
||||||
});
|
|
||||||
--></script>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
@@ -67,11 +67,7 @@ echo '<div CLASS="detail supporting">' . "\n";
|
|||||||
* Statement Entries
|
* Statement Entries
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($transaction['type'] === 'INVOICE' ||
|
if ($transaction['type'] === 'INVOICE' || $transaction['type'] === 'RECEIPT') {
|
||||||
$transaction['type'] === 'RECEIPT' ||
|
|
||||||
$transaction['type'] === 'CREDIT_NOTE' ||
|
|
||||||
$transaction['type'] === 'PAYMENT'
|
|
||||||
) {
|
|
||||||
echo $this->element('statement_entries', array
|
echo $this->element('statement_entries', array
|
||||||
(// Grid configuration
|
(// Grid configuration
|
||||||
'config' => array
|
'config' => array
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php /* -*- mode:PHP -*- */
|
|
||||||
|
|
||||||
echo '<div class="unit edit">' . "\n";
|
|
||||||
|
|
||||||
echo $form->create('Unit', array('action' => 'edit')) . "\n";
|
|
||||||
echo $form->input('id') . "\n";
|
|
||||||
|
|
||||||
echo($this->element
|
|
||||||
('form_table',
|
|
||||||
array('class' => 'item unit detail',
|
|
||||||
'caption' => isset($this->data['Unit']) ? 'Edit Unit' : 'New Unit',
|
|
||||||
'fields' => array
|
|
||||||
('name' => true,
|
|
||||||
'unit_size_id' => true,
|
|
||||||
'status' => array('opts' =>
|
|
||||||
array('options' => $statusEnums,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
'deposit' => true,
|
|
||||||
'rent' => true,
|
|
||||||
'comment' => true,
|
|
||||||
))) . "\n");
|
|
||||||
|
|
||||||
echo $form->submit('Update') . "\n";
|
|
||||||
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
|
||||||
echo $form->end() . "\n";
|
|
||||||
echo '</div>' . "\n";
|
|
||||||
447
site/webroot/css/jqGrid/basic/grid.css
Normal file
@@ -0,0 +1,447 @@
|
|||||||
|
.GridHeader {
|
||||||
|
}
|
||||||
|
.Header {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Header th {
|
||||||
|
font-size: 100%; font-weight: bold; text-align: left;
|
||||||
|
padding: 2px;
|
||||||
|
background-image: url(images/headerbg.gif) ;
|
||||||
|
color: #FFFFFF;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderLeft {
|
||||||
|
background-image: url(images/headerleft.gif);
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderRight {
|
||||||
|
background-image: url(images/headerright.gif);
|
||||||
|
}
|
||||||
|
.HeaderButton {
|
||||||
|
background-image: url(images/headerbg.gif);
|
||||||
|
}
|
||||||
|
.HeaderButton img{
|
||||||
|
width: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderLeft img{
|
||||||
|
width: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderRight img{
|
||||||
|
width: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.GridHeader table {margin:0;}
|
||||||
|
.GridHeader td, tr {padding:0;}
|
||||||
|
/* Grid */
|
||||||
|
table.scroll {
|
||||||
|
table-layout: fixed;
|
||||||
|
/*border-right: 1px solid #D4D0C8;*/
|
||||||
|
margin-bottom:0;
|
||||||
|
}
|
||||||
|
table.scroll tbody tr {
|
||||||
|
background-color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll tbody tr.alt {
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll tr.over td{
|
||||||
|
background-color: #E1DCF4;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll tr.selected td {
|
||||||
|
background: #3d84cc;
|
||||||
|
color: White;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll tbody td {
|
||||||
|
padding: 2px;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #D4D0C8;
|
||||||
|
border-left: 1px solid #D4D0C8;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
height : auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll thead th {
|
||||||
|
padding: 2px;
|
||||||
|
border-bottom: 1px solid #CBC7B8;
|
||||||
|
border-left: 1px solid #D4D0C8;
|
||||||
|
text-align: left;
|
||||||
|
font-weight: normal;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
background-image: url(images/grid-blue-hd.gif);
|
||||||
|
height : 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll th div {
|
||||||
|
overflow: hidden;
|
||||||
|
/* white-space: nowrap;*/
|
||||||
|
word-wrap: break-word;
|
||||||
|
height : 17px;
|
||||||
|
}
|
||||||
|
table.scroll th span {
|
||||||
|
cursor: e-resize;
|
||||||
|
/* border-right: 1px solid #D6D2C2; */
|
||||||
|
width: 10px;
|
||||||
|
float: right;
|
||||||
|
display: block;
|
||||||
|
margin: -2px -1px -2px 0px;
|
||||||
|
height: 17px;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End Grid */
|
||||||
|
|
||||||
|
/* Pager */
|
||||||
|
div.scroll {
|
||||||
|
vertical-align: top;
|
||||||
|
height: 23px;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
background-image: url(images/grid-blue-ft.gif);
|
||||||
|
}
|
||||||
|
div.scroll span {
|
||||||
|
vertical-align : top;
|
||||||
|
}
|
||||||
|
.selbox {
|
||||||
|
font-size: x-small;
|
||||||
|
vertical-align : top;
|
||||||
|
}
|
||||||
|
input.selbox{
|
||||||
|
font-size: x-small;
|
||||||
|
vertical-align : top;
|
||||||
|
}
|
||||||
|
.pgbuttons {
|
||||||
|
margin-top :2px;
|
||||||
|
}
|
||||||
|
.nav-table-left {
|
||||||
|
padding:1px;
|
||||||
|
float: left;
|
||||||
|
/* position:absolute;*/
|
||||||
|
}
|
||||||
|
.nav-table-right {
|
||||||
|
padding:1px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.navtable {margin-bottom:0; width: auto;}
|
||||||
|
table.navtable tr{
|
||||||
|
background-image: url(images/grid-blue-ft.gif);
|
||||||
|
}
|
||||||
|
|
||||||
|
table.navtable td.nav-button {
|
||||||
|
border: 1px solid #E2ECF8;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.navtable td.nav-hover {
|
||||||
|
border: 1px solid #83B4D8;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.tbutton tr td{
|
||||||
|
border : none;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img.jsHover { /*not used */
|
||||||
|
border: 1px solid #99CCFF;
|
||||||
|
}
|
||||||
|
/* End Pager */
|
||||||
|
/*multiselect checkbox */
|
||||||
|
.cbox {
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
/*border:1px solid #999;*/
|
||||||
|
}
|
||||||
|
/* end multiselect */
|
||||||
|
|
||||||
|
|
||||||
|
/* loading div */
|
||||||
|
div.loading {
|
||||||
|
position: absolute;
|
||||||
|
padding: 3px;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
background: red;
|
||||||
|
color: white;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.loadingui {
|
||||||
|
display:none;
|
||||||
|
z-index:6000;
|
||||||
|
position:absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
div.loadingui div.msgbox {
|
||||||
|
position: relative;
|
||||||
|
z-index:6001;
|
||||||
|
left: 35%;
|
||||||
|
top:45%;
|
||||||
|
background: url(images/loading.gif) no-repeat left;
|
||||||
|
width: 100px;
|
||||||
|
border: 2px solid #B2D2FF;
|
||||||
|
text-align: right;
|
||||||
|
height: auto;
|
||||||
|
padding:2px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
/* end loading div */
|
||||||
|
/* toolbar */
|
||||||
|
div.userdata {
|
||||||
|
margin-top: 0px;
|
||||||
|
background-color : #EAF9F9;
|
||||||
|
height : 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
/* end toolbar */
|
||||||
|
/*Subgrid text mode*/
|
||||||
|
.subgrid {
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
.tablediv {
|
||||||
|
background-color: White;
|
||||||
|
border-spacing: 1px; /*cellspacing:poor IE support for this*/
|
||||||
|
border-collapse: separate;
|
||||||
|
width:100%; /* FF hack poor when scroling subgrid */
|
||||||
|
}
|
||||||
|
.celldiv {
|
||||||
|
float: left;
|
||||||
|
display: table-cell;
|
||||||
|
border: 1px dotted #CCCCCC;
|
||||||
|
overflow: auto;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
.celldivth {
|
||||||
|
float: left; /*fix for buggy browsers*/
|
||||||
|
border: 1px solid #CCCCCC;
|
||||||
|
background-color: #99CCFF;
|
||||||
|
border-bottom: 1px solid #CBC7B8;
|
||||||
|
text-align: left;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
.rowdiv {
|
||||||
|
display: table-row;
|
||||||
|
background: #F9F9F9 none;
|
||||||
|
color: #000000;
|
||||||
|
width: 100%;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
/* End Subgrid */
|
||||||
|
|
||||||
|
/* InLine editing */
|
||||||
|
input.editable[type="text"] {
|
||||||
|
font-size: x-small;
|
||||||
|
overflow: hidden;
|
||||||
|
height : 15px;
|
||||||
|
}
|
||||||
|
input.editable[type="checkbox"] {
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea.editable {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.editable {
|
||||||
|
font-size: x-small;
|
||||||
|
}
|
||||||
|
/* End Inline Editing */
|
||||||
|
|
||||||
|
/*Modal Window */
|
||||||
|
.modaltext{
|
||||||
|
text-align : left;
|
||||||
|
}
|
||||||
|
.modalwin{
|
||||||
|
border:1px solid #555555;
|
||||||
|
background:#F9F9F9;
|
||||||
|
text-align:left;
|
||||||
|
margin: 0 auto;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.modalhead {
|
||||||
|
background-image: url(images/grid-blue-hd.gif);
|
||||||
|
height: 20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.modalcontent {
|
||||||
|
overflow: auto;
|
||||||
|
margin-bottom: 9px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
/* end Modal window*/
|
||||||
|
/* Search window */
|
||||||
|
input.search {
|
||||||
|
margin: 2px;
|
||||||
|
width: 70px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.search {
|
||||||
|
margin: 2px;
|
||||||
|
width: 70px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
.buttonsearch {
|
||||||
|
width : 50px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
/*End search */
|
||||||
|
|
||||||
|
/* Form edit */
|
||||||
|
|
||||||
|
.FormGrid {
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
.EditTable {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.FormData { /* tr */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#FormError td {
|
||||||
|
font-size: 90%;
|
||||||
|
color: #FF0000;
|
||||||
|
vertical-align: top;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CaptionTD{ /* td */
|
||||||
|
font-weight: normal; text-align: left; vertical-align: top;
|
||||||
|
padding: 1px;
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
white-space: nowrap;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
.DataTD { /* td */
|
||||||
|
padding: 1px;
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
.navButton{
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
border-bottom: 1px solid #D4D0C8;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.navButton input{
|
||||||
|
width:17px;
|
||||||
|
}
|
||||||
|
input.EditButton { /* buttons are at footer tr */
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
td.EditButton {
|
||||||
|
text-align: right;
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
border-bottom: 1px solid #D4D0C8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.FormElement { /* form element - input -text,textarea,checkbox - select */
|
||||||
|
|
||||||
|
}
|
||||||
|
.FormElement {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
input[type="text"].FormElement{
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
input[type="checkbox"].FormElement{
|
||||||
|
width: 15px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
input[type="textarea"].FormElement{
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
select.FormElement {
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
/* End Eorm edit */
|
||||||
|
|
||||||
|
/* Delete Dialog */
|
||||||
|
.DelButton > input { /* buttons are at footer tr */
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
.DelButton {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
/* End Delete Dialog */
|
||||||
|
|
||||||
|
img.jqResize {
|
||||||
|
position:absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
right: 0px;
|
||||||
|
cursor :se-resize;
|
||||||
|
}
|
||||||
|
.dirty-cell {
|
||||||
|
background: transparent url(images/dirty.gif) no-repeat 0 0;
|
||||||
|
}
|
||||||
|
#DelError td {
|
||||||
|
font-size: 90%;
|
||||||
|
color: #FF0000;
|
||||||
|
vertical-align: top;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
}
|
||||||
|
/* Tree Grid */
|
||||||
|
.tree-wrap
|
||||||
|
{
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
height: 18px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.tree-minus
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
height: 18px;
|
||||||
|
width: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: url(images/tree_minus.gif) no-repeat;
|
||||||
|
}
|
||||||
|
.tree-plus
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
height: 18px;
|
||||||
|
width: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: url(images/tree_plus.gif) no-repeat;
|
||||||
|
}
|
||||||
|
.tree-leaf
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
height: 18px;
|
||||||
|
width: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: url(images/tree_leaf.gif) no-repeat;
|
||||||
|
}
|
||||||
|
.treeclick
|
||||||
|
{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.edit-cell {
|
||||||
|
background-color: #E1DCF4 !important;
|
||||||
|
}
|
||||||
|
.selected-row, .selected-row TD {
|
||||||
|
background-color: #3d84cc;
|
||||||
|
}
|
||||||
BIN
site/webroot/css/jqGrid/basic/images/cd_run.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
site/webroot/css/jqGrid/basic/images/dirty.gif
Normal file
|
After Width: | Height: | Size: 832 B |
BIN
site/webroot/css/jqGrid/basic/images/down.gif
Normal file
|
After Width: | Height: | Size: 309 B |
BIN
site/webroot/css/jqGrid/basic/images/find.gif
Normal file
|
After Width: | Height: | Size: 986 B |
BIN
site/webroot/css/jqGrid/basic/images/first.gif
Normal file
|
After Width: | Height: | Size: 925 B |
BIN
site/webroot/css/jqGrid/basic/images/folder.png
Normal file
|
After Width: | Height: | Size: 229 B |
BIN
site/webroot/css/jqGrid/basic/images/grid-blue-ft.gif
Normal file
|
After Width: | Height: | Size: 821 B |
BIN
site/webroot/css/jqGrid/basic/images/grid-blue-hd.gif
Normal file
|
After Width: | Height: | Size: 821 B |
BIN
site/webroot/css/jqGrid/basic/images/headerbg.gif
Normal file
|
After Width: | Height: | Size: 87 B |
BIN
site/webroot/css/jqGrid/basic/images/headerleft.gif
Normal file
|
After Width: | Height: | Size: 425 B |
BIN
site/webroot/css/jqGrid/basic/images/headerright.gif
Normal file
|
After Width: | Height: | Size: 87 B |
BIN
site/webroot/css/jqGrid/basic/images/ico-close.gif
Normal file
|
After Width: | Height: | Size: 957 B |
BIN
site/webroot/css/jqGrid/basic/images/last.gif
Normal file
|
After Width: | Height: | Size: 923 B |
BIN
site/webroot/css/jqGrid/basic/images/line3.gif
Normal file
|
After Width: | Height: | Size: 70 B |
BIN
site/webroot/css/jqGrid/basic/images/loading.gif
Normal file
|
After Width: | Height: | Size: 771 B |
BIN
site/webroot/css/jqGrid/basic/images/minus.gif
Normal file
|
After Width: | Height: | Size: 85 B |
BIN
site/webroot/css/jqGrid/basic/images/next.gif
Normal file
|
After Width: | Height: | Size: 875 B |
BIN
site/webroot/css/jqGrid/basic/images/nochild.gif
Normal file
|
After Width: | Height: | Size: 66 B |
BIN
site/webroot/css/jqGrid/basic/images/off-first.gif
Normal file
|
After Width: | Height: | Size: 925 B |
BIN
site/webroot/css/jqGrid/basic/images/off-last.gif
Normal file
|
After Width: | Height: | Size: 923 B |
BIN
site/webroot/css/jqGrid/basic/images/off-next.gif
Normal file
|
After Width: | Height: | Size: 875 B |
BIN
site/webroot/css/jqGrid/basic/images/off-prev.gif
Normal file
|
After Width: | Height: | Size: 879 B |
BIN
site/webroot/css/jqGrid/basic/images/plus.gif
Normal file
|
After Width: | Height: | Size: 89 B |
BIN
site/webroot/css/jqGrid/basic/images/prev.gif
Normal file
|
After Width: | Height: | Size: 879 B |
BIN
site/webroot/css/jqGrid/basic/images/refresh.gif
Normal file
|
After Width: | Height: | Size: 581 B |
BIN
site/webroot/css/jqGrid/basic/images/resize.gif
Normal file
|
After Width: | Height: | Size: 862 B |
BIN
site/webroot/css/jqGrid/basic/images/row_add.gif
Normal file
|
After Width: | Height: | Size: 635 B |
BIN
site/webroot/css/jqGrid/basic/images/row_delete.gif
Normal file
|
After Width: | Height: | Size: 634 B |
BIN
site/webroot/css/jqGrid/basic/images/row_edit.gif
Normal file
|
After Width: | Height: | Size: 996 B |
BIN
site/webroot/css/jqGrid/basic/images/sort_asc.gif
Normal file
|
After Width: | Height: | Size: 830 B |
BIN
site/webroot/css/jqGrid/basic/images/sort_desc.gif
Normal file
|
After Width: | Height: | Size: 833 B |
BIN
site/webroot/css/jqGrid/basic/images/spacer.gif
Normal file
|
After Width: | Height: | Size: 43 B |
BIN
site/webroot/css/jqGrid/basic/images/tab_close-on.gif
Normal file
|
After Width: | Height: | Size: 351 B |
BIN
site/webroot/css/jqGrid/basic/images/tree_leaf.gif
Normal file
|
After Width: | Height: | Size: 134 B |
BIN
site/webroot/css/jqGrid/basic/images/tree_minus.gif
Normal file
|
After Width: | Height: | Size: 132 B |
BIN
site/webroot/css/jqGrid/basic/images/tree_plus.gif
Normal file
|
After Width: | Height: | Size: 138 B |
BIN
site/webroot/css/jqGrid/basic/images/up.gif
Normal file
|
After Width: | Height: | Size: 312 B |
457
site/webroot/css/jqGrid/coffee/grid.css
Normal file
@@ -0,0 +1,457 @@
|
|||||||
|
.GridHeader {
|
||||||
|
}
|
||||||
|
.Header {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Header th {
|
||||||
|
font-size: 100%; font-weight: bold; text-align: left;
|
||||||
|
padding: 2px;
|
||||||
|
background-image: url(images/headerbg.gif); color: #ffffff;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderLeft {
|
||||||
|
background-image: url(images/headerleft.gif);
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderRight {
|
||||||
|
background-image: url(images/headerright.gif);
|
||||||
|
}
|
||||||
|
.HeaderButton {
|
||||||
|
background-image: url(images/headerbg.gif);
|
||||||
|
}
|
||||||
|
.HeaderButton img{
|
||||||
|
width: 21px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderLeft img{
|
||||||
|
width: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.HeaderRight img{
|
||||||
|
width: 9px;
|
||||||
|
}
|
||||||
|
.GridHeader table {margin:0;}
|
||||||
|
.GridHeader td, tr {padding:0;}
|
||||||
|
|
||||||
|
|
||||||
|
/* Grid */
|
||||||
|
table.scroll {
|
||||||
|
border-right: 1px solid #FFFFFF;
|
||||||
|
table-layout: fixed;
|
||||||
|
margin-bottom:0;
|
||||||
|
}
|
||||||
|
table.scroll tbody tr {
|
||||||
|
background-color: #eceae3;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll tbody tr.alt{
|
||||||
|
background-color: #e3dfd1;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll tr.over td{
|
||||||
|
background-color: #D2B48C;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table.scroll tr.selected td {
|
||||||
|
background-color: #c9b9b1;
|
||||||
|
color: Black;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll tbody tr td {
|
||||||
|
font-size: 90%;
|
||||||
|
padding: 2px;
|
||||||
|
text-align: left;
|
||||||
|
border-left: 1px solid #FFFFFF;
|
||||||
|
border-bottom: 1px solid #FFFFFF;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
height : auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll thead tr th {
|
||||||
|
font-size: 90%;
|
||||||
|
font-weight: normal;
|
||||||
|
padding: 2px;
|
||||||
|
border-left: 1px solid #FFFFFF;
|
||||||
|
border-bottom: 1px solid #FFFFFF;
|
||||||
|
text-align: left;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
background: url(images/grid-blue-hd.gif) transparent repeat-x;
|
||||||
|
height : 18px;
|
||||||
|
}
|
||||||
|
table.scroll thead tr th div img {
|
||||||
|
width: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll th div {
|
||||||
|
overflow: hidden;
|
||||||
|
/* white-space: nowrap;*/
|
||||||
|
word-wrap: break-word;
|
||||||
|
height : 18px;
|
||||||
|
}
|
||||||
|
table.scroll th span {
|
||||||
|
cursor: e-resize;
|
||||||
|
/* border-right: 1px solid #D6D2C2; */
|
||||||
|
width: 5px;
|
||||||
|
float: right;
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
margin: -1px -1px -1px 0px;
|
||||||
|
height: 18px;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.scroll thead {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End Grid */
|
||||||
|
|
||||||
|
/* Pager */
|
||||||
|
div.scroll {
|
||||||
|
vertical-align: top;
|
||||||
|
height: 23px;
|
||||||
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
background-image: url(images/grid-blue-ft.gif);
|
||||||
|
border-right: 1px solid #FFFFFF;
|
||||||
|
border-left: 1px solid #FFFFFF;
|
||||||
|
border-bottom: 1px solid #FFFFFF;
|
||||||
|
}
|
||||||
|
div.scroll span {
|
||||||
|
vertical-align : top;
|
||||||
|
}
|
||||||
|
.selbox {
|
||||||
|
font-size: x-small;
|
||||||
|
vertical-align : top;
|
||||||
|
}
|
||||||
|
input.selbox{
|
||||||
|
font-size: x-small;
|
||||||
|
vertical-align : top;
|
||||||
|
}
|
||||||
|
.pgbuttons {
|
||||||
|
margin-top :1px;
|
||||||
|
}
|
||||||
|
.nav-table-left {
|
||||||
|
padding:1px;
|
||||||
|
float: left;
|
||||||
|
margin-top:2px;
|
||||||
|
/* position:absolute;*/
|
||||||
|
}
|
||||||
|
.nav-table-right {
|
||||||
|
padding:1px;
|
||||||
|
float: right;
|
||||||
|
margin-top:2px;
|
||||||
|
}
|
||||||
|
table.navtable {margin-bottom:0; width: auto;}
|
||||||
|
table.navtable tbody tr {
|
||||||
|
background-image: url(images/grid-blue-ft.gif);
|
||||||
|
}
|
||||||
|
table.navtable tbody tr td.nav-button {
|
||||||
|
border: 1px solid #FFFFFF;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
table.navtable tbody tr td.nav-hover {
|
||||||
|
border: 1px solid #c9b9b1;
|
||||||
|
}
|
||||||
|
table.tbutton tbody tr td {
|
||||||
|
border : none;
|
||||||
|
padding:0px;
|
||||||
|
}
|
||||||
|
img.jsHover { /*not used */
|
||||||
|
border: 1px solid #99CCFF;
|
||||||
|
}
|
||||||
|
/* End Pager */
|
||||||
|
/*multiselect checkbox */
|
||||||
|
.cbox {
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
/* text-align: center;*/
|
||||||
|
/*border:1px solid #999;*/
|
||||||
|
}
|
||||||
|
/* end multiselect */
|
||||||
|
|
||||||
|
|
||||||
|
/* loading div */
|
||||||
|
div.loading {
|
||||||
|
position: absolute;
|
||||||
|
padding: 3px;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
background: red;
|
||||||
|
color: white;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
div.loadingui {
|
||||||
|
display:none;
|
||||||
|
z-index:6000;
|
||||||
|
position:absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
div.loadingui div.msgbox {
|
||||||
|
position: relative;
|
||||||
|
z-index:6001;
|
||||||
|
left: 35%;
|
||||||
|
top:45%;
|
||||||
|
background: url(images/loading.gif) no-repeat left;
|
||||||
|
width: 100px;
|
||||||
|
border: 2px solid #B2D2FF;
|
||||||
|
text-align: right;
|
||||||
|
height: auto;
|
||||||
|
padding:2px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end loading div */
|
||||||
|
/*toolbar */
|
||||||
|
div.userdata {
|
||||||
|
margin-top: 0px;
|
||||||
|
background-color : #e3dfd1;
|
||||||
|
height : 20px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
/* end toolbar */
|
||||||
|
/*Subgrid text mode*/
|
||||||
|
.subgrid {
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
.tablediv {
|
||||||
|
background-color: White;
|
||||||
|
border-spacing: 1px; /*cellspacing:poor IE support for this*/
|
||||||
|
border-collapse: separate;
|
||||||
|
width:100%; /* FF hack poor when scroling subgrid */
|
||||||
|
}
|
||||||
|
.celldiv {
|
||||||
|
float: left;
|
||||||
|
display: table-cell;
|
||||||
|
border: 1px dotted #CCCCCC;
|
||||||
|
overflow: auto;
|
||||||
|
white-space: normal;
|
||||||
|
}
|
||||||
|
.celldivth {
|
||||||
|
float: left; /*fix for buggy browsers*/
|
||||||
|
border: 1px solid #CCCCCC;
|
||||||
|
background-color: #99CCFF;
|
||||||
|
border-bottom: 1px solid #CBC7B8;
|
||||||
|
text-align: left;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
.rowdiv {
|
||||||
|
display: table-row;
|
||||||
|
background: #F9F9F9 none;
|
||||||
|
color: #000000;
|
||||||
|
width: 100%;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
/* End Subgrid */
|
||||||
|
|
||||||
|
/* InLine editing */
|
||||||
|
input.editable[type="text"] {
|
||||||
|
font-size: x-small;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
input.editable[type="checkbox"] {
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea.editable {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.editable {
|
||||||
|
font-size: x-small;
|
||||||
|
}
|
||||||
|
/* End Inline Editing */
|
||||||
|
|
||||||
|
/*Modal Window */
|
||||||
|
.modaltext{
|
||||||
|
text-align : left;
|
||||||
|
}
|
||||||
|
.modalwin{
|
||||||
|
border:1px solid #555555;
|
||||||
|
background:#F9F9F9;
|
||||||
|
text-align:left;
|
||||||
|
margin: 0 auto;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.modalhead {
|
||||||
|
background-image: url(images/grid-blue-hd.gif);
|
||||||
|
height: 20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
.modalcontent {
|
||||||
|
overflow: auto;
|
||||||
|
margin-bottom: 9px;
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
/* end Modal window*/
|
||||||
|
/* Search window */
|
||||||
|
input.search {
|
||||||
|
margin: 2px;
|
||||||
|
width: 70px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
|
||||||
|
select.search {
|
||||||
|
margin: 2px;
|
||||||
|
width: 70px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
.buttonsearch {
|
||||||
|
width : 50px;
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
/*End search */
|
||||||
|
|
||||||
|
/* Form edit */
|
||||||
|
|
||||||
|
.FormGrid {
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
.EditTable {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.FormData { /* tr */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#FormError td {
|
||||||
|
font-size: 90%;
|
||||||
|
color: #FF0000;
|
||||||
|
vertical-align: top;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CaptionTD{ /* td */
|
||||||
|
font-weight: normal; text-align: left; vertical-align: top;
|
||||||
|
padding: 1px;
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
white-space: nowrap;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
.DataTD { /* td */
|
||||||
|
padding: 1px;
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
.navButton{
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
border-bottom: 1px solid #D4D0C8;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.navButton input{
|
||||||
|
width:19px;
|
||||||
|
}
|
||||||
|
input.EditButton { /* buttons are at footer tr */
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
td.EditButton {
|
||||||
|
text-align: right;
|
||||||
|
border-top: 1px solid #D4D0C8;
|
||||||
|
border-bottom: 1px solid #D4D0C8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.FormElement { /* form element - input -text,textarea,checkbox - select */
|
||||||
|
|
||||||
|
}
|
||||||
|
.FormElement {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
input[type="text"].FormElement{
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
input[type="checkbox"].FormElement{
|
||||||
|
width: 15px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
input[type="textarea"].FormElement{
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
select.FormElement {
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
/* End Eorm edit */
|
||||||
|
|
||||||
|
/* Delete Dialog */
|
||||||
|
.DelButton > input { /* buttons are at footer tr */
|
||||||
|
font-size: 10px;
|
||||||
|
color: #15428B;
|
||||||
|
}
|
||||||
|
.DelButton {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
/* End Delete Dialog */
|
||||||
|
|
||||||
|
img.jqResize {
|
||||||
|
position:absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
right: 0px;
|
||||||
|
cursor :se-resize;
|
||||||
|
}
|
||||||
|
.dirty-cell {
|
||||||
|
background: transparent url(images/dirty.gif) no-repeat 0 0;
|
||||||
|
}
|
||||||
|
#DelError td {
|
||||||
|
font-size: 90%;
|
||||||
|
color: #FF0000;
|
||||||
|
vertical-align: top;
|
||||||
|
background-color: #f7f7f7;
|
||||||
|
}
|
||||||
|
/* Tree Grid */
|
||||||
|
.tree-wrap
|
||||||
|
{
|
||||||
|
float: left;
|
||||||
|
position: relative;
|
||||||
|
height: 18px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.tree-minus
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
height: 18px;
|
||||||
|
width: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: url(images/tree_minus.gif) no-repeat;
|
||||||
|
}
|
||||||
|
.tree-plus
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
height: 18px;
|
||||||
|
width: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: url(images/tree_plus.gif) no-repeat;
|
||||||
|
}
|
||||||
|
.tree-leaf
|
||||||
|
{
|
||||||
|
position: absolute;
|
||||||
|
height: 18px;
|
||||||
|
width: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: url(images/tree_leaf.gif) no-repeat;
|
||||||
|
}
|
||||||
|
.treeclick
|
||||||
|
{
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.edit-cell {
|
||||||
|
background-color: #D2B48C !important;
|
||||||
|
}
|
||||||
|
.selected-row, .selected-row TD {
|
||||||
|
background-color: #c9b9b1;
|
||||||
|
}
|
||||||
BIN
site/webroot/css/jqGrid/coffee/images/cd_run.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
site/webroot/css/jqGrid/coffee/images/dirty.gif
Normal file
|
After Width: | Height: | Size: 832 B |
BIN
site/webroot/css/jqGrid/coffee/images/down.gif
Normal file
|
After Width: | Height: | Size: 683 B |
BIN
site/webroot/css/jqGrid/coffee/images/find.gif
Normal file
|
After Width: | Height: | Size: 986 B |
BIN
site/webroot/css/jqGrid/coffee/images/first.gif
Normal file
|
After Width: | Height: | Size: 734 B |
BIN
site/webroot/css/jqGrid/coffee/images/folder.png
Normal file
|
After Width: | Height: | Size: 229 B |
BIN
site/webroot/css/jqGrid/coffee/images/grid-blue-ft.gif
Normal file
|
After Width: | Height: | Size: 165 B |
BIN
site/webroot/css/jqGrid/coffee/images/grid-blue-hd.gif
Normal file
|
After Width: | Height: | Size: 165 B |