I have a sales report that will give me the totals for any given time, week ,event or any other search. Below is the code I use
for this.
////////Code/////////
sub html_sales_report {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
my (%rec) = @_;
print qq|
<TD>$rec{'Promotion'}</TD><TD>$rec{'Pdate'}</TD><TD>$rec{'Userid'}</TD><td>$rec{'Amount'}|;
if ($rec{'Bump'} =~ "Yes") {
print qq| <font color="red"> Bump</font></td>|;
}
print qq|
</td>
<TD>$rec{'Bump'}</TD><TD>$rec{'Collected_date'}</TD><TD>$rec{'Week'}</TD><TD>$rec{'Memorabilia'}</TD><TD>$rec{'Payment'}</TD><TD>$rec{'Tap'}</TD><TD><a HREF="$db_script_www/cgi-bin/master/db.cgi?db=default&uid=$in{'uid'}&ID2=&Date=&Company=$rec{'Company'}&keyword=&mh=10&sb=---&so=ascend&view_records=1" target="_blank">$rec{'Company'}</a></TD><TD>$rec{'Special_Inst'}</TD> |;
$total_field = $rec{'Amount'};
$total_field =~ s/\$//./,/gi;
$Pagetotal += $total_field;
}
////////Code/////////
The question I have is. How can I have it sort by "Userid" (Sales Rep) and give the totals for each Userid?
I'm looking for something like this:
Softball 2016 bgoldman $200.00 02/12/2016 03 Pick Up Tap Lewis Animal Hospital
Softball 2016 bgoldman $200.00 02/12/2016 03 Pick Up Tap James W Smith & Sons
Softball 2016 bgoldman $100.00 02/12/2016 03 Pick Up Tap Gumbo's Lawn & Landscape
Softball 2016 bgoldman $100.00 02/12/2016 03 Pick Up New Friends of Charity
Total $600.00
Softball 2016 elevy $200.00 02/12/2016 03 Credit Card Tap Driving School
Softball 2016 elevy $100.00 02/12/2016 03 Pick Up Tap Premiere Electric
Softball 2016 elevy $100.00 02/12/2016 03 Pick Up Tap Superbowl Bellewood
Softball 2016 elevy $200.00 02/12/2016 03 Pick Up Tap G.F. Frank & Sons
Softball 2016 elevy $600.00 02/12/2016 03 Credit Card Tap Louiso Trucking
Total $1200.00
I found this code that totals hours for each person, and it has a layout like I need, but I could not get it to work right.
I changed 'Name' to 'Userid' and 'Hours' to 'Amount'. Then I inserted this in the code above.
/////code/////
In sub html_record, before you print out your results, add code: if ($rec{'Name'} eq $PreviousName) { $subtotal += $rec{'Hours'}; } else { if ($subtotal) { print qq|-----------------<BR>$subtotal|; } $subtotal = $rec{'Hours'}; $PreviousName = $rec{'Name'}; }
/////code/////
The two codes looked like this:
////////Code/////////
sub html_sales_report {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
my (%rec) = @_;
print qq|
<TD>$rec{'Promotion'}</TD><TD>$rec{'Pdate'}</TD><TD>$rec{'Userid'}</TD><td>$rec{'Amount'}|;
if ($rec{'Bump'} =~ "Yes") {
print qq| <font color="red"> Bump</font></td>|;
}
print qq|
</td>
<TD>$rec{'Bump'}</TD><TD>$rec{'Collected_date'}</TD><TD>$rec{'Week'}</TD><TD>$rec{'Memorabilia'}</TD><TD>$rec{'Payment'}</TD><TD>$rec{'Tap'}</TD><TD><a HREF="$db_script_www/cgi-bin/master/db.cgi?db=default&uid=$in{'uid'}&ID2=&Date=&Company=$rec{'Company'}&keyword=&mh=10&sb=---&so=ascend&view_records=1" target="_blank">$rec{'Company'}</a></TD><TD>$rec{'Special_Inst'}</TD> |;
if ($rec{'Userid'} eq $PreviousName) { $subtotal += $rec{'Amount'}; } else { if ($subtotal) { print qq|-----------------<BR>$subtotal|; } $subtotal = $rec{'Amount'}; $PreviousName = $rec{'Userid'}; }
$total_field = $rec{'Amount'};
$total_field =~ s/\$//./,/gi;
$Pagetotal += $total_field;
}
////////Code/////////
The layout I'm ok with, its getting it to sort then the totals for each Sales Rep I'm having trouble with.
Any ideals?
Thank you,
Ed-
for this.
////////Code/////////
sub html_sales_report {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
my (%rec) = @_;
print qq|
<TD>$rec{'Promotion'}</TD><TD>$rec{'Pdate'}</TD><TD>$rec{'Userid'}</TD><td>$rec{'Amount'}|;
if ($rec{'Bump'} =~ "Yes") {
print qq| <font color="red"> Bump</font></td>|;
}
print qq|
</td>
<TD>$rec{'Bump'}</TD><TD>$rec{'Collected_date'}</TD><TD>$rec{'Week'}</TD><TD>$rec{'Memorabilia'}</TD><TD>$rec{'Payment'}</TD><TD>$rec{'Tap'}</TD><TD><a HREF="$db_script_www/cgi-bin/master/db.cgi?db=default&uid=$in{'uid'}&ID2=&Date=&Company=$rec{'Company'}&keyword=&mh=10&sb=---&so=ascend&view_records=1" target="_blank">$rec{'Company'}</a></TD><TD>$rec{'Special_Inst'}</TD> |;
$total_field = $rec{'Amount'};
$total_field =~ s/\$//./,/gi;
$Pagetotal += $total_field;
}
////////Code/////////
The question I have is. How can I have it sort by "Userid" (Sales Rep) and give the totals for each Userid?
I'm looking for something like this:
Softball 2016 bgoldman $200.00 02/12/2016 03 Pick Up Tap Lewis Animal Hospital
Softball 2016 bgoldman $200.00 02/12/2016 03 Pick Up Tap James W Smith & Sons
Softball 2016 bgoldman $100.00 02/12/2016 03 Pick Up Tap Gumbo's Lawn & Landscape
Softball 2016 bgoldman $100.00 02/12/2016 03 Pick Up New Friends of Charity
Total $600.00
Softball 2016 elevy $200.00 02/12/2016 03 Credit Card Tap Driving School
Softball 2016 elevy $100.00 02/12/2016 03 Pick Up Tap Premiere Electric
Softball 2016 elevy $100.00 02/12/2016 03 Pick Up Tap Superbowl Bellewood
Softball 2016 elevy $200.00 02/12/2016 03 Pick Up Tap G.F. Frank & Sons
Softball 2016 elevy $600.00 02/12/2016 03 Credit Card Tap Louiso Trucking
Total $1200.00
I found this code that totals hours for each person, and it has a layout like I need, but I could not get it to work right.
I changed 'Name' to 'Userid' and 'Hours' to 'Amount'. Then I inserted this in the code above.
/////code/////
In sub html_record, before you print out your results, add code: if ($rec{'Name'} eq $PreviousName) { $subtotal += $rec{'Hours'}; } else { if ($subtotal) { print qq|-----------------<BR>$subtotal|; } $subtotal = $rec{'Hours'}; $PreviousName = $rec{'Name'}; }
/////code/////
The two codes looked like this:
////////Code/////////
sub html_sales_report {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.
my (%rec) = @_;
print qq|
<TD>$rec{'Promotion'}</TD><TD>$rec{'Pdate'}</TD><TD>$rec{'Userid'}</TD><td>$rec{'Amount'}|;
if ($rec{'Bump'} =~ "Yes") {
print qq| <font color="red"> Bump</font></td>|;
}
print qq|
</td>
<TD>$rec{'Bump'}</TD><TD>$rec{'Collected_date'}</TD><TD>$rec{'Week'}</TD><TD>$rec{'Memorabilia'}</TD><TD>$rec{'Payment'}</TD><TD>$rec{'Tap'}</TD><TD><a HREF="$db_script_www/cgi-bin/master/db.cgi?db=default&uid=$in{'uid'}&ID2=&Date=&Company=$rec{'Company'}&keyword=&mh=10&sb=---&so=ascend&view_records=1" target="_blank">$rec{'Company'}</a></TD><TD>$rec{'Special_Inst'}</TD> |;
if ($rec{'Userid'} eq $PreviousName) { $subtotal += $rec{'Amount'}; } else { if ($subtotal) { print qq|-----------------<BR>$subtotal|; } $subtotal = $rec{'Amount'}; $PreviousName = $rec{'Userid'}; }
$total_field = $rec{'Amount'};
$total_field =~ s/\$//./,/gi;
$Pagetotal += $total_field;
}
////////Code/////////
The layout I'm ok with, its getting it to sort then the totals for each Sales Rep I'm having trouble with.
Any ideals?
Thank you,
Ed-