#!/usr/bin/perl -w use CGI qw(:all); ($disk, $_, $program)=$ENV{'SCRIPT_FILENAME'}=~/^(.{26})(.*\/)(.*)$/; $input = $disk.$_.'INPUT.txt'; $output = $disk.'INPUT.txt'; $separator="\t"; $FORMBG="#999999"; $FORMFG="#FFFFFF"; $FORM=qq~ style="background-color:$FORMBG;color:$FORMFG;border:2px solid #FFFFFF" onFocus="blur()"~; open(F, $input); @file=; close(F); if ($file[0]=~/^\w{3}\s/){@line=@file;chomp @line;} ####start CSV Build#### else{ @line=grep(/^\w{3}\s/, @file); @line=grep(!/^MFG/, @line); if ($line[0]=~/^\w{3}\s/){ foreach $text (@line){ @prod=split(//,$text); $text=""; $text.=join("", @prod[0..2]); $text.="$separator"; $text.=join("", @prod[4..10]); $text.="$separator"; $text.=join("", @prod[16..40]); $text.="$separator"; $text.=join("", @prod[41..43]); $text.="$separator"; $text.=join("", @prod[58..62]); $text.="$separator"; $text.=join("", @prod[49..53]); $text.="$separator"; $text.=join("", @prod[67..71]); $text.="$separator"; $text.=join("", @prod[85..89]); $text.="$separator"; $text.=join("", @prod[103..107]); $text.="$separator"; $text.=join("", @prod[121..125]); $text.="$separator"; } } } ####End CSV Build#### ####Start Search##### if (defined param('search')) {&search(param('PartNumber'))} sub search { #print "Content-type: text/html\n\n"; ($searchInput)=@_; @searchPart=split(",", $searchInput); @results=(); foreach $search (@searchPart) { for ($i=0;$i<@line;$i++) { if ($line[$i]=~m:$search:i) {$results[@results]=$i} } } $r=join(",",@results); print "Content-type: text/html\n\n
"; #print "
"; #foreach (@results) { # $line[$_]=~s:\t::g; # print "$line[$_]
"; #} #print "
"; #exit; } ####End Search#### if (defined param('record')) {$r=param('record');} else {$r=0;} if ($r>=@line) {$r=0;} if (defined param('new')) {$r=@line;} $p=$r-1; $n=$r+1; if ($r=~/,/) { @p=split(",", $r); $p=pop(@p); unshift(@p, $p); $p=join(",", @p); @n=split(",", $r); $n=shift(@n); push(@n, $n); $n=join(",", @n); ($rr)=split(",", $r); } if ($r<0) {$r=@line+$r;} ####Format: MFG,SKU,DES,UMC,LUC,RTL,NET,PR1,PR2,PR3#### if (!defined param('new')) { @item=split(/$separator/, "$line[$r]"); $mfg =$item[0]; $sku =$item[1]; $description=$item[2]; $umc =$item[3]; $cost =$item[4]; #cost-LUC $sel =$item[5]; #RTL $sel2 =$item[6]; #NET $sel3 =$item[7]; #SP3-PR1 $sel4 =$item[8]; #SP4-PR2 $sel5 =$item[9]; #SP5-PR3 @item=split(/$separator/, "$line[$p]"); $Pmfg =$item[0]; $Psku =$item[1]; $Pdescription=$item[2]; $Pumc =$item[3]; $Pcost =$item[4]; #cost-LUC $Psel =$item[5]; #RTL $Psel2 =$item[6]; #NET $Psel3 =$item[7]; #SP3-PR1 $Psel4 =$item[8]; #SP4-PR2 $Psel5 =$item[9]; #SP5-PR3 @item=split(/$separator/, "$line[$n]"); $Nmfg =$item[0]; $Nsku =$item[1]; $Ndescription=$item[2]; $Numc =$item[3]; $Ncost =$item[4]; #cost-LUC $Nsel =$item[5]; #RTL $Nsel2 =$item[6]; #NET $Nsel3 =$item[7]; #SP3-PR1 $Nsel4 =$item[8]; #SP4-PR2 $Nsel5 =$item[9]; #SP5-PR3 } ###Checkboxes### $gp2cal=""; $end9=""; ################ if (defined param('MFG')) {$mfg=param('MFG');} if (defined param('PartNumber')) {$sku=param('PartNumber');} if (defined param('Description')) {$description=param('Description');} if (defined param('UMC')) {$umc=param('UMC');} if (defined param('SP1')) {$sel=eval(param('SP1')); #if ($sel=~/\./) {} else {$sel=$sel/100;} } if (defined param('SP2')) {$sel2=eval(param('SP2')); #if ($sel2=~/\./) {} else {$sel2=$sel2/100;} } if (defined param('SP3')) {$sel3=eval(param('SP3')); #if ($sel3=~/\./) {} else {$sel3=$sel3/100;} } if (defined param('SP4')) {$sel4=eval(param('SP4')); #if ($sel4=~/\./) {} else {$sel4=$sel4/100;} } if (defined param('SP5')) {$sel5=eval(param('SP5')); #if ($sel5=~/\./) {} else {$sel5=$sel5/100;} } if (defined param('cost')) {$cost=eval(param('cost')); #if ($cost=~/\./) {} else {$cost=$cost/100;} } if (($cost%1==0 || $cost==1) && ($cost>1 || $cost==1) && $cost!~/\./) {$cost.=".00"} if (($sel%1 ==0 || $sel ==1) && ($sel >1 || $sel ==1) && $sel !~/\./) {$sel .=".00"} if (($sel2%1==0 || $sel2==1) && ($sel2>1 || $sel2==1) && $sel2!~/\./) {$sel2.=".00"} if (($sel3%1==0 || $sel3==1) && ($sel3>1 || $sel3==1) && $sel3!~/\./) {$sel3.=".00"} if (($sel4%1==0 || $sel4==1) && ($sel4>1 || $sel4==1) && $sel4!~/\./) {$sel4.=".00"} if (($sel5%1==0 || $sel5==1) && ($sel5>1 || $sel5==1) && $sel5!~/\./) {$sel5.=".00"} ###Start GP Calculation#### if ($Psel != 0){$Pgp1 =int(($Psel-$Pcost)/$Psel*100);} if ($Psel2 != 0){$Pgp2 =int(($Psel2-$Pcost)/$Psel2*100);} if ($Psel3 != 0){$Pgp3 =int(($Psel3-$Pcost)/$Psel3*100);} if ($Psel4 != 0){$Pgp4 =int(($Psel4-$Pcost)/$Psel4*100);} if ($Psel5 != 0){$Pgp5 =int(($Psel5-$Pcost)/$Psel5*100);} if ($sel != 0){$gp1 =int(($sel-$cost)/$sel*100);} if ($sel2 != 0){$gp2 =int(($sel2-$cost)/$sel2*100);} if ($sel3 != 0){$gp3 =int(($sel3-$cost)/$sel3*100);} if ($sel4 != 0){$gp4 =int(($sel4-$cost)/$sel4*100);} if ($sel5 != 0){$gp5 =int(($sel5-$cost)/$sel5*100);} if ($Nsel != 0){$Ngp1 =int(($Nsel-$Ncost)/$Nsel*100);} if ($Nsel2 != 0){$Ngp2 =int(($Nsel2-$Ncost)/$Nsel2*100);} if ($Nsel3 != 0){$Ngp3 =int(($Nsel3-$Ncost)/$Nsel3*100);} if ($Nsel4 != 0){$Ngp4 =int(($Nsel4-$Ncost)/$Nsel4*100);} if ($Nsel5 != 0){$Ngp5 =int(($Nsel5-$Ncost)/$Nsel5*100);} ####End GP Calculation###### if (defined param('gp2cal')) { $gp2cal="CHECKED"; $sel=int(($cost/(1-(eval(param('GPSP1'))/100)))*100)/100; $sel2=int(($cost/(1-(eval(param('GPSP2'))/100)))*100)/100; $sel3=int(($cost/(1-(eval(param('GPSP3'))/100)))*100)/100; $sel4=int(($cost/(1-(eval(param('GPSP4'))/100)))*100)/100; $sel5=int(($cost/(1-(eval(param('GPSP5'))/100)))*100)/100; $gp1=eval(param('GPSP1')); $gp2=eval(param('GPSP2')); $gp3=eval(param('GPSP3')); $gp4=eval(param('GPSP4')); $gp5=eval(param('GPSP5')); } if (defined param('end9')) { $end9="CHECKED"; $sel=(int($sel*10)+.9)/10; $sel2=(int($sel2*10)+.9)/10; $sel3=(int($sel3*10)+.9)/10; $sel4=(int($sel4*10)+.9)/10; $sel5=(int($sel5*10)+.9)/10; } ###START KEYBOARD SHORTCUT LAYOUT### sub keyb() { if (!defined param('search')) { if (!defined param('record') || param('record')==0) { $sku ="Z"; $sel ="Q"; $cost ="X"; $sel2 ="W"; $sel3 ="E"; $sel4 ="R"; $sel5 ="T"; $gp1 ="A"; $gp2 ="S"; $gp3 ="D"; $gp4 ="F"; $gp5 ="G"; $mfg =""; $description=""; $umc =""; } } } #&keyb(); ###END KEYBOARD SHORTCUT LAYOUT### ###NEW PART ENTRY### if (defined param('new')) { $line[@line]="$mfg\t$sku\t$description\t$umc\t$cost\t$sel\t$sel2\t$sel3\t$sel4\t$sel5"; } #################### ###File Writing format: MFG,SKU,DESCRIPTION,UMC,LUC,RTL,NET,PR1,PR2,PR3#### if (defined param('save') || defined param('new')) { $line[$r]="$mfg\t$sku\t$description\t$umc\t$cost\t$sel\t$sel2\t$sel3\t$sel4\t$sel5"; foreach (@line) {$_.="\n";} chomp $line[$#line]; open(WRITE , ">$output"); print WRITE @line; close(WRITE); } ###NEW PART RESUBMIT FOR PROPER RECORD NUMBER### if (defined param('new')) { print "Content-type: text/html\n\n
New Record # $#line "; } ################################################ print "Content-type: text/html\n\n"; print qq~ GizmoMike.com

GizmoMike.com

Previous RecordCurrent RecordNext Record
MFG:
Part Number:
Description:
U/M:

Pricing: GP %
Retail:
Net:
SP1:
SP2:
SP3:
 
LUC:
MFG:
Part Number:
Description:
U/M:

Pricing: Gross Profit %
Retail:
Net:
PR1:
PR2:
PR3:
 
LUC:
AUse GP% to calculate Price.
SEnd Pricing in 9



MFG:
Part Number:
Description:
U/M:

Pricing: GP %
Retail:
Net:
SP1:
SP2:
SP3:
 
LUC:
A------------Use GP% to calculate Price.
S------------End Pricing in 9
D------------Previous record
F------------Next Record
Enter--------Next field/recalculate
Shift+Enter--Previous field/recalculate
Q------------New Part
W-----------SAVE
E------------Search for part number
R------------Reset Search Values
Z------------Select MFG field
X------------Select COST field
C------------Compare Part Numbers
~; #SPRINTF!!!!!!!!!!!!!!! #Unmark record from search #EVALUATE FORMS #AUTOSAVE OPTION #new part #find next match $program?found=1,2,3 #search only part number #caps lock check #$program?MFG= desktop shortcuts # Cost: # # #print sidebar - for ($a=0; $a<0; $a++){@prod=split(/,/, "$file[$a]");print "$prod[1]";} #DEFAULT INPUT #GP% recal auto submit #BN SAVE CHANGE RECORD #AUTO SELECT RETAIL (LOOP NEXT 10) # tabcounter++; # if (tabcounter==16) {tabcounter=1} # if (tabcounter==1) {document.forms[1].elements[1].select()} # if (tabcounter==2) {document.forms[1].elements[2].select()} # if (tabcounter==3) {document.forms[1].elements[3].select()} # if (tabcounter==4) {document.forms[1].elements[4].select()} # if (tabcounter==5) {document.forms[1].elements[5].select()} # if (tabcounter==6) {document.forms[1].elements[7].select()} # if (tabcounter==7) {document.forms[1].elements[9].select()} # if (tabcounter==8) {document.forms[1].elements[11].select()} # if (tabcounter==9) {document.forms[1].elements[13].select()} # if (tabcounter==10) {document.forms[1].elements[15].select()} # if (tabcounter==11) {document.forms[1].elements[6].select()} # if (tabcounter==12) {document.forms[1].elements[8].select()} # if (tabcounter==13) {document.forms[1].elements[10].select()} # if (tabcounter==14) {document.forms[1].elements[12].select()} # if (tabcounter==15) {document.forms[1].elements[14].select()} sub oldcsv { #MFG for ($i=0; $i<=2; $i++){$text .="$prod[$i]";} $text .="\t"; #SKU for ($i=4; $i<=10; $i++){$text .="$prod[$i]";} $text .="\t"; #DES for ($i=16; $i<=40; $i++){$text .="$prod[$i]";} $text .="\t"; #UMC for ($i=41; $i<=43; $i++){$text .="$prod[$i]";} $text .="\t"; #LUC for ($i=58; $i<=62; $i++){$text .="$prod[$i]";} $text .="\t"; #RTL for ($i=49; $i<=53; $i++){$text .="$prod[$i]";} $text .="\t"; #NET for ($i=67; $i<=71; $i++){$text .="$prod[$i]";} $text .="\t"; #PR1 for ($i=85; $i<=89; $i++){$text .="$prod[$i]";} $text .="\t"; #PR2 for ($i=103; $i<=107; $i++){$text .="$prod[$i]";} $text .="\t"; #PR3 for ($i=121; $i<=125; $i++){$text .="$prod[$i]";} } sub OLDsearch { for ($i=0;$i<$#line;$i++) { if ($line[$i]=~m:(.*)$search(.*):i){ print "Content-type: text/html\n\n
"; } } }