Hylafax Mailing List Archives
|
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
Re: [hylafax-users] Windows Faxing and Accounting Questions
> Are you using smbfax?
Not in production, but I have been evaluating/tweaking it for possible use in
production.
> Clear as mud :^)
>
> We bill a fixed charge per page. Each project has a id (job) number
> (3036, 2941 etc). All I need is some sort of system where a log is
> created with the date and time of each fax, the number of pages and the
> job number.
This is my suggestion:
Modify smbfax-html.pl to:
provide a text field for providing the client code along with the fax numbers
return the user to the form if they have not entered the client code
write to a log the client code and HylaFAX job id for each fax sent via smbfax
I've attached a patch for the changes that I made to smbfax-html.pl from
smbfax-1.4 to do these things.
At job submission time you do not have the number of pages in the fax available
to you. You won't have this until after the print job is coverted by HylaFAX.
So, you'll need to correlate this log of client code and job id with the
HylaFAX activity log. I noticed two obvious places to do this - the xferfaxlog
or the files in the doneq directory (both within the HylaFAX spool).
To do the correlation, you'll need to run something after the jobs are actually
sent to gather the number of pages and the date/time of each transmission. I've
also attached a small perl script to do that against the xferfaxlog. You'll
need to do this before you clean xferfaxlog, maybe once a day just after
midnight? The script outputs a listing of each fax containing the information
that you indicated you needed, as well as a summary of pages per client code if
that is at all useful to you.
I noticed a few things in putting this together that I'll note:
A job id can have more than one entry in xferfaxlog. For instance, I had a 30
page fax that the receiver did not accept all at once because it contained too
many pages. So, there is a second entry for the same job id for the remaining
pages. If you have continuation cover pages enabled, this means you might
charge your client for an extra cover page or two here and there. Not sure if
this matters that much or not to you.
You could be sending two faxes via smbfax at the same time so writing entries
to the clientjobs log file could result in munged data. If you think your
volume is high enough that this could really be a problem you should put some
file locking code into the smbfax-html.pl script around that log file append.
> Ideally I would log this in a MySQL database and auto generate a report
> for each billing period (I'll work on that later!).
So instead of printing each fax transmission in the perl script, you could do a
SQL insert at this point instead.
Hopefully this helps you...
Sam
--- smbfax-html Fri Sep 13 15:33:31 2002
+++ smbfax-html2 Thu Apr 10 10:21:07 2003
@@ -72,10 +72,10 @@
# Form has been filled out, now send fax
- if ($www->param('PhoneNumbers') =~ /\d/) {
+ if ($www->param('PhoneNumbers') =~ /\d/ && $www->param('ClientCode') =~ /^\d{4}$/) {
my ($phonestring, @phones, $feedback, $cover, $csender, $ccompany,
- $clocation, $cvoice, $ccomments, $identity, $cregarding);
+ $clocation, $cvoice, $ccomments, $identity, $cregarding,$clientcode);
# sanity checks
$phonestring = $www->param('PhoneNumbers');
@@ -83,6 +83,7 @@
@phones = split (/\n/, $phonestring);
$feedback = $www->param('Feedback');
$cover = $www->param('CoverRadio');
+ $clientcode = $www->param('ClientCode');
if ($cover eq 'User') {
$csender = $www->param('CoverSender');
$csender =~ s/[^A-Za-z\@\.\- ]+/ /g;
@@ -165,6 +166,26 @@
while (<KID>) {
push (@output, $_);
}
+
+ # now write the log to correlate the job and client ids
+ my ($jid, $str, $x);
+
+ foreach $x (@output) {
+ $str .= $x;
+ }
+
+ if($str =~ /request id is (\d+)/s) {
+ $jid = $1;
+ if(open LOG, ">>/tmp/clientjobs") {
+ print LOG "$clientcode $jid\n";
+ close LOG;
+ }
+ else {
+ print "<font color=red>Unable to record client code for this fax transmission - please notify your administrator</font><br><br>";
+ }
+ }
+ # else assume the job failed and there is no job id to record
+
print "<H1 DEFANGED_style="\"text-align:" center; DEFANGED_vertical-align: middle\">Fax sent</H1>\n";
print "Program output follows (in case of any errors):<p>\n";
print "<TT> @output </TT><p>\n";
@@ -321,7 +342,11 @@
print $www->textarea(-name => 'PhoneNumbers',
-rows => 10,
-columns => 40
- ) . "</TD></TR></TABLE>\n";
+ ) . "</TD></TR>\n";
+
+ print "<TR><TD>Client code " . $www->textfield(-name => 'ClientCode', -size => 4, -maxlength => 4) . "</TD></TR></TABLE>\n";
+
+
print "<LI><H3>Feedback options:</H3><p>\n";
print "<TABLE><TR><TD>\n";
print $www->radio_group (-name => 'Feedback',
#!/bin/sh
echo DEFANGED.25
exit
#!/bin/sh
echo DEFANGED.14676
exit
#!/bin/sh
echo DEFANGED.26
exit
#!/usr/bin/perl
(undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = localtime();
$mday--; # we're running for yesterday
$year += 1900;
$mon++;
$fn = '/tmp/clientjobs';
$newfn = sprintf "%s-%4d-%02d-%02d", $fn, $year, $mon, $mday;
$faxlog = '/var/spool/hylafax/etc/xferfaxlog';
rename $fn, $newfn or die "cannot rename $fn to $newfn\n";
open J, "<$newfn" or die "cannot open $newfn\n";
open L, "<$faxlog" or die "cannot open $faxlog\n";
while(<J>) {
chomp;
@temp = split/ /;
$jobs{$temp[1]} = $temp[0];
# get the client records ready
$clients{$temp[0]} = 0;
}
close J;
print "Jobs for $year-$mon-$mday\n\ncode pages date+time\n---- ----- ---------\n";
while(<L>) {
next if(/^$/); # my log starts with an empty line
chomp;
@temp = split/\t/;
foreach $x (keys %jobs) {
if($temp[4] eq $x) {
printf "%4d %5d %s\n", $jobs{$x}, $temp[10], $temp[0];
$clients{$jobs{$x}} += $temp[10];
# one job id may have > 1 entry
# last;
}
}
}
close L;
print "\n\nBilling Summary for $year-$mon-$mday\n\ncode pages\n---- -----\n";
foreach $x (keys %clients) {
print "$x $clients{$x}\n" if($clients{$x} > 0);
}