default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / httemplate / edit / prospect_main-ocr.html
1 <%  include("/elements/header.html", 'Upload business card' ) %>
2
3 % if ( $error ) { 
4   <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
5   <BR><BR>
6 % } else {
7
8     <FORM ACTION="prospect_main.html" METHOD="POST">
9     <INPUT TYPE="hidden" NAME="session" VALUE="<% $session %>">
10
11     <TABLE>
12
13 %   my $num = 0;
14 %   foreach my $line ( @lines ) { 
15       <TR>
16         <TD>
17           <INPUT TYPE="hidden" NAME="val<%$num%>" VALUE="<% $line |h %>">
18           <SELECT NAME="sel<%$num%>">
19             <OPTION VALUE="">
20             <OPTION VALUE="name">Name
21             <OPTION VALUE="contactnum0_title">Title
22             <OPTION VALUE="company">Company
23             <OPTION VALUE="contactnum0_emailaddress">Email
24             <OPTION VALUE="address1">Address (1)
25             <OPTION VALUE="address2">Address (2)
26             <OPTION VALUE="city_state_zip">City, State, Zip
27 %           my @phone_types = qsearch({table=>'phone_type',order_by=>'weight'});
28 %           foreach my $phone_type ( @phone_types ) {
29 %             next if $phone_type->typename eq 'Home';
30               <OPTION VALUE="contactnum0_phonetypenum<% $phone_type->phonetypenum %>"><% $phone_type->typename |h %> phone
31 %           }
32             <OPTION VALUE="contactnum0_comment">Comment
33           </SELECT>
34         </TD>
35         <TD><% $line %></TD>
36
37 %       unless ( $num++) {
38
39           <TD ROWSPAN="9999"><IMG SRC="<%$p%>view/image.cgi?type=png;prefname=bizcard<%$session%>" WIDTH=604 HEIGHT=328></IMG></TD>
40
41 %       }
42
43       </TR>
44 %   }
45
46     </TABLE>
47
48     <BR>
49     <INPUT TYPE="submit" VALUE="Create prospect">
50
51 % }
52 <% include('/elements/footer.html') %>
53 <%init>
54
55 my $fh = $cgi->upload('card');
56
57 my $error = '';
58 my @lines = ();
59 my $session = '';
60 if ( defined $fh ) {
61
62   local $/;
63   my $logo_data = <$fh>;
64
65   $session = int(rand(4294967296)); #XXX
66   my $pref = new FS::access_user_pref({
67     'usernum'    => $FS::CurrentUser::CurrentUser->usernum,
68     'prefname'   => "bizcard$session",
69     'prefvalue'  => encode_base64($logo_data),
70     'expiration' => time + 3600, #1h?  1m?
71   });
72   my $pref_error = $pref->insert;
73   if ( $pref_error ) {
74     die "FATAL: couldn't set preview cookie: $pref_error\n";
75   }
76
77   @lines = eval { ocr_image($logo_data); };
78   $error = $@ if $error;
79
80 } else {
81
82   $error = 'No file uploaded';
83
84 }
85
86 </%init>