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 # --------------------------------------------------------------------
16 require 'offline-lib.pl';
18 if( $cgi->param('file') ) {
20 &handle_success("File Upload Succeeded<br/><br/>".
21 "<a href='offline-execute.pl?org=$org'>Execute Scripts for org $org</a>");
27 # --------------------------------------------------------------------
28 # Use this for testing manual uploads
29 # --------------------------------------------------------------------
32 my $ws = $cgi->param('ws');
33 my $ses = $cgi->param('ses');
35 handle_error("Missing data in upload. We need ws and ses")
36 unless ($ws and $ses);
38 print "content-type: text/html\n\n";
42 <title>Offline Upload Server</title>
43 <style type='text/css'>
44 input { margin: 5px;' }
48 <div style='margin-top: 50px; text-align: center;'>
49 <form action='offline-upload.pl' method='post' enctype='multipart/form-data'>
50 <b>Testing</b><br/><br/>
51 <b> - Select an offline file to upload - </b><br/><br/>
52 <input type='file' name='file'> </input>
53 <input type='submit' name='Submit' value='Upload'> </input>
54 <input type='hidden' name='ws' value='$ws'> </input>
55 <input type='hidden' name='ses' value='$ses'> </input>
67 my $wsname = $cgi->param('ws');
68 my $ses = $cgi->param('ses');
69 my $filehandle = $cgi->upload('file');
71 my $ws = fetch_workstation($wsname);
72 $org = $ws->owning_lib;
73 my $dir = get_pending_dir($org);
74 my $output = "$dir/$wsname.log";
75 my $lock = "$dir/lock";
77 handle_error("Offline batch in process for this location. Please try again later." ) if( -e $lock );
78 handle_error("File $output already exists" ) if( -e $output );
80 $logger->debug("offline: Writing log file $output");
81 open(FILE, ">$output");
82 while( <$filehandle> ) { print FILE; }