summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorivan <ivan>2010-10-14 01:14:27 +0000
committerivan <ivan>2010-10-14 01:14:27 +0000
commit7bbe939d139be7edd77378cfc9a2c3ec6287749d (patch)
tree4c43f97b729880ae191cc630d9402b843ca76870 /httemplate/edit
parentf839709351aee1f9488e9a26496adc564aa5b8e5 (diff)
more contact work and preliminary business card upload
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/process/prospect_main.html7
-rw-r--r--httemplate/edit/prospect_main-ocr.html86
-rw-r--r--httemplate/edit/prospect_main-upload.html7
-rw-r--r--httemplate/edit/prospect_main.html44
4 files changed, 143 insertions, 1 deletions
diff --git a/httemplate/edit/process/prospect_main.html b/httemplate/edit/process/prospect_main.html
index 34d26421b..ca4dfabfe 100644
--- a/httemplate/edit/process/prospect_main.html
+++ b/httemplate/edit/process/prospect_main.html
@@ -4,7 +4,7 @@
'agent_virt' => 1,
'process_o2m' => {
'table' => 'contact',
- 'fields' => [qw( first last title comment )],
+ 'fields' => \@contact_fields,
},
'redirect' => popurl(3). 'view/prospect_main.html?',
)
@@ -31,4 +31,9 @@ my $args_callback = sub {
};
+my @contact_fields = qw( first last title comment emailaddress );
+foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
+ push @contact_fields, 'phonetypenum'.$phone_type->phonetypenum;
+}
+
</%init>
diff --git a/httemplate/edit/prospect_main-ocr.html b/httemplate/edit/prospect_main-ocr.html
new file mode 100644
index 000000000..41fc4c105
--- /dev/null
+++ b/httemplate/edit/prospect_main-ocr.html
@@ -0,0 +1,86 @@
+<% include("/elements/header.html", 'Upload business card' ) %>
+
+% if ( $error ) {
+ <FONT SIZE="+1" COLOR="#ff0000">Error: <% $error %></FONT>
+ <BR><BR>
+% } else {
+
+ <FORM ACTION="prospect_main.html" METHOD="POST">
+ <INPUT TYPE="hidden" NAME="session" VALUE="<% $session %>">
+
+ <TABLE>
+
+% my $num = 0;
+% foreach my $line ( @lines ) {
+ <TR>
+ <TD>
+ <INPUT TYPE="hidden" NAME="val<%$num%>" VALUE="<% $line |h %>">
+ <SELECT NAME="sel<%$num%>">
+ <OPTION VALUE="">
+ <OPTION VALUE="name">Name
+ <OPTION VALUE="contactnum0_title">Title
+ <OPTION VALUE="company">Company
+ <OPTION VALUE="contactnum0_emailaddress">Email
+ <OPTION VALUE="address1">Address (1)
+ <OPTION VALUE="address2">Address (2)
+ <OPTION VALUE="city_state_zip">City, State, Zip
+% my @phone_types = qsearch({table=>'phone_type',order_by=>'weight'});
+% foreach my $phone_type ( @phone_types ) {
+% next if $phone_type->typename eq 'Home';
+ <OPTION VALUE="contactnum0_phonetypenum<% $phone_type->phonetypenum %>"><% $phone_type->typename |h %> phone
+% }
+ <OPTION VALUE="contactnum0_comment">Comment
+ </SELECT>
+ </TD>
+ <TD><% $line %></TD>
+
+% unless ( $num++) {
+
+ <TD ROWSPAN="9999"><IMG SRC="<%$p%>view/image.cgi?type=png;prefname=bizcard<%$session%>" WIDTH=604 HEIGHT=328></IMG></TD>
+
+% }
+
+ </TR>
+% }
+
+ </TABLE>
+
+ <BR>
+ <INPUT TYPE="submit" VALUE="Create prospect">
+
+% }
+<% include('/elements/footer.html') %>
+<%init>
+
+my $fh = $cgi->upload('card');
+
+my $error = '';
+my @lines = ();
+my $session = '';
+if ( defined $fh ) {
+
+ local $/;
+ my $logo_data = <$fh>;
+
+ $session = int(rand(4294967296)); #XXX
+ my $pref = new FS::access_user_pref({
+ 'usernum' => $FS::CurrentUser::CurrentUser->usernum,
+ 'prefname' => "bizcard$session",
+ 'prefvalue' => encode_base64($logo_data),
+ 'expiration' => time + 3600, #1h? 1m?
+ });
+ my $pref_error = $pref->insert;
+ if ( $pref_error ) {
+ die "FATAL: couldn't set preview cookie: $pref_error\n";
+ }
+
+ @lines = eval { ocr_image($logo_data); };
+ $error = $@ if $error;
+
+} else {
+
+ $error = 'No file uploaded';
+
+}
+
+</%init>
diff --git a/httemplate/edit/prospect_main-upload.html b/httemplate/edit/prospect_main-upload.html
new file mode 100644
index 000000000..24b1caa4c
--- /dev/null
+++ b/httemplate/edit/prospect_main-upload.html
@@ -0,0 +1,7 @@
+<% include("/elements/header.html", 'Upload business card' ) %>
+
+ <FORM ACTION="prospect_main-ocr.html" METHOD="POST" ENCTYPE="multipart/form-data">
+ <INPUT TYPE="file" NAME="card">
+ <BR><INPUT TYPE="submit" NAME="submit" VALUE="Upload">
+
+<% include('/elements/footer.html') %>
diff --git a/httemplate/edit/prospect_main.html b/httemplate/edit/prospect_main.html
index e867907ed..c260eb8e2 100644
--- a/httemplate/edit/prospect_main.html
+++ b/httemplate/edit/prospect_main.html
@@ -5,6 +5,7 @@
'agentnum' => 'Agent',
'company' => 'Company',
'contactnum' => 'Contact',
+ 'locationnum' => '&nbsp;',
},
'fields' => [
{ 'field' => 'agentnum',
@@ -34,6 +35,7 @@
'empty_label' => 'No address',
},
],
+ 'new_callback' => $new_callback,
'edit_callback' => $edit_callback,
'error_callbacck' => $error_callback,
'agent_virt' => 1,
@@ -62,6 +64,48 @@ if ( $cgi->param('error') ) {
}
+my $new_callback = sub {
+ my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
+
+ if ( $cgi->param('session') =~ /^(\w+)$/ ) {
+ my $session = $1;
+
+ #add a link to the image.cgi for this card
+ $opt_hashref->{'html_bottom'} .=
+ qq(<BR><IMG SRC="${p}view/image.cgi?type=png;prefname=bizcard$session" ).
+ ' WIDTH=604 HEIGHT=328><BR>';
+
+ #fill in the incoming params: name, address1/address2, city_state_zip
+ foreach my $param ( grep /^sel\d+$/, $cgi->param ) {
+ $param =~ /^sel(\d+)$/ or die 'again, wtf (daily)';
+ my $num = $1;
+ my $field = $cgi->param($param);
+ my $value = $cgi->param("val$num");
+ $cgi->param($field => $value);
+ }
+
+ if ( $cgi->param('company') ) {
+ $prospect_main->company( $cgi->param('company') );
+ }
+
+ if ( $cgi->param('name') =~ /^(.*\S+)\s+(\w+)\s*$/ ) {
+ $cgi->param('contactnum0_first' => $1);
+ $cgi->param('contactnum0_last' => $2);
+ }
+
+ if ( grep $cgi->param($_), qw( address1 address2 city_state_zip ) ) {
+ $cgi->param('locationnum', -1);
+ if ( $cgi->param('city_state_zip') =~ /^(\s*)([\w\s]+)[\., ]+(\w{2})[, ]+(\d{5}(-\d{4})?)/ ) {
+ $cgi->param('city' => $2);
+ $cgi->param('state' => $3);
+ $cgi->param('zip' => $4);
+ }
+ }
+
+ }
+
+};
+
my $edit_callback = sub {
#my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
my( $cgi, $prospect_main ) = @_;