[ic] Order prefix

Jim Balcom interchange-users@lists.akopia.com
Thu Aug 2 21:18:00 2001


On Thu, 2 Aug 2001, Mike Heins wrote:

MH>>This is a great idea!

It is.

It means that order numbers now have the date in front of the actual
number, and when a customer calls with a question, or a complaint that I
have a much better idea of where to start looking to research his
answer!

It's got to be one of the best ideas that has popped up on this list in
a long time!

Repeating it:

MH>>#!/usr/bin/perl -w
MH>>
MH>># reset_order_number -- date-based order numbers for Interchange
MH>>
MH>># From an idea posted to the interchange-users@ic.redhat.com
MH>># mail list by Leon Harris <leon@quoll.com>
MH>>
MH>># Place in crontab with 
MH>># 
MH>># 0 0 * * * /path/to/reset_order_number /path/to/catalog_dir
MH>>
MH>>use Fcntl qw/:flock/;
MH>>use POSIX qw/strftime/;
MH>>
MH>>my $dir = shift 
MH>>	or die "usage: $0 <catalog-directory-or-counter-file>\n";
MH>>
MH>>my $fn;
MH>>
MH>>if (-f $dir) {
MH>>	$fn = $dir;
MH>>}
MH>>else {
MH>>	$fn = "$dir/etc/order.number";
MH>>}
MH>>
MH>>open ON, "+<$fn"
MH>>	or die "open $fn: $!\n";
MH>>
MH>>flock    ON, LOCK_EX	or die "lock $fn: $!\n";
MH>>seek     ON, 0, 0       or die "seek $fn: $!\n";
MH>>truncate ON, 0          or die "truncate $fn: $!\n";
MH>>
MH>>print    ON  strftime("%Y%m%d0000\n", localtime() );
MH>>
MH>>close    ON             or die "close $fn: $!\n";
MH>>
MH>>__END__


-= Jim =-

----------------------------------------------------------------
Jim's Linux-Operated Underground Bomb Shelter

Tagline for Thursday, August 02, 2001 at 21:15 PM:
Never eat prunes when you're famished.

----------------------------------------------------------------
This Linux System has been up 578 hours  

My web page: http://www.idk-enterprises.com
----------------------------------------------------------------