Vue bundle - Add main.js.LICENSE.txt
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / offline_circ / process_koc.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% INCLUDE 'doc-head-open.inc' %]
5 <title>Offline circulation file upload &rsaquo; Circulation &rsaquo; Koha</title>
6 [% INCLUDE 'doc-head-close.inc' %]
7 </head>
8
9 <body id="ocirc_process_koc" class="circ ocirc">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'circ-search.inc' %]
12
13 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
14     <ol>
15         <li>
16             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
17         </li>
18         <li>
19             <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a>
20         </li>
21
22         [% IF ( transactions_loaded ) %]
23             <li>
24                 <a href="/cgi-bin/koha/offline_circ/process_koc.pl">Offline circulation file upload</a>
25             </li>
26             <li>
27                 <a href="#" aria-current="page">
28                     Results
29                 </a>
30             </li>
31         [% ELSE %]
32             <li>
33                 <a href="#" aria-current="page">
34                     Offline circulation file upload
35                 </a>
36             </li>
37         [% END %]
38     </ol>
39 </nav>
40
41 <div class="main container-fluid">
42     <div class="row">
43         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
44
45 [% IF ( transactions_loaded ) %]
46   <h1>Koha offline circulation</h1>
47   <p>Your data was processed. Here are the results:</p>
48   [% FOREACH message IN messages %]
49     [% IF ( message.message ) %]
50         <div class="dialog alert">
51                 [% IF ( message.ERROR_file_version ) %]<p>Warning: This file is version [% message.upload_version | html %], but I only know how to import version [% message.current_version | html %]. I'll try my best.</p>[% END %]
52         </div>
53         [% END %]
54         [% IF ( message.ERROR_no_borrower_from_item ) %]<p>Warning: Unable to determine patron from item barcode ([% message.badbarcode | html %]). Cannot check in.</p>[% END %]
55     [% IF ( message.issue ) %]<p>Checked out <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber | uri %]">[% message.title | html %]</a> ([% message.barcode | html %]) to <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% message.borrowernumber | html %]">[% message.firstname | html %] [% message.surname | html %]</a> ([% message.cardnumber | html %]): [% message.datetime | html %]</p>[% END %]
56     [% IF ( message.renew ) %]<p>Renewed <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber | uri %]">[% message.title | html %]</a>  ([% message.barcode | html %]) for <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% message.borrowernumber | html %]">[% message.firstname | html %] [% message.surname | html %]</a> ([% message.cardnumber | html %]): [% message.datetime | html %]</p>[% END %]
57     [% IF ( message.return ) %]<p>Checked in <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% message.biblionumber | uri %]">[% message.title | html %]</a> ([% message.barcode | html %]) from <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% message.borrowernumber | html %]">[% message.firstname | html %] [% message.surname | html %]</a> ([% message.cardnumber | html %]): [% message.datetime | html %]</p>[% END %]
58     [% IF ( message.payment ) %]<p>Accepted payment ([% message.amount | html %]) from <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% message.borrowernumber | uri %]">[% message.firstname | html %] [% message.surname | html %]</a> ([% message.cardnumber | html %]): [% message.datetime | html %]</p>[% END %]
59   [% END %]
60 [% ELSE %]
61    <h1>Upload offline circulation data</h1>
62
63    <div id="fileuploadform">
64      <form method="post" action="/cgi-bin/koha/offline_circ/process_koc.pl" enctype="multipart/form-data" class="validated">
65                 <fieldset class="brief">
66        <ol><li><label for="fileToUpload">Choose .koc file: </label>
67             <input class="required" required="required" type="file" id="fileToUpload" size="50" name="fileToUpload" />
68             <span class="required">Required</span>
69        </li></ol>
70        <fieldset class="action"><input type="button" class="submit" value="Upload file" id="upload_file" /></fieldset>
71            </fieldset>
72      </form>
73      <div id="fileuploadstatus" class="progress_panel" style="display:none">Upload progress: <progress id="fileuploadprogress" max="100" value="0"></progress> <span class="fileuploadpercent">0</span>%</div>
74      <div id="fileuploadfailed" style="display:none"></div>
75    </div>
76
77    <form action="enqueue_koc.pl" id="processfile" method="post" enctype="multipart/form-data">
78      <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
79      <input type="submit" value="Add to offline circulation queue" id="queueformsubmit" />
80    </form>
81
82    <form action="process_koc.pl" id="enqueuefile" method="post" enctype="multipart/form-data">
83      <input type="hidden" name="uploadedfileid" id="uploadedfileid" value="" />
84      <input type="hidden" name="runinbackground" id="runinbackground" value="" />
85      <input type="hidden" name="completedJobID" id="completedJobID" value="" />
86      <!-- <input type="submit" value="Apply directly" id="mainformsubmit" /> -->
87      <!-- FIXME: Job freezes when submitted, disabling button as a temporary mitigation -->
88      <div id="jobstatus" style="display:none">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div>
89      <div id="jobfailed" style="display:none"></div>
90    </form>
91 [% END %]
92
93
94     </div>
95 </div>
96
97 [% MACRO jsinclude BLOCK %]
98     [% Asset.js("js/background-job-progressbar.js") | $raw %]
99     [% Asset.js("js/file-upload.js") | $raw %]
100     <script>
101         var xhr;
102         $(document).ready(function(){
103             $("#enqueuefile").hide();
104             $("#processfile").hide();
105             $("#upload_file").on("click",function(){
106                 StartUpload();
107             });
108             $("#queueformsubmit").on("click",function(){
109                 var processfile = document.getElementById("processfile");
110                 return CheckForm( processfile );
111             });
112             $("#mainformsubmit").on("click",function(){
113                 var enqueuefile = document.getElementById("enqueuefile");
114                 return CheckForm( enqueuefile );
115             });
116         });
117
118         function StartUpload() {
119             if( $('#fileToUpload').prop('files').length == 0 ) return;
120             $('#fileuploadform input.submit').prop('disabled',true);
121             $("#fileuploadfailed").hide();
122             $("#processfile").hide();
123             $("#fileuploadstatus").show();
124             $("form#processfile #uploadedfileid").val('');
125             $("form#enqueuefile #uploadedfileid").val('');
126             xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), 'temp=1', cbUpload );
127         }
128
129         function cbUpload( status, fileid, errors ) {
130             if( status=='done' ) {
131                 $("form#processfile #uploadedfileid").val( fileid );
132                 $("form#enqueuefile #uploadedfileid").val( fileid );
133                 $('#fileToUpload').prop('disabled',true);
134                 $("#processfile").show();
135                 $("#enqueuefile").show();
136             } else {
137                 var errMsgs = [ _("Error code 0 not used"), _("File already exists"), _("Directory is not writeable"), _("Root directory for uploads not defined"), _("Temporary directory for uploads not defined") ];
138                 var errCode = errors[$('#fileToUpload').prop('files')[0].name].code;
139                 $("#fileuploadstatus").hide();
140                 $("#fileuploadfailed").show();
141                 $("#fileuploadfailed").text( _("Upload status: ") +
142                     ( status=='failed'? _("Failed") + " - (" + errCode + ") " + errMsgs[errCode]:
143                     ( status=='denied'? _("Denied"): status ))
144                 );
145             }
146         }
147
148         function CheckForm(f) {
149             if (f.uploadedfileid.value == '') {
150                 alert(_("Please upload a file first."));
151             } else {
152                 $("#fileuploadstatus").hide();
153                 $("#fileuploadform").slideUp();
154                 $("#mainformsubmit").prop('disabled',true);
155                 $("#queueformsubmit").prop('disabled',true);
156                 return submitBackgroundJob(f);
157             }
158             return false;
159         }
160     </script>
161 [% END %]
162
163 [% INCLUDE 'intranet-bottom.inc' %]