dolibarr  16.0.5
fileupload_main.tpl.php
1 <?php
2 /* Copyright (C) 2011-2013 Regis Houssin <regis.houssin@inodbox.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 // Protection to avoid direct call of template
19 if (empty($conf) || !is_object($conf)) {
20  print "Error, template page can't be called as URL";
21  exit;
22 }
23 
24 ?>
25 
26 <!-- START TEMPLATE FILE UPLOAD MAIN -->
27 <script>
28 window.locale = {
29  "fileupload": {
30  "errors": {
31  "maxFileSize": "<?php echo $langs->trans('FileIsTooBig'); ?>",
32  "minFileSize": "<?php echo $langs->trans('FileIsTooSmall'); ?>",
33  "acceptFileTypes": "<?php echo $langs->trans('FileTypeNotAllowed'); ?>",
34  "maxNumberOfFiles": "<?php echo $langs->trans('MaxNumberOfFilesExceeded'); ?>",
35  "uploadedBytes": "<?php echo $langs->trans('UploadedBytesExceedFileSize'); ?>",
36  "emptyResult": "<?php echo $langs->trans('EmptyFileUploadResult'); ?>"
37  },
38  "error": "<?php echo $langs->trans('Error'); ?>",
39  "start": "<?php echo $langs->trans('Start'); ?>",
40  "cancel": "<?php echo $langs->trans("Cancel"); ?>",
41  "destroy": "<?php echo $langs->trans('Delete'); ?>"
42  }
43 };
44 
45 $(function () {
46  'use strict';
47 
48  // Initialize the jQuery File Upload widget:
49  $('#fileupload').fileupload();
50 
51  // Events
52  $('#fileupload').fileupload({
53  stop: function (e, data) {
54  location.href='<?php echo dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]); ?>';
55  },
56  destroy: function (e, data) {
57  var that = $(this).data('fileupload');
58  $( "#confirm-delete" ).dialog({
59  resizable: false,
60  width: 400,
61  modal: true,
62  buttons: {
63  "<?php echo $langs->trans('Ok'); ?>": function() {
64  $( "#confirm-delete" ).dialog( "close" );
65  if (data.url) {
66  $.ajax({
67  method: "POST",
68  data: { token: '<?php echo currentToken(); ?>' },
69  url: data.url
70  }).success(function (data) {
71  if (data) {
72  that._adjustMaxNumberOfFiles(1);
73  $(this).fadeOut(function () {
74  $(this).remove();
75  $.jnotify("<?php echo $langs->trans('FileIsDelete'); ?>");
76  });
77  } else {
78  $.jnotify("<?php echo $langs->trans('ErrorFileNotDeleted'); ?>", "error", true);
79  }
80  });
81  } else {
82  data.context.fadeOut(function () {
83  $(this).remove();
84  });
85  }
86  },
87  "<?php echo $langs->trans("Cancel"); ?>": function() {
88  $( "#confirm-delete" ).dialog( "close" );
89  }
90  }
91  });
92  }
93  });
94 });
95 </script>
96 <!-- END TEMPLATE FILE UPLOAD MAIN -->