3 param_to_global( 'creditorcode', 'int' );
6 * Add some widgets onto the top of the browser
8 include_once("classWidgets.php");
9 $widget = new Widget("browse-$component");
10 $widget->AddField( 'year', 'int1', "SELECT 0, '--- All Years ---' UNION SELECT financialyearcode, description FROM financialyear ORDER BY 1;" );
11 $widget->AddField( 'status', 'char1', "SELECT '[^PC]', '--- Yet to be Paid ---', -10 UNION SELECT '.', '--- Any Status ---', -1 UNION SELECT voucherstatus, description, sequencecode FROM voucherstatus ORDER BY 3;" );
13 $widget->Defaults( array( 'year' => $year, 'status' => '[^PC]') );
14 $widget->Layout( '<table> <tr>
15 <th>Status:</th> <td>##status.select##</td>
16 <th>For year:</th> <td>##year.select##</td>
17 <td>##Show.submit##</td> </tr> </table>' );
18 $page_elements[] = $widget;
20 $related_menu->AddOption("New Voucher","/edit.php?t=voucher","Create a new voucher", false, 3100);
22 $browser = new Browser("Vouchers");
23 $browser->AddColumn( 'voucherseq', 'Vchr#', 'right' );
24 $browser->AddHidden( 'vchrst', "'vchrst'||lower(voucherstatus)" );
25 $browser->AddColumn( 'voucherstatus', 'S', 'center' );
26 $browser->AddColumn( 'date', 'Date', 'center' );
27 $browser->AddColumn( 'invoicereference', 'Invoice#', 'left', '<span style="white-space:nowrap;">%s</span>' );
28 $browser->AddColumn( 'ourorderno', 'Order', 'left', '<span style="white-space:nowrap;">%s</span>' );
29 $browser->AddColumn( 'description', 'Description' );
30 $browser->AddColumn( 'goodsvalue', 'Goods', 'right', '%0.2lf' );
31 $browser->AddColumn( 'taxvalue', 'Tax', 'right', '%0.2lf' );
32 $browser->AddColumn( 'total', 'Total', 'right', '%0.2lf', '(goodsvalue + taxvalue)' );
33 $browser->AddTotal( 'goodsvalue' );
34 $browser->AddTotal( 'taxvalue' );
35 $browser->AddTotal( 'total' );
36 $browser->SetJoins( "voucher " );
37 if ( isset($creditorcode) ) {
38 $qry = new PgQuery( "SELECT name FROM creditor WHERE creditorcode = ?;", $creditorcode );
39 if ( $qry->Exec("Browse::Vouchers") && $row = $qry->Fetch() ) {
40 $browser->Title("Vouchers for $row->name (C$creditorcode)");
42 $browser->AndWhere( "voucher.creditorcode=$creditorcode" );
44 if ( $widget->Record
->{'status'} != '' ) {
45 $browser->AndWhere( "voucherstatus ~* " .qpg($widget->Record
->{'status'}) );
47 if ( $widget->Record
->{'year'} > 0 ) {
48 $browser->SetJoins("voucher JOIN month ON month.startdate <= voucher.date AND month.enddate >= voucher.date ");
49 $browser->AndWhere( "financialyearcode = " . qpg($widget->Record
->{'year'}) );
51 $browser->AddOrder( 'voucherseq', 'DESC', 1 );
52 $rowurl = '/view.php?t=voucher&id=%s';
53 $browser->RowFormat( "<tr onclick=\"window.location='$rowurl';\" class=\"r%d%s\">\n", "</tr>\n",
54 'voucherseq', '#even', 'vchrst' );
56 $c->page_title
= $browser->Title();
57 $page_elements[] = $browser;
59 include_once("menus_entityaccount.php");