diff options
author | ivan <ivan> | 2010-10-14 01:14:27 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-10-14 01:14:27 +0000 |
commit | 7bbe939d139be7edd77378cfc9a2c3ec6287749d (patch) | |
tree | 4c43f97b729880ae191cc630d9402b843ca76870 /httemplate | |
parent | f839709351aee1f9488e9a26496adc564aa5b8e5 (diff) |
more contact work and preliminary business card upload
Diffstat (limited to 'httemplate')
-rw-r--r-- | httemplate/edit/process/prospect_main.html | 7 | ||||
-rw-r--r-- | httemplate/edit/prospect_main-ocr.html | 86 | ||||
-rw-r--r-- | httemplate/edit/prospect_main-upload.html | 7 | ||||
-rw-r--r-- | httemplate/edit/prospect_main.html | 44 | ||||
-rw-r--r-- | httemplate/elements/contact.html | 55 | ||||
-rw-r--r-- | httemplate/elements/menu.html | 4 | ||||
-rw-r--r-- | httemplate/view/image.cgi | 31 |
7 files changed, 224 insertions, 10 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' => ' ', }, '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 ) = @_; diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html index a7a33b1f0..eea3694e3 100644 --- a/httemplate/elements/contact.html +++ b/httemplate/elements/contact.html @@ -5,12 +5,38 @@ <TABLE> <TR> % foreach my $field ( @fields ) { +% +% my $value = ''; +% if ( $field =~ /^phonetypenum(\d+)$/ ) { +% my $contact_phone = qsearchs('contact_phone', { +% 'contactnum' => $curr_value, +% 'phonetypenum' => $1, +% }); +% if ( $contact_phone ) { +% $value = $contact_phone->phonenum; +% $value .= 'x'.$contact_phone->extension +% if $contact_phone->extension; +% $value = '+'. $contact_phone->countrycode. " $value" +% if $contact_phone->countrycode +% && $contact_phone->countrycode ne '1'; +% } +% } elsif ( $field eq 'emailaddress' ) { +% #XXX multiple not yet supported +% my $contact_email = qsearchs('contact_email', { +% 'contactnum' => $curr_value, +% }); +% $value = $contact_email->emailaddress if $contact_email; +% } else { +% $value = $contact->get($field); +% } + <TD> - <INPUT TYPE = "text" - NAME = "<%$name%>_<%$field%>" - ID = "<%$id%>_<%$field%>" + <INPUT TYPE = "text" + NAME = "<%$name%>_<%$field%>" + ID = "<%$id%>_<%$field%>" + SIZE = "<% $size{$field} || 15 %>" VALUE = "<% scalar($cgi->param($name."_$field")) - || $contact->get($field) |h %>" + || $value |h %>" <% $onchange %> ><BR> <FONT SIZE="-1"><% $label{$field} %></FONT> @@ -45,12 +71,25 @@ if ( $curr_value ) { $contact = new FS::contact {}; } +my %size = ( 'title' => 12 ); + tie my %label, 'Tie::IxHash', - 'first' => 'First name', - 'last' => 'Last name', - 'title' => 'Title/Position', - 'comment' => 'Comment', + 'first' => 'First name', + 'last' => 'Last name', + 'title' => 'Title/Position', + 'emailaddress' => 'Email', ; + +my $first = 0; +foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) { + next if $phone_type->typename eq 'Home'; + my $f = 'phonetypenum'.$phone_type->phonetypenum; + $label{$f} = $phone_type->typename. ' phone'; + $size{$f} = $first++ ? 11 : 15; +} + +$label{'comment'} = 'Comment'; + my @fields = keys %label; </%init> diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 09b8e7405..cc52aaef8 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -364,11 +364,13 @@ $tools_menu{'Process payment batches'} = [ $fsurl.'search/pay_batch.cgi?magic=_d if ( $conf->exists('batch-enable') || $conf->config('batch-enable_payby') ) && $curuser->access_right('Process batches'); $tools_menu{'Process invoice batches'} = [ $fsurl.'search/bill_batch.cgi' ] - if ( $conf->exists('invoice_print_pdf') ); + if $conf->exists('invoice_print_pdf'); $tools_menu{'Job Queue'} = [ $fsurl.'search/queue.html', 'View pending job queue' ] if $curuser->access_right('Job queue'); $tools_menu{'Ticketing'} = [ \%tools_ticketing, 'Ticketing tools' ] if $conf->config('ticket_system'); +$tools_menu{'Business card scan'} = [ $fsurl.'edit/prospect_main-upload.html' ] + if $curuser->access_right('New prospect'); $tools_menu{'Time Queue'} = [ $fsurl.'search/report_timeworked.html', 'View pending support time' ] if $curuser->access_right('Time queue'); $tools_menu{'Attachments'} = [ $fsurl.'browse/cust_attachment.html', 'View customer attachments' ] diff --git a/httemplate/view/image.cgi b/httemplate/view/image.cgi new file mode 100644 index 000000000..153ec858e --- /dev/null +++ b/httemplate/view/image.cgi @@ -0,0 +1,31 @@ +<% $data %>\ +<%init> + +#die "access denied" +# unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $conf = new FS::Conf; + +my $type; +if ( $cgi->param('type') eq 'png' ) { + $type = 'png'; +} elsif ( $cgi->param('type') eq 'eps' ) { + $type = 'eps'; +} else { + die "unknown image type ". $cgi->param('type'); +} + +my $data; +if ( $cgi->param('prefname') =~ /^(\w+)$/ ) { + + my $prefname = $1; + my $curuser = $FS::CurrentUser::CurrentUser; + $data = decode_base64( $curuser->option("$prefname") ); + +} else { + die "no preview_session specified"; +} + +http_header('Content-Type' => 'image/png' ); + +</%init> |