From bf0b5d93e74d8113d655ac16a7f130473d1c91d9 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Sat, 6 Jun 2009 11:49:03 +1200 Subject: [PATCH] Browse/View/Edit chartofaccount records. --- inc/browse/chartofaccounts.php | 50 ++++++++++++++++++++++++++++++++++ inc/edit/chartofaccount.php | 61 ++++++++++++++++++++++++++++++++++++++++++ inc/view/chartofaccount.php | 46 +++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 inc/browse/chartofaccounts.php create mode 100644 inc/edit/chartofaccount.php create mode 100644 inc/view/chartofaccount.php diff --git a/inc/browse/chartofaccounts.php b/inc/browse/chartofaccounts.php new file mode 100644 index 0000000..ca98051 --- /dev/null +++ b/inc/browse/chartofaccounts.php @@ -0,0 +1,50 @@ +AddField( 'updates', 'char1', "SELECT ' ', '--Show All--' UNION SELECT 'Z', '--No Manual Posting--' UNION SELECT entitytype, description FROM entitytype ORDER BY 1" ); +$widget->ReadWrite(); +$widget->Defaults( array('updates' => ' ' ) ); +$widget->Layout( '
Update to: ##updates.select## ##Show.submit##
' ); + +$allow_updates = ' '; +if ( isset($widget->Record->{'updates'}) && preg_match( '#([ACTLPJZ]+)#i', $widget->Record->{'updates'}, $matches) ) $allow_updates = strtoupper($matches[1]); + +$page_elements[] = $widget; + + +$browser = new Browser("Chart of Accounts"); + +if ( !isset($accountgroup) ) $browser->AddColumn( 'accountgroupcode', 'Group', 'left' ); +$browser->AddColumn( 'accountcode', 'Account', 'right', '', "TO_CHAR(accountcode,'FM0009.00')" ); +$browser->AddColumn( 'shortname', 'ShortName' ); +$browser->AddColumn( 'name', 'Name', 'left', '%s', 'chartofaccount.name' ); +$browser->AddHidden( 'alternativecode' ); +$browser->AddColumn( 'updateto', 'Updates' ); +$browser->AddColumn( 'highvolume', 'Volume', 'left', '', "CASE WHEN highvolume THEN 'Yes' ELSE 'No' END" ); +$browser->SetJoins( "chartofaccount LEFT JOIN accountgroup USING ( accountgroupcode )" ); +$rowurl = '/view.php?t=chartofaccount&id=%s'; +$browser->RowFormat( "\n", "\n", 'accountcode', '#even' ); +$browser->SetOrdering( 'accountcode' ); + +if ( isset($accountgroup) ) $browser->AndWhere( "accountgroupcode = ".qpg($accountgroup) ); + +if ( $allow_updates != ' ' ) { + if ( $allow_updates != 'Z' ) + $browser->AndWhere( "updateto ~ '[$allow_updates]'" ); + else + $browser->AndWhere( "updateto IS NULL OR updateto = ''" ); +} + +include_once("menus_entityaccount.php"); + +$rowurl = '/view.php?t=document&id=%s'; +$c->page_title = $browser->Title; +$browser->DoQuery(); +$page_elements[] = $browser; diff --git a/inc/edit/chartofaccount.php b/inc/edit/chartofaccount.php new file mode 100644 index 0000000..06c9dc1 --- /dev/null +++ b/inc/edit/chartofaccount.php @@ -0,0 +1,61 @@ +SetLookup("accountgroupcode", "SELECT accountgroupcode, accountgroupcode || ' - ' || name AS description FROM accountgroup ORDER BY sequencecode"); +$editor->SetWhere( "accountcode=$ac"); + +if ( $editor->IsSubmit() ) { + $ac = floatval($_POST['accountcode']); + $editor->WhereNewRecord( "accountcode=".floatval($_POST['accountcode']) ); + $editor->Write(); + $editor->SetWhere( "accountcode=$ac"); + $editor->GetRecord(); +} +else { + $editor->GetRecord(); +} + +$template = << + + Account: + ##accountcode.input.7## + + + Short name: + ##shortname.input.12## + + + Name: + ##name.input.50## + + + Group: + ##accountgroupcode.select## + + + High volume: + ##highvolume.checkbox## + + + Update to: + ##updateto.input.10## + + +   + ##submit## + + + +EOTEMPLATE; + +$editor->SetTemplate( $template ); +$editor->SetTitle("Account $ac - " . $editor->Record->{'name'}); +$c->page_title = $editor->Title; +$page_elements[] = $editor; + +include_once("menus_entityaccount.php"); diff --git a/inc/view/chartofaccount.php b/inc/view/chartofaccount.php new file mode 100644 index 0000000..0432bdb --- /dev/null +++ b/inc/view/chartofaccount.php @@ -0,0 +1,46 @@ +SetWhere( "accountcode=$ac"); +$viewer->GetRecord(); + +$template = << + + Account: + ##accountcode.format.%07.2lf## + + + Short name: + ##shortname## + + + Name: + ##name## + + + Group: + ##accountgroupcode## + + + High volume: + ##highvolume## + + + Update to: + ##updateto## + + + +EOTEMPLATE; + +$viewer->SetTemplate( $template ); +$viewer->SetTitle("Account $ac - " . $viewer->Record->{'name'}); +$c->page_title = $viewer->Title; +$page_elements[] = $viewer; + +include_once("menus_entityaccount.php"); + -- 2.11.4.GIT