Initial revision
[wip/koha-chris_n.git] / telnet / startint.pl
1 #!/usr/bin/perl
2
3 use strict;
4 #use C4::Security;
5 #use C4::Database;                                                                   
6 use C4::Circulation::Main;                                                          
7 #use C4::Circulation::Issues;                                                        
8 #use C4::Circulation::Returns;                                                       
9 #use C4::Circulation::Renewals;                                                      
10 #use C4::Circulation::Borrower;                                                      
11 #use C4::Reserves;                                                                   
12 use C4::InterfaceCDK;                                                               
13 #use C4::Security;
14
15
16 # set up environment array
17 # branchcode - logged on branch
18 # usercode - current user
19 # proccode - current or last procedure
20 # borrowernumber - current or last borrowernumber
21 # logintime - time logged on
22 # lasttime - lastime security checked
23 # tempuser - temporary user
24 my %env = (
25   branchcode => "", usercode => "", proccode => "lgon", borrowernumber => "",
26   logintime  => "", lasttime => "", tempuser => "", debug => "9"
27   );
28
29 $env{'branchcode'} = "C";
30 $env{'usercode'} = `whoami`;
31 $env{'telnet'} = "Y";
32
33
34 #start interface                                                                  
35 &startint(\%env,'Circulation');                                                    
36 getbranch(\%env);                                                                  
37 getprinter(\%env);                                                                 
38 my $donext = 'Circ';                                                              
39 my $reason;                                                                       
40 my $data;                                                                         
41 while ($donext ne 'Quit') {                                                       
42   if ($donext  eq "Circ") {                                                       
43     ($reason,$data) = menu(\%env,'console','Circulation',                          
44     ('Issues','Returns','Select Branch','Select Printer'));                     
45   } else {                                                                        
46     $data = $donext;                                                              
47   }                                                                               
48   if ($data eq 'Issues') {                                                        
49    my @args=('issuewrapper.pl',"$env{'branchcode'}","$env{'usercode'}","$env{'telnet'}","$env{'queue'}","$env{'printtype'}","$env{'brdata'}","$env{'lasttime'}");
50   open (FILE,">>/tmp/$<_$$");
51    my $time=localtime(time);
52    print FILE "Start issues $time \n";
53    close FILE;
54    system(@args);
55   } elsif ($data eq 'Returns') {                                                  
56    my @args=('returnswrapper.pl',"$env{'branchcode'}","$env{'usercode'}","$env{'telnet'}","$env{'queue'}","$env{'printtype'}","$env{'brdata'}");
57    open (FILE,">>/tmp/$<_$$");
58    my $time=localtime(time);
59    print FILE "Start returns $time \n";
60    close FILE;
61    system(@args);
62 #    $donext=Returns(\%env); #C4::Circulation::Returns                              
63   } elsif ($data eq 'Select Branch') {                                            
64     getbranch(\%env);                                                              
65   } elsif ($data eq 'Select Printer') {                                           
66     getprinter(\%env);                                                             
67 #  } elsif ($data eq 'Borrower Enquiries') {                                       
68     #  $donext=Borenq($env); #C4::Circulation::Borrower - conversion              
69 #  } elsif ($data eq 'Reserves'){                                                  
70 #    $donext=EnterReserves(\%env); #C4::Reserves                                    
71   } elsif ($data eq 'Quit') {                                                     
72     $donext = $data;                                                              
73     &endint(\%env);            
74     die;
75   }                                                                               
76 }
77     &endint(\%env);            
78     die;