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.

157 lines
5.1 KiB

  1. #!/usr/bin/perl
  2. #script to print confirmation screen, then if accepted calls itself to insert data
  3. use strict;
  4. use C4::Output;
  5. use C4::Input;
  6. use CGI;
  7. use Date::Manip;
  8. my %env;
  9. my $input = new CGI;
  10. #get varibale that tells us whether to show confirmation page
  11. #or insert data
  12. my $insert=$input->param('insert');
  13. #get rest of data
  14. my %data;
  15. my @names=$input->param;
  16. foreach my $key (@names){
  17. $data{$key}=$input->param($key);
  18. }
  19. print $input->header;
  20. print startpage();
  21. print startmenu('member');
  22. my $main="#99cc33";
  23. my $image="/images/background-mem.gif";
  24. if ($insert eq ''){
  25. my $ok=0;
  26. #check that all compulsary fields are entered
  27. my $string="The following compulsary fields have been left blank. Please push the back button
  28. and try again<p>";
  29. if ($data{'cardnumber'} eq ''){
  30. $string.=" Cardnumber<br>";
  31. $ok=1;
  32. } else {
  33. #check cardnumber is valid
  34. my $valid=checkdigit(\%env,$data{'cardnumber'});
  35. if ($valid != 1){
  36. $ok=1;
  37. $string.=" Invalid Cardnumber<br>";
  38. }
  39. }
  40. if ($data{'sex'} eq ''){
  41. $string.=" Gender <br>";
  42. $ok=1;
  43. }
  44. if ($data{'firstname'} eq ''){
  45. $string.=" Given Names<br>";
  46. $ok=1;
  47. }
  48. if ($data{'surname'} eq ''){
  49. $string.=" Surname<br>";
  50. $ok=1;
  51. }
  52. if ($data{'address'} eq ''){
  53. $string.=" Postal Street Address<br>";
  54. $ok=1;
  55. }
  56. if ($data{'city'} eq ''){
  57. $string.=" Postal City<br>";
  58. $ok=1;
  59. }
  60. if ($data{'contactname'} eq ''){
  61. $string.=" Alternate Contact<br>";
  62. $ok=1;
  63. }
  64. #we are printing confirmation page
  65. print mkheadr(1,'Confirm Record');
  66. if ($ok ==0){
  67. print mktablehdr;
  68. print mktablerow(2,$main,bold('NEW MEMBER'),"",$image);
  69. my $name=$data{'title'}." ";
  70. if ($data{'othernames'} ne ''){
  71. $name.=$data{'othernames'}." ";
  72. } else {
  73. $name.=$data{'firstname'}." ";
  74. }
  75. $name.="$data{'surname'} ( $data{'firstname'}, $data{'initials'})";
  76. print mktablerow(2,'white',bold('Name'),$name);
  77. print mktablerow(2,$main,bold('MEMBERSHIP DETAILS'),"",$image);
  78. print mktablerow(2,'white',bold('Membership Number'),$data{'borrowernumber'});
  79. print mktablerow(2,'white',bold('Cardnumber'),$data{'cardnumber'});
  80. print mktablerow(2,'white',bold('Membership Category'),$data{'categorycode'});
  81. print mktablerow(2,'white',bold('Area'),$data{'area'});
  82. print mktablerow(2,'white',bold('Fee'),$data{'fee'});
  83. if ($data{'joining'} eq ''){
  84. $data{'joining'}=ParseDate('today');
  85. $data{'joining'}=&UnixDate($data{'joining'},'%Y-%m-%d');
  86. }
  87. print mktablerow(2,'white',bold('Joining Date'),$data{'joining'});
  88. if ($data{'expiry'} eq ''){
  89. $data{'expiry'}=ParseDate('in 1 year');
  90. $data{'expiry'}=&UnixDate($data{'expiry'},'%Y-%m-%d');
  91. }
  92. print mktablerow(2,'white',bold('Expiry Date'),$data{'expiry'});
  93. print mktablerow(2,'white',bold('Joining Branch'),$data{'joinbranch'});
  94. print mktablerow(2,$main,bold('PERSONAL DETAILS'),"",$image);
  95. my $ethnic=$data{'ethnicity'}." ".$data{'ethnicnotes'};
  96. print mktablerow(2,'white',bold('Ethnicity'),$ethnic);
  97. $data{'dateofbirth'}=ParseDate($data{'dateofbirth'});
  98. $data{'dateofbirth'}=UnixDate($data{'dateofbirth'},'%Y-%m-%d');
  99. print mktablerow(2,'white',bold('Date of Birth'),$data{'dateofbirth'});
  100. my $sex;
  101. if ($data{'sex'} eq 'M'){
  102. $sex="Male";
  103. } else {
  104. $sex="Female";
  105. }
  106. print mktablerow(2,'white',bold('Sex'),$sex);
  107. print mktablerow(2,$main,bold('MEMBER ADDRESS'),"",$image);
  108. my $postal=$data{'address'}."<br>".$data{'city'};
  109. my $home;
  110. if ($data{'streetaddress'} ne ''){
  111. $home=$data{'streetaddress'}."<br>".$data{'streetcity'};
  112. } else {
  113. $home=$postal;
  114. }
  115. print mktablerow(2,'white',bold('Postal Address'),$postal);
  116. print mktablerow(2,'white',bold('Home Address'),$home);
  117. print mktablerow(2,$main,bold('MEMBER CONTACT DETAILS'),"",$image);
  118. print mktablerow(2,'white',bold('Phone (Home)'),$data{'phone'});
  119. print mktablerow(2,'white',bold('Phone (Daytime)'),$data{'phoneday'});
  120. print mktablerow(2,'white',bold('Fax'),$data{'faxnumber'});
  121. print mktablerow(2,'white',bold('Email'),$data{'emailaddress'});
  122. print mktablerow(2,$main,bold('ALTERNATIVE CONTACT DETAILS'),"",$image);
  123. print mktablerow(2,'white',bold('Name'),$data{'contactname'});
  124. print mktablerow(2,'white',bold('Phone'),$data{'altphone'});
  125. print mktablerow(2,'white',bold('Relationship'),$data{'altrelationship'});
  126. print mktablerow(2,'white',bold('Notes'),$data{'altnotes'});
  127. print mktablerow(2,$main,bold('Notes'),"",$image);
  128. print mktablerow(2,'white',bold('General Notes'),$data{'borrowernotes'});
  129. print mktableft;
  130. #set up form to post data thru for modification or insertion
  131. my $i=0;
  132. my @inputs;
  133. while (my ($key, $value) = each %data) {
  134. $value=~ s/\"/%22/g;
  135. $inputs[$i]=["hidden","$key","$value"];
  136. $i++;
  137. }
  138. $inputs[$i]=["submit","submit","submit"];
  139. print mkformnotable("/cgi-bin/koha/insertdata.pl",@inputs);
  140. } else {
  141. print $string;
  142. }
  143. }
  144. #print $input->dump;
  145. print mktablehdr;
  146. print mktableft;
  147. print endmenu('member');
  148. print endpage();