#-*-Perl-*- #register-initMachine-nicsample.txt #install with "update-sysStrings register-initMachine-default < register-initMachine-nicsample.txt" ############################################################################################# #there is a lot going on here, so I'll try to comment #this initMachine is for a nicregister with a Samsung SRP-350 usb thermal receipt printer #printer init first, as many other devices are chained off of it local *PrinterDev; open PrinterDev, ">/dev/lp0"; my $oldfh = select PrinterDev; $| = 1; select $oldfh; #put serial port setup here require LanePOS::Printers::Epson::TMT88; $printer = new TMT88 *PrinterDev; *printer2 = *printer; *pole = *printer; *drawer = *printer; #endorse is a printer alias *endorse = *printer; #this is the price table/fs/wic stuff @ptCount = (); $fsTotal = 0; $wicTotal = 0; #this is for the remote printer @remoteData = (); $useResetCode = 1; $resetCode = '$main::fsTotal = 0; $main::wicTotal = 0; $main::sizeAddOn = 0; #print the remote items if needed foreach my $dta (@main::remoteData) { local *RPrinter; use Socket; if(socket(RPrinter, PF_INET, SOCK_STREAM, getprotobyname("tcp"))) { ##################################################################################### # change the next line to match your setup (port 9101 and host coalfire) # ##################################################################################### if(connect(RPrinter, sockaddr_in(9101, inet_aton("coalfire")))) { require LanePOS::Printers::Epson::TMU375; my $remote; $remote = TMU375->new(*RPrinter); my $host = `/bin/hostname`; $host =~ /(.*)(\..*)(\..*)/; $host = $1; $remote->printFormatted("
Kitchen Printer
\n\n$dta\n" . $me->{"clerk"}{"name"} . "\@$host\nTicket: " . $me->{"sale"}{"id"} . "
\n" . $remote->{"codes"}{"ejectReceipt"}); close(RPrinter); } else { print STDERR "connect failed in remote print\n"; } } else { print STDERR "socket init failed in remote print\n"; } } @main::remoteData = (); '; $useExtProductCode = 1; $extProductCode = ' if(exists $me->{"prod"}->{"extended"}->{"pt"}) #this if is for price table support { &main::infoPrint("Only one price table item can be entered at a time.") if $qty > 1; $qty = 1; require LanePOS::PriceTable; my $pt = PriceTable->new(); print STDERR "error in pt->open\n" if !$pt->open($me->{"prod"}->{"extended"}->{"pt"}); $amt = $pt->price($ptCount[$me->{"prod"}->{"extended"}->{"pt"}]) * 100; $ptCount[$me->{"prod"}->{"extended"}->{"pt"}]++; $extPrice = $amt * $qty; } if(exists $me->{"prod"}->{"extended"}->{"fs"}) #this if is for foodstamp support { $main::fsTotal += $extPrice; &main::receiptPrint("foodstampable\n"); } if(exists $me->{"prod"}->{"extended"}->{"wic"}) #this if is for wic support { $main::wicTotal += $extPrice; &main::receiptPrint("wicable\n"); } if(exists $me->{"prod"}{"extended"}{"sized"}) #this and the next if are for size { #apply the size data #this only works if the id is an integer! $me->itemProcess($qty, $amt, int($id) + $main::sizeAddOn) if $main::sizeAddOn != 0; $main::sizeAddOn = 0; #sizes are popup return 0; #dont ring this item--the thing above will get the sized variant } if(exists $me->{"prod"}{"extended"}{"szcol"}) #this and the previous if are for size { $main::sizeAddOn = sprintf "%." . $me->{"prod"}{"extended"}{"szcol"} . "d", $sizeAddOn; substr $main::sizeAddOn, -$me->{"prod"}{"extended"}{"szcol"}, 1, $me->{"prod"}{"extended"}{"szset"}; return 0; #dont ring this thing either } if(exists $me->{"prod"}{"extended"}{"rprint"}) #this is for remote (kitchen/bar) printers { for(my $j = 1; $j <= $qty; $j++) { for(my $i = 0; 2 ** $i <= $me->{"prod"}{"extended"}{"rprint"}; $i++) { $main::remoteData[$i] .= sprintf("%-20.20s\n", $me->{"prod"}{"descr"}) if $me->{"prod"}{"extended"}{"rprint"} & (1 << $i); } } if($qty < 0) { for(my $j = 1; $j <= -$qty; $j++) { for(my $i = 0; 2 ** $i <= $me->{"prod"}{"extended"}{"rprint"}; $i++) { $main::remoteData[$i] .= sprintf("%-20.20s\n", "CANCEL " . $me->{"prod"}{"descr"}) if $me->{"prod"}{"extended"}{"rprint"} & (1 << $i); } } } } 1; ';