Kumara - predecessor to Koha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
1.9 KiB

  1. package C4::Input; #asummes C4/Input
  2. #package to deal with marking up output
  3. use strict;
  4. require Exporter;
  5. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
  6. # set the version for version checking
  7. $VERSION = 0.01;
  8. @ISA = qw(Exporter);
  9. @EXPORT = qw(&checkflds &checkdigit);
  10. %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
  11. # your exported package globals go here,
  12. # as well as any optionally exported functions
  13. @EXPORT_OK = qw($Var1 %Hashit);
  14. # non-exported package globals go here
  15. use vars qw(@more $stuff);
  16. # initalize package globals, first exported ones
  17. my $Var1 = '';
  18. my %Hashit = ();
  19. # then the others (which are still accessible as $Some::Module::stuff)
  20. my $stuff = '';
  21. my @more = ();
  22. # all file-scoped lexicals must be created before
  23. # the functions below that use them.
  24. # file-private lexicals go here
  25. my $priv_var = '';
  26. my %secret_hash = ();
  27. # here's a file-private function as a closure,
  28. # callable as &$priv_func; it cannot be prototyped.
  29. my $priv_func = sub {
  30. # stuff goes here.
  31. };
  32. # make all your functions, whether exported or not;
  33. sub checkflds {
  34. my ($env,$reqflds,$data) = @_;
  35. my $numrflds = @$reqflds;
  36. my @probarr;
  37. my $i = 0;
  38. while ($i < $numrflds) {
  39. if ($data->{@$reqflds[$i]} eq "") {
  40. push(@probarr, @$reqflds[$i]);
  41. }
  42. $i++
  43. }
  44. return (\@probarr);
  45. }
  46. sub checkdigit {
  47. my ($env,$infl) = @_;
  48. $infl = uc $infl;
  49. my @weightings = (8,4,6,3,5,2,1);
  50. my $sum;
  51. my $i = 1;
  52. my $valid = 0;
  53. # print $infl."<br>";
  54. while ($i <8) {
  55. my $temp1 = $weightings[$i-1];
  56. my $temp2 = substr($infl,$i,1);
  57. $sum = $sum + ($temp1*$temp2);
  58. # print "$sum $temp1 $temp2<br>";
  59. $i++;
  60. }
  61. my $rem = ($sum%11);
  62. if ($rem == 10) {
  63. $rem = "X";
  64. }
  65. #print $rem."<br>";
  66. if ($rem eq substr($infl,8,1)) {
  67. $valid = 1;
  68. }
  69. return $valid;
  70. }
  71. END { } # module clean-up code here (global destructor)