summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2018-01-11 20:05:34 -0600
committerMitch Jackson <mitch@freeside.biz>2018-01-11 20:05:34 -0600
commit69e481a4a9191b9912d6bb8202627a5dc75f74ce (patch)
tree85604b29a5ce712824472778f488e69d0b0be1c5 /httemplate
parent77daf007ef522ae71041d9b094643cf868d8ecce (diff)
rt# 74031 implement svc_realestate
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/realestate_location.html43
-rw-r--r--httemplate/browse/realestate_unit.html70
-rw-r--r--httemplate/docs/part_svc-table.html7
-rw-r--r--httemplate/edit/process/realestate_location.html14
-rw-r--r--httemplate/edit/process/realestate_unit.html13
-rw-r--r--httemplate/edit/realestate_location.html72
-rw-r--r--httemplate/edit/realestate_unit.html48
-rw-r--r--httemplate/elements/menu.html6
-rw-r--r--httemplate/elements/select-realestate_location.html32
-rw-r--r--httemplate/elements/select-realestate_unit.html59
-rw-r--r--httemplate/elements/tr-select-realestate_location.html17
-rw-r--r--httemplate/elements/tr-select-realestate_unit.html5
12 files changed, 384 insertions, 2 deletions
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');
+
+
+
+</%init>
diff --git a/httemplate/browse/realestate_unit.html b/httemplate/browse/realestate_unit.html
new file mode 100644
index 000000000..399cd2583
--- /dev/null
+++ b/httemplate/browse/realestate_unit.html
@@ -0,0 +1,70 @@
+<% 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 svc_realestate
+ ON realestate_unit.realestatenum = svc_realestate.realestatenum
+ LEFT JOIN cust_svc
+ ON svc_realestate.svcnum = cust_svc.svcnum
+ LEFT JOIN cust_pkg
+ ON cust_svc.pkgnum = cust_pkg.pkgnum
+ LEFT JOIN cust_main
+ ON cust_pkg.custnum = cust_main.custnum
+ ",
+ order_by => "ORDER BY location_title, unit_title"
+ },
+
+ 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.html?", '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');
+
+
+
+</%init>
diff --git a/httemplate/docs/part_svc-table.html b/httemplate/docs/part_svc-table.html
index 820d0b9cc..56a4d0e8c 100644
--- a/httemplate/docs/part_svc-table.html
+++ b/httemplate/docs/part_svc-table.html
@@ -39,6 +39,7 @@
<TR>
<TH ALIGN="left">Hosting</TH>
<TH ALIGN="left">Colocation</TH>
+ <TH ALIGN="left">Real Estate</TH>
</TR>
<TD VALIGN="top">
<UL STYLE="margin:0">
@@ -54,6 +55,11 @@
<LI><B>svc_port</B>: Customer router/switch port
</UL>
</TD>
+ <TD VALIGN="top">
+ <UL STYLE="margin:0">
+ <LI><B>svc_realestate</B>: Real estate properties
+ </UL>
+ </TD>
</TR>
<TABLE>
<!-- <LI>svc_charge - One-time charges (Partially unimplemented)
@@ -62,4 +68,3 @@
</BODY>
</HTML>
-
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');
+
+</%init>
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');
+
+</%init>
diff --git a/httemplate/edit/realestate_location.html b/httemplate/edit/realestate_location.html
new file mode 100644
index 000000000..34344e98f
--- /dev/null
+++ b/httemplate/edit/realestate_location.html
@@ -0,0 +1,72 @@
+<% 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',
+ value => 1,
+ },
+ { 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');
+
+</%init>
diff --git a/httemplate/edit/realestate_unit.html b/httemplate/edit/realestate_unit.html
new file mode 100644
index 000000000..a7ca72dd9
--- /dev/null
+++ b/httemplate/edit/realestate_unit.html
@@ -0,0 +1,48 @@
+<% 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 => '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');
+
+</%init>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index defcc494f..0a73d71a6 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -834,6 +834,11 @@ $config_misc{'Inventory classes and inventory'} = [ $fsurl.'browse/inventory_cla
|| $curuser->access_right('Edit global inventory')
|| $curuser->access_right('Configuration');
+$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');
+
$config_misc{'Upload targets'} = [ $fsurl.'browse/upload_target.html', 'Billing and payment upload destinations' ]
if $curuser->access_right('Configuration');
@@ -1038,4 +1043,3 @@ sub submenu {
}
</%init>
-
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
+
+</%doc>
+
+<% 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);
+
+</%init>
diff --git a/httemplate/elements/select-realestate_unit.html b/httemplate/elements/select-realestate_unit.html
new file mode 100644
index 000000000..e189d5d99
--- /dev/null
+++ b/httemplate/elements/select-realestate_unit.html
@@ -0,0 +1,59 @@
+<%doc>
+
+Display a pair of select boxes for provisioning a realestate_unit
+- Real Estate Location
+- Real Estate Unit
+
+NOTE:
+ Records are always suppresed if
+ - realestate_location.disabled is set
+ - realestate_unit is provisioned to a customer [not working]
+
+ If it becomes necessary, an option may be added to the template
+ to show disabled/provisioned records, but is not yet implemented
+
+</%doc>
+<& select-tiered.html,
+ 'tiers' => [
+ {
+
+ field => 'realestate_location',
+ table => 'realestate_location',
+ extra_sql => "WHERE realestate_location.disabled IS NULL "
+ . " OR realestate_location.disabled = '' ",
+ name_col => 'location_title',
+ empty_label => '(all)',
+ },
+ {
+ field => 'realestatenum',
+ table => 'realestate_unit',
+ name_col => 'unit_title',
+ value_col => 'realestatenum',
+ link_col => 'realestatelocnum',
+
+ # TODO: Filter units assigned to customers
+ # SQL below breaks the selectbox... why?
+
+ # Also, can we assume if realestatenum doesn't appear in svc_realestate
+ # that the realestate_unit is unprovisioned to a customer? What indicator
+ # should be used to determine when a realestae_unit is not provisioned?
+
+ # addl_from => "
+ # LEFT JOIN svc_realestate
+ # ON svc_realestate.realestatenum = realestate_unit.realestatenum
+ # ",
+
+ #extra_sql => "WHERE svc_realestate.svcnum IS NULL ",
+
+ disable_empty => 1,
+ debug => 1,
+ },
+ ],
+ %opt,
+ 'prefix' => $opt{'prefix'}. $opt{'field'}. '_', #after %opt so it overrides
+&>
+<%init>
+
+my %opt = @_;
+
+</%init>
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 @@
+<TR>
+ <TH ALIGN="right"><% $opt{'label'} || 'Real Estate Location' %></TD>
+ <TD>
+ <% include( '/elements/select-realestate_location.html',
+ 'curr_value' => $curr_value,
+ %opt
+ )
+ %>
+ </TD>
+</TR>
+
+<%init>
+
+my %opt = @_;
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+</%init>
diff --git a/httemplate/elements/tr-select-realestate_unit.html b/httemplate/elements/tr-select-realestate_unit.html
new file mode 100644
index 000000000..b1a4296d4
--- /dev/null
+++ b/httemplate/elements/tr-select-realestate_unit.html
@@ -0,0 +1,5 @@
+<& tr-td-label.html, @_ &>
+<td>
+<& select-realestate_unit.html, @_ &>
+</td>
+</tr>