config {
    base_dir        `/home/pcrow`;
    engine          MP13;
    template_engine TT;
    Init            Std           {}
    SQL             Postgres      {}
    HttpdConf       Gantry        {}
    Control         Gantry        {}
    Model           GantryCDBI    {}
    SiteLook        GantryDefault {}
}
app Checkbook {
    location `/checking`;
    config {
        dbconn           `dbi:Pg:dbname=checking`        => no_accessor;
        dbuser           apache                          => no_accessor;
        template_wrapper `checking_wrapper.tt`           => no_accessor;
        root
            `/home/pcrow/Checkbook/html;/home/httpd/html/bailey`
                                                         => no_accessor;
        css_root         `/home/pcrow/Checking/html/css` => no_accessor;
        app_rootp        `/canopy`                       => no_accessor;
    }
    sequence payeepayor_seq { }
    table payeepayor {
		sequence payeepayor_seq;
        foreign_display `%name`;
        field id    { is `int4 PRIMARY KEY`, assign_by_sequence; }
        field name  {
            is             varchar;
            label          Name;
            html_form_type text;
        }
        field descr {
            is             varchar;
            label          Description;
            html_form_type textarea;
            html_form_rows 5;
            html_form_cols 45;
        }
    }
    sequence category_seq {}
    table category {
        sequence category_seq;
        foreign_display `%type: %subtype`;
        field id    { is `int4 PRIMARY KEY`, assign_by_sequence; }
        field type  {
            is                     varchar;
            label                  Name;
            html_form_type         text;
        }
        field sub_type  {
            is                     varchar;
            label                  Name;
            html_form_type         text;
            html_form_optional     1;
        }
    }
    sequence status_seq { }
    table status {
        sequence status_seq;
        foreign_display `%descr`;

        field id { is `int4 PRIMARY KEY`, auto; }
        field descr {
            is             varchar;
            label          Description;
            html_form_type text;
        }
        data descr => Outstanding;
        data descr => Cleared;
        data descr => Reconciled;
    }
    sequence trans_seq { }
    table trans {
        sequence trans_seq;
        field id { is `int4 PRIMARY KEY`, auto; }
        field status {
            is                     varchar;
            label                  Status;
            refers_to              status;
            html_form_type         select;
        }
        field trans_date {
            is                     date;
            label                  `Trans Date`;
            html_form_type         text;
            html_form_display_size 10;
            date_select_text       Select;
        }
        field amount {
            is                     int4;
            label                  Amount;
            html_form_type         text;
            html_form_display_size 10;
        }
        field payee_payor {
            is                     int4;
            refers_to              payee;
            label                  `Paid To/Rec\\'v\\'d From`;
            html_form_type         select;
        }
        field category {
            is                     int4;
            refers_to              category;
            label                  Category;
            html_form_type         select;
        }
        field descr {
            is                     varchar;
            label                  Descr;
            html_form_type         textarea;
            html_form_rows         3;
            html_form_cols         60;
            html_form_optional     1;
        }
    }
    controller PayeePayor {
        uses              Gantry::Plugins::AutoCRUD;
        controls_table    payeepayor;
        text_description `Payee/Payor`;
        rel_location      payeeor;

        method do_main is main_listing {
            title          `Payees/Payors`;
            cols           name;
            header_options Add;
            row_options    Edit, Delete;
        }

        method _form is AutoCRUD_form {
            form_name      payeeor;
            all_fields_but id;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    controller Category {
        uses              Gantry::Plugins::AutoCRUD;
        controls_table    category;
        text_description `Category`;
        rel_location      category;

        method do_main is main_listing {
            title          Category;
            cols           type, sub_type;
            header_options Add;
            row_options    Edit, Delete;
        }

        method _form is AutoCRUD_form {
            form_name      category;
            all_fields_but id;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    controller Status {
        uses              Gantry::Plugins::AutoCRUD;
        controls_table    status;
        text_description `Status`;
        rel_location      status;

        method do_main is main_listing {
            title          Status;
            cols           descr;
            header_options Add;
            row_options    Edit, Delete;
        }

        method _form is AutoCRUD_form {
            form_name      category;
            all_fields_but id;
            extra_keys
                legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
        }
    }
    controller Trans {
        uses              Gantry::Plugins::AutoCRUD, Gantry::Plugins::Calendar;
        controls_table    trans;
        text_description  Transaction;
        rel_location      trans;

        method do_main is main_listing {
            title          `Transaction`;
            cols           status, trans_date, amount, payee_payor, category;
            header_options Add;
            row_options    Edit, Delete;
        }

        method _form is AutoCRUD_form {
            form_name      trans;
            all_fields_but id;
            extra_keys
                legend     => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`,
                javascript => `$self->calendar_month_js( 'trans' )`;
        }
    }
}
