From 8e2372530191ae32938786363885aa4b540e29c7 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 19 Jan 2015 02:29:23 -0800 Subject: import package definitions, RT#32639 --- httemplate/browse/part_pkg.cgi | 4 + httemplate/elements/menu.html | 13 +-- httemplate/misc/cust_pkg-import.html | 28 +++---- httemplate/misc/part_pkg-import.html | 116 +++++++++++++++++++++++++++ httemplate/misc/process/part_pkg-import.html | 10 +++ 5 files changed, 150 insertions(+), 21 deletions(-) create mode 100644 httemplate/misc/part_pkg-import.html create mode 100644 httemplate/misc/process/part_pkg-import.html (limited to 'httemplate') diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi index 87aa79255..87e7aad90 100755 --- a/httemplate/browse/part_pkg.cgi +++ b/httemplate/browse/part_pkg.cgi @@ -76,6 +76,10 @@ if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { } $cgi->delete('classnum'); +if ( $cgi->param('pkgpartbatch') =~ /^([\w\/\-\:\. ]+)$/ ) { + push @where, "pkgpartbatch = '$1' "; +} + if ( $cgi->param('missing_recur_fee') ) { push @where, "NOT EXISTS ( SELECT 1 FROM part_pkg_option WHERE optionname = 'recur_fee' diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 03ce20185..816f74ab6 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -445,12 +445,13 @@ $report_menu{'SQL Query'} = [ $fsurl.'search/report_sql.html', 'SQL Query'] if $curuser->access_right('Raw SQL'); tie my %tools_importing, 'Tie::IxHash', - 'Customers' => [ $fsurl.'misc/cust_main-import.cgi', '' ], - 'Customer packages' => [ $fsurl.'misc/cust_pkg-import.html', '' ], - 'Customer comments' => [ $fsurl.'misc/cust_main_note-import.html', '' ], - 'One-time charges' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ], - 'Payments' => [ $fsurl.'misc/cust_pay-import.cgi', '' ], - 'Credits' => [ $fsurl.'misc/cust_credit-import.html', '' ], + 'Customers' => [ $fsurl.'misc/cust_main-import.cgi', '' ], + 'Package definitions' => [ $fsurl.'misc/part_pkg-import.html', '' ], + 'Customer packages' => [ $fsurl.'misc/cust_pkg-import.html', '' ], + 'Customer comments' => [ $fsurl.'misc/cust_main_note-import.html', '' ], + 'One-time charges' => [ $fsurl.'misc/cust_main-import_charges.cgi', '' ], + 'Payments' => [ $fsurl.'misc/cust_pay-import.cgi', '' ], + 'Credits' => [ $fsurl.'misc/cust_credit-import.html', '' ], 'Phone numbers (DIDs)' => [ $fsurl.'misc/phone_avail-import.html', '' ], 'Call Detail Records (CDRs)' => [ $fsurl.'misc/cdr-import.html', '' ], ; diff --git a/httemplate/misc/cust_pkg-import.html b/httemplate/misc/cust_pkg-import.html index 94e7dd926..e0c0c7ff4 100644 --- a/httemplate/misc/cust_pkg-import.html +++ b/httemplate/misc/cust_pkg-import.html @@ -1,6 +1,6 @@ -<% include("/elements/header.html",'Batch Package Import') %> +<& /elements/header.html, 'Customer package import' &> -Import a file containing package records. +Import a file containing customer packages.

<& /elements/form-file_upload.html, @@ -8,19 +8,18 @@ Import a file containing package records. 'action' => 'process/cust_pkg-import.html', 'num_files' => 1, 'fields' => [ 'agentnum', 'pkgbatch', 'format' ], - 'message' => 'Package import successful', + 'message' => 'Customer package import successful', 'url' => $p."search/cust_pkg.cgi?pkgbatch=$pkgbatch", 'onsubmit' => "document.PackageImportForm.submitButton.disabled=true;" &> <% &ntable("#cccccc", 2) %> - <% include( '/elements/tr-select-agent.html', - #'curr_value' => '', #$agentnum, - 'label' => "Agent", - 'empty_label' => 'Select agent', - ) - %> + <& /elements/tr-select-agent.html, + #'curr_value' => '', #$agentnum, + 'label' => "Agent", + 'empty_label' => 'Select agent', + &> @@ -43,11 +42,10 @@ Import a file containing package records. - <% include( '/elements/file-upload.html', - 'field' => 'file', - 'label' => 'Filename', - ) - %> + <& /elements/file-upload.html, + 'field' => 'file', + 'label' => 'Filename', + &> @@ -171,7 +169,7 @@ Field information:
-<% include('/elements/footer.html') %> +<& /elements/footer.html &> <%once> diff --git a/httemplate/misc/part_pkg-import.html b/httemplate/misc/part_pkg-import.html new file mode 100644 index 000000000..aed734aac --- /dev/null +++ b/httemplate/misc/part_pkg-import.html @@ -0,0 +1,116 @@ +<& /elements/header.html, 'Import package definitions' &> + +Import a file containing package definitions. +

+ +<& /elements/form-file_upload.html, + 'name' => 'PackageDefImportForm', + 'action' => 'process/part_pkg-import.html', + 'num_files' => 1, + 'fields' => [ 'agentnum', 'pkgpartbatch', 'format' ], + 'message' => 'Package definition import successful', + 'url' => $p."browse/part_pkg.cgi?pkgpartbatch=$pkgpartbatch", + 'onsubmit' => "document.PackageDefImportForm.submitButton.disabled=true;" +&> + +<% &ntable("#cccccc", 2) %> + + <& /elements/tr-select-agent.html, + #'curr_value' => '', #$agentnum, + 'label' => "Agent", + + 'disable_empty' => 1, + #this doesn't work yet, no type_pkgs records are inserted + #'empty_label' => '(global)', + + #disable_empty => ! $acl_edit_global, + &> + + + + + + Format + + + + + + <& /elements/file-upload.html, + 'field' => 'file', + 'label' => 'Filename', + &> + + + + + + + + + + + +
+Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets. The file should have a .CSV or .XLS extension. +

+ +Default format has the following field order: agent_pkgpartid, pkg<%$req%>, comment<%$req%>, freq<%$req%>, plan<%$req%>, setup_fee<%$req%>, recur_fee<%$req%>, setup_cost, recur_cost, classnum, taxclass + +

+ +<%$req%> Required fields +

+ +Field information: + + + +
+ +<& /elements/footer.html &> + +<%once> + +my $req = qq!*!; + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Import'); + +my $pkgpartbatch = + time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time); + + diff --git a/httemplate/misc/process/part_pkg-import.html b/httemplate/misc/process/part_pkg-import.html new file mode 100644 index 000000000..f951a21c3 --- /dev/null +++ b/httemplate/misc/process/part_pkg-import.html @@ -0,0 +1,10 @@ +<% $server->process %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Import'); + +my $server = + new FS::UI::Web::JSRPC 'FS::part_pkg::Import::process_batch_import', $cgi; + + -- cgit v1.2.1