From: Mitch Jackson Date: Thu, 14 Dec 2017 00:14:43 +0000 (-0600) Subject: rt# 74031 Implement forms for editing real estate inventory X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=8c04f3676f1e83393432a0ba899ec5b7fea4afe0 rt# 74031 Implement forms for editing real estate inventory --- diff --git a/httemplate/browse/realestate_location.html b/httemplate/browse/realestate_location.html new file mode 100644 index 000000000..be2cd11f8 --- /dev/null +++ b/httemplate/browse/realestate_location.html @@ -0,0 +1,43 @@ +<% include( 'elements/browse.html', + title => emt('Real Estate Locations'), + name => 'real estate locations', + + menubar => [ + 'Edit units' => "${p}browse/realestate_unit.html", + 'Add a new location' => "${p}edit/realestate_location.html", + 'Add a new unit' => "${p}edit/realestate_unit.html", + ], + + query => { table => 'realestate_location' }, + count_query => 'SELECT COUNT(*) FROM realestate_location', + + header => [ 'Location', 'Address', 'Address 2', 'City', 'State', 'Zip' ], + fields => [ + 'location_title', + 'address1', + 'address2', + 'city', + 'state', + 'zip' + ], + links => [ + ["${p}edit/realestate_location.html?", 'realestatelocnum' ], + ], + + agent_virt => 1, + agent_pos => 0, + disableable => 1, +) +%> +<%init> + + +my $curuser = $FS::CurrentUser::CurrentUser; +die("access denied") + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); + + + + diff --git a/httemplate/browse/realestate_unit.html b/httemplate/browse/realestate_unit.html new file mode 100644 index 000000000..e71a59819 --- /dev/null +++ b/httemplate/browse/realestate_unit.html @@ -0,0 +1,63 @@ +<% include( 'elements/browse.html', + title => emt('Real Estate Inventory'), + name => 'real estate inventory', + + menubar => [ + 'Edit locations' => "${p}browse/realestate_location.html", + 'Add a new location' => "${p}edit/realestate_location.html", + 'Add a new unit' => "${p}edit/realestate_unit.html", + ], + + query => { + table => 'realestate_unit', + select => join(', ',qw( + realestate_unit.* + realestate_location.location_title + cust_main.first + cust_main.last + cust_main.company + )), + addl_from => " + LEFT JOIN realestate_location + ON realestate_location.realestatelocnum + = realestate_unit.realestatelocnum + LEFT JOIN cust_main + ON realestate_unit.custnum = cust_main.custnum + ", + }, + + count_query => 'SELECT COUNT(*) FROM realestate_unit', + + header => [ 'Location', 'Unit', 'Customer' ], + fields => [ + 'location_title', + 'unit_title', + sub { + return '' unless $_[0]->custnum; + return $_[0]->company if $_[0]->company; + return $_[0]->first.' '.$_[0]->last; + }, + ], + links => [ + ["${p}edit/realestate_location?", 'realestatelocnum' ], + ["${p}edit/realestate_unit.html?", 'realestatenum' ], + ["${p}view/cust_main.cgi?", 'custnum' ] + ], + + agent_virt => 1, + agent_pos => 0, + disableable => 1, +) +%> +<%init> + + +my $curuser = $FS::CurrentUser::CurrentUser; +die("access denied") + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); + + + + diff --git a/httemplate/edit/process/realestate_location.html b/httemplate/edit/process/realestate_location.html new file mode 100644 index 000000000..ab5cf230f --- /dev/null +++ b/httemplate/edit/process/realestate_location.html @@ -0,0 +1,14 @@ +<% include( 'elements/process.html', + table => 'realestate_location', + viewall_dir => 'browse', + ) +%> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); + + diff --git a/httemplate/edit/process/realestate_unit.html b/httemplate/edit/process/realestate_unit.html new file mode 100644 index 000000000..ba9b5dc92 --- /dev/null +++ b/httemplate/edit/process/realestate_unit.html @@ -0,0 +1,13 @@ +<& elements/process.html, + 'table' => 'realestate_unit', + 'viewall_dir' => 'browse', +&> +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die("access denied") + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); + + diff --git a/httemplate/edit/realestate_location.html b/httemplate/edit/realestate_location.html new file mode 100644 index 000000000..254e57f5e --- /dev/null +++ b/httemplate/edit/realestate_location.html @@ -0,0 +1,71 @@ +<% include( 'elements/edit.html', + 'name_singular' => 'Real Estate Location', + 'table' => 'realestate_location', + + 'labels' => { + realestatelocnum => 'Location', + location_title => "Location", + address1 => "Address", + address2 => "Address", + city => "City", + state => "State", + zip => "Zip-Code", + disabled => "Disabled", + }, + 'fields' => [ + { field => 'realestatelocnum', type => 'hidden' }, + + { field => 'location_title', + type=>'text', + size => 40, + maxlength => 80, + }, + { field => 'address1', + type=>'text', + size => 40, + maxlength => 80, + }, + { field => 'address2', + type=>'text', + size => 40, + maxlength => 80, + }, + { field => 'city', + type=>'text', + size => 40, + maxlength => 80, + }, + { field => 'state', + type=>'text', + size => 40, + maxlength => 80, + }, + { field => 'zip', + type=>'text', + size => 5, + maxlength => 5, + }, + + { field => 'agentnum', + type => 'select-agent', + }, + { field => 'disabled', + type=>'checkbox', + value=>'Y' + }, + ], + + 'viewall_dir' => 'browse', + 'agent_virt' => 1, +) +%> + +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die("access denied") + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); + + diff --git a/httemplate/edit/realestate_unit.html b/httemplate/edit/realestate_unit.html new file mode 100644 index 000000000..b8bf1fa22 --- /dev/null +++ b/httemplate/edit/realestate_unit.html @@ -0,0 +1,49 @@ +<% include( 'elements/edit.html', + 'name_singular' => 'Real Estate Unit', + 'table' => 'realestate_unit', + + 'labels' => { + realestatenum => 'Ref No', + unit_title => 'Unit Title', + agentnum => 'Agent', + realestatelocnum => 'Location', + }, + 'fields' => [ + { field => 'realestatenum', type => 'hidden' }, + { field => 'custnum', type => 'hidden' }, + + { field => 'unit_title', + type=>'text', + size => 40, + }, + { field => 'realestatelocnum', + type => 'select-realestate_location', + + # possible todo: + # I'd like to have this field disabled for editing on existing records, + # and only show the full selectbox for new records. + + }, + { field => 'agentnum', + type => 'select-agent', + }, + { field => 'disabled', + type=>'checkbox', + value=>'Y' + }, + ], + + 'viewall_dir' => 'browse', + 'agent_virt' => 1, +) +%> + +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die("access denied") + unless $curuser->access_right('Edit inventory') + || $curuser->access_right('Edit global inventory') + || $curuser->access_right('Configuration'); + + diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 3532e6074..0a73d71a6 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -829,12 +829,12 @@ $config_misc{'Custom fields'} = [ $fsurl.'browse/part_virtual_field.html', 'Loca if $curuser->access_right('Edit custom fields'); $config_misc{'Translation strings'} = [ $fsurl.'browse/msgcat.html', 'Translations and other customizable labels for each locale' ] if $curuser->access_right('Configuration'); -$config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/realestate_inventory.html', 'Setup inventory classes and stock inventory' ] +$config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_class.html', 'Setup inventory classes and stock inventory' ] if $curuser->access_right('Edit inventory') || $curuser->access_right('Edit global inventory') || $curuser->access_right('Configuration'); -$config_misc{'Real estate inventory'} = [ $fsurl.'browse/inventory_realestate.html', 'Setup real estate inventory' ] +$config_misc{'Real estate inventory'} = [ $fsurl.'browse/realestate_unit.html', 'Setup real estate inventory' ] if $curuser->access_right('Edit realestate inventory') || $curuser->access_right('Edit global inventory') || $curuser->access_right('Configuration'); diff --git a/httemplate/elements/select-realestate_location.html b/httemplate/elements/select-realestate_location.html new file mode 100644 index 000000000..001ed3e89 --- /dev/null +++ b/httemplate/elements/select-realestate_location.html @@ -0,0 +1,32 @@ +<%doc> + + Displays a selectbox populated with values from realestate_location. + key: realestate_location.realestatenum + value: realestate_location.location_title + + + +<% include( '/elements/select-table.html', + %opt, + table => 'realestate_location', + name_col => 'location_title', + hashref => { 'disabled' => '' }, + value => $select_value, + disable_empty => 1, + ) +%> + +<%init> + +# +# possible todo: +# I'd like to change the behavior of this select based on if +# a new item is being created, or an existing item being edited + +my %opt = @_; +my $select_value = $opt{'curr_value'} || $opt{'value'}; + +# use Data::Dumper qw(Dumper); +# print Dumper(\%opt); + + diff --git a/httemplate/elements/tr-select-realestate_location.html b/httemplate/elements/tr-select-realestate_location.html new file mode 100644 index 000000000..1367886ed --- /dev/null +++ b/httemplate/elements/tr-select-realestate_location.html @@ -0,0 +1,17 @@ + + <% $opt{'label'} || 'Real Estate Location' %> + + <% include( '/elements/select-realestate_location.html', + 'curr_value' => $curr_value, + %opt + ) + %> + + + +<%init> + +my %opt = @_; +my $curr_value = $opt{'curr_value'} || $opt{'value'}; + +