package web import from CSV/XLS, RT#9529
[freeside.git] / httemplate / misc / cust_pkg-import.html
1 <% include("/elements/header.html",'Batch Package Import') %>
2
3 Import a file containing package records.
4 <BR><BR>
5
6 <% include( '/elements/form-file_upload.html',
7               'name'      => 'PackageImportForm',
8               'action'    => 'process/cust_pkg-import.html',
9               'num_files' => 1,
10               'fields'    => [ 'agentnum', 'pkgbatch', 'format' ],
11               'message'   => 'Package import successful',
12               'url'       => $p."search/cust_pkg.cgi?pkgbatch=$pkgbatch",
13           )
14 %>
15
16 <% &ntable("#cccccc", 2) %>
17
18   <% include( '/elements/tr-select-agent.html',
19                  #'curr_value' => '', #$agentnum,
20                  'label'       => "<B>Agent</B>",
21                  'empty_label' => 'Select agent',
22              )
23   %>
24
25   <INPUT TYPE="hidden" NAME="pkgbatch" VALUE="<% $pkgbatch %>"%>
26
27   <TR>
28     <TH ALIGN="right">Format</TH>
29     <TD>
30       <SELECT NAME="format">
31         <OPTION VALUE="default" SELECTED>Default
32         <OPTION VALUE="default-agent_custid">Default with agent_custid
33         <OPTION VALUE="svc_acct">Account service
34         <OPTION VALUE="svc_acct-agent_custid">Account service with agent_custid
35         <OPTION VALUE="svc_phone">Phone service
36         <OPTION VALUE="svc_phone-agent_custid">Phone service with agent_custid
37         <OPTION VALUE="svc_external">External service
38         <OPTION VALUE="svc_external-agent_custid">External service with agent_custid
39       </SELECT>
40     </TD>
41   </TR>
42
43   <% include( '/elements/file-upload.html',
44                 'field' => 'file',
45                 'label' => 'Filename',
46             )
47   %>
48
49   <TR>
50     <TD COLSPAN=2 ALIGN="center" STYLE="padding-top:6px">
51       <INPUT TYPE    = "submit"
52              ID      = "submit"
53              VALUE   = "Import file"
54              onClick = "document.PackageImportForm.submit.disabled=true;"
55       >
56     </TD>
57   </TR>
58
59 </TABLE>
60
61 </FORM>
62
63 <BR>
64 Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.  The file should have a .CSV or .XLS extension.
65 <BR><BR>
66
67 <b>Default</b> format has the following field order: <i>custnum<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire</i>
68 <BR><BR>
69
70 <b>Default with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire</i>
71 <BR><BR>
72
73 <b>Account service</b> format has the following field order: <i>custnum<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, username, _password</i>
74 <BR><BR>
75
76 <b>Account service with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, username, _password</i>
77 <BR><BR>
78
79 <b>Phone sevice</b> format has the following field order: <i>custnum<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, countrycode, phonenum, sip_password, pin</i>
80 <BR><BR>
81
82 <b>Phone service with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, countrycode, phonenum, sip_password, pin</i>
83 <BR><BR>
84
85 <b>External sevice</b> format has the following field order: <i>custnum<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, id, title</i>
86 <BR><BR>
87
88 <b>External service with agent_custid</b> format has the following field order: <i>agent_custid<%$req%>, pkgpart<%$req%>, discountnum, start_date, setup, bill, last_bill, susp, adjourn, cancel, expire, id, title</i>
89 <BR><BR>
90
91 <%$req%> Required fields
92 <BR><BR>
93
94 Field information:
95
96 <ul>
97
98   <li><i>custnum</i>: This specifies an existing customer by custnum.
99
100   <li><i>agent_custid</i>: This specifies an existing customer record by agent_custid.
101
102   <li><i>pkgpart</i>: Package definition.  Configuration -&gt; Packages -&gt; Package definitions
103
104   <li><i>pkgpart</i>: Optional discount.  Configuration -&gt; Packages -&gt; Discounts
105
106 <!--
107   <li><i>username</i> and <i>_password</i> are required if <i>pkgpart</i> is specified. (Extended and Extended plus company formats)
108 -->
109
110   <li><i>id</i>: External service id, integer
111
112   <li><i>title</i>: External service identifier, text
113
114 </ul>
115
116 <BR>
117
118 <% include('/elements/footer.html') %>
119
120 <%once>
121
122 my $req = qq!<font color="#ff0000">*</font>!;
123
124 </%once>
125 <%init>
126
127 die "access denied"
128   unless $FS::CurrentUser::CurrentUser->access_right('Import');
129
130 my $pkgbatch = time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);
131
132 </%init>