2 use strict; use warnings;
4 # --------------------------------------------------------------------
5 # Uploads offline action files
6 # pending files go into $base_dir/pending/<org>/<ws>.log
7 # completed transactions go into $base_dir/archive/<org>/YYYMMDDHHMM/<ws>.log
8 # --------------------------------------------------------------------
10 our ($ORG, $META_FILE, $LOCK_FILE, $TIME_DELTA, $MD5_SUM, $PRINT_HTML,
11 $AUTHTOKEN, $REQUESTOR, $U, %config, $cgi, $base_dir, $logger);
13 require 'offline-lib.pl';
15 if( $cgi->param('file') ) {
17 &handle_event(OpenILS::Event->new('SUCCESS'));
22 # --------------------------------------------------------------------
23 # Loads the POSTed file and writes the contents to disk
24 # --------------------------------------------------------------------
27 my $wsname = $cgi->param('ws');
28 my $filehandle = $cgi->upload('file');
30 my $ws = fetch_workstation($wsname);
31 $ORG = $ws->owning_lib;
33 # make sure we have upload priveleges
34 my $evt = $U->check_perms($REQUESTOR->id, $ORG, 'OFFLINE_UPLOAD');
35 handle_event($evt) if $evt;
37 my $dir = get_pending_dir();
38 my $output = "$dir/$wsname.log";
39 my $lock = "$dir/$LOCK_FILE";
41 &handle_event(OpenILS::Event->new('OFFLINE_SESSION_ACTIVE')) if( -e $lock );
42 &handle_event(OpenILS::Event->new('OFFLINE_SESSION_FILE_EXISTS')) if( -e $output );
44 $logger->debug("offline: Writing log file $output");
45 open(FILE, ">$output");
46 while( <$filehandle> ) { print FILE; }
49 # Append the metadata for this workstations upload
51 requestor => $REQUESTOR->id,
53 workstation => $wsname,
55 delta => $TIME_DELTA},
60 # --------------------------------------------------------------------
61 # Use this for testing manual uploads
62 # --------------------------------------------------------------------
64 my $ws = $cgi->param('ws') || "";
67 title => "Offline Upload",
70 <form action='offline-upload.pl' method='post' enctype='multipart/form-data'>
71 <b> - Select an offline file to upload - </b><br/><br/>
75 <td>File to Upload: </td>
76 <td><input type='file' name='file'> </input></td>
79 <td>Workstation Name: </td>
80 <td><input type='text' name='ws' value='$ws'> </input></td>
84 <td><input type='text' name='delta' value='$TIME_DELTA'> </input></td>
87 <td colspan='2' align='center'><input type='submit' name='Submit' value='Upload'> </input></td>
91 <input type='hidden' name='ses' value='$AUTHTOKEN'> </input>
92 <input type='hidden' name='html' value='$PRINT_HTML'> </input>