[freeside-commits] freeside/httemplate/edit prospect_main.html, 1.4, 1.5 prospect_main-ocr.html, NONE, 1.1 prospect_main-upload.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Wed Oct 13 18:14:29 PDT 2010
- Previous message: [freeside-commits] freeside/FS/FS contact.pm, 1.1, 1.2 Mason.pm, 1.54, 1.55 Schema.pm, 1.237, 1.238 cust_main.pm, 1.562, 1.563 contact_phone.pm, 1.1, 1.2 Misc.pm, 1.41, 1.42
- Next message: [freeside-commits] freeside/httemplate/edit/process prospect_main.html, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/httemplate/edit
In directory wavetail.420.am:/tmp/cvs-serv4104/httemplate/edit
Modified Files:
prospect_main.html
Added Files:
prospect_main-ocr.html prospect_main-upload.html
Log Message:
more contact work and preliminary business card upload
--- NEW FILE: prospect_main-upload.html ---
<% 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') %>
--- NEW FILE: prospect_main-ocr.html ---
<% 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>
Index: prospect_main.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/edit/prospect_main.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -d -r1.4 -r1.5
--- prospect_main.html 17 Jun 2010 02:08:52 -0000 1.4
+++ prospect_main.html 14 Oct 2010 01:14:27 -0000 1.5
@@ -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 @@
}
+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 ) = @_;
- Previous message: [freeside-commits] freeside/FS/FS contact.pm, 1.1, 1.2 Mason.pm, 1.54, 1.55 Schema.pm, 1.237, 1.238 cust_main.pm, 1.562, 1.563 contact_phone.pm, 1.1, 1.2 Misc.pm, 1.41, 1.42
- Next message: [freeside-commits] freeside/httemplate/edit/process prospect_main.html, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list