diff options
author | mark <mark> | 2010-05-25 07:53:08 +0000 |
---|---|---|
committer | mark <mark> | 2010-05-25 07:53:08 +0000 |
commit | 80eddb3dc8201a9686db214af2d6dbc5a637c107 (patch) | |
tree | 202e27650dbcd23fc59655c245db6aff6cbb9de8 | |
parent | 306ebf9299ec7875e51320f1c2d7c2f5bc9dfe2c (diff) |
RT#7010: inventory items can be moved between agents
-rw-r--r-- | httemplate/misc/inventory_item-move.cgi | 23 | ||||
-rw-r--r-- | httemplate/search/inventory_item.html | 45 |
2 files changed, 67 insertions, 1 deletions
diff --git a/httemplate/misc/inventory_item-move.cgi b/httemplate/misc/inventory_item-move.cgi new file mode 100644 index 000000000..4d53beb23 --- /dev/null +++ b/httemplate/misc/inventory_item-move.cgi @@ -0,0 +1,23 @@ +<% '',$cgi->redirect(popurl(2). "search/inventory_item.html?$browse_opts") %> +<%init> + +# Shamelessly copied from misc/cust_attachment.cgi. + +my $browse_opts = join(';', map { $_.'='.$cgi->param($_) } + qw( classnum avail ) + ); + +my $move_agentnum = $cgi->param('move_agentnum') or + die "No agent selected"; +foreach my $itemnum ( + map { /^itemnum(\d+)$/; $1; } grep /^itemnum\d+$/, $cgi->param ) { + my $item = qsearchs('inventory_item', { 'itemnum' => $itemnum }); +# die "Can't move assigned inventory item $itemnum" if $item->svcnum; + my $error; + $item->agentnum($move_agentnum); + $error = $item->replace; + die $error if $error; +} + +</%init> + diff --git a/httemplate/search/inventory_item.html b/httemplate/search/inventory_item.html index 37914e0a7..086c8e92d 100644 --- a/httemplate/search/inventory_item.html +++ b/httemplate/search/inventory_item.html @@ -34,6 +34,7 @@ $inventory_class->classname, 'Service', FS::UI::Web::cust_header(), + '', # checkbox column ], 'fields' => [ @@ -56,6 +57,7 @@ }, \&FS::UI::Web::cust_fields, + $sub_checkbox, ], 'align' => 'rll'.FS::UI::Web::cust_aligns(), @@ -79,7 +81,12 @@ '', FS::UI::Web::cust_styles(), ], - + 'html_form' => + qq! +<FORM NAME="itemForm" ACTION="$p/misc/inventory_item-move.cgi" METHOD="POST"> +<INPUT TYPE="hidden" NAME="classnum" VALUE="$classnum"> +<INPUT TYPE="hidden" NAME="avail" VALUE="! .$cgi->param('avail') . '">', #' + 'html_foot' => $sub_foot, ) %> <%init> @@ -151,5 +158,41 @@ my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '. ' LEFT JOIN part_svc USING ( svcpart ) '. ' LEFT JOIN cust_pkg USING ( pkgnum ) '. ' LEFT JOIN cust_main USING ( custnum ) '; +my $areboxes = 0; + +my $sub_checkbox = sub { + my $item = $_[0]; + my $itemnum = $item->itemnum; + #return '' if $item->svcnum; + $areboxes = 1; + return qq!<INPUT NAME="itemnum$itemnum" TYPE="checkbox" VALUE="1">!; +}; + +my $sub_foot = sub { + return if !$areboxes; + my $foot = +'<BR><INPUT TYPE="button" VALUE="Select all" onClick="setAll(true)"> +<INPUT TYPE="button" VALUE="Unselect all" onClick="setAll(false)"> +<BR><INPUT TYPE="submit" NAME="action" VALUE="Move to agent"> +<SELECT NAME="move_agentnum">'; + foreach my $agent ($curuser->agents) { + $foot .= '<OPTION VALUE="'.$agent->agentnum.'">'. + $agent->agent . '</OPTION> + '; + } + $foot .= '</SELECT> +<SCRIPT TYPE="text/javascript"> + function setAll(setTo) { + theForm = document.itemForm; + for (i=0,n=theForm.elements.length;i<n;i++) + if (theForm.elements[i].name.indexOf("itemnum") != -1) + theForm.elements[i].checked = setTo; + } +</SCRIPT>'; + $foot; +}; + + + </%init> |