dolibarr 21.0.0-alpha
upload_page.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This file is a modified version of datepicker.php from phpBSM to fix some
7 * bugs, to add new features and to dramatically increase speed.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
28//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
29//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
30//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
31//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
32/*
33if (!defined('NOCSRFCHECK')) {
34 define('NOCSRFCHECK', 1);
35}
36if (!defined('NOTOKENRENEWAL')) {
37 define('NOTOKENRENEWAL', 1);
38}
39*/
40//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
41/*
42if (!defined('NOREQUIREMENU')) {
43 define('NOREQUIREMENU', 1);
44}
45*/
46//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
47
48require_once '../main.inc.php';
49require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
50
51if (GETPOST('lang', 'aZ09')) {
52 $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
53}
54
55$langs->loadLangs(array("main", "other"));
56
57$action = GETPOST('action', 'aZ09');
58
59/*$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
60$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');*/
61
62
63/*
64 * Actions
65 */
66
67// if ($action == 'aaa') { // Test on permission not required here. Test will be done on the targeted page.
68
69// }
70
71
72/*
73 * View
74 */
75
76$form = new Form($db);
77
78// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
79if (empty($dolibarr_nocache) && GETPOSTINT('cache')) {
80 header('Cache-Control: max-age='.GETPOSTINT('cache').', public');
81 // For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
82 header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOSTINT('cache')).' GMT');
83 // HTTP/1.0
84 header('Pragma: token=public');
85} else {
86 // HTTP/1.0
87 header('Cache-Control: no-cache');
88}
89
90$title = $langs->trans("UploadFile");
91$help_url = '';
92
93// URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
94$head = '<!-- Upload file -->'."\n"; // This is used by DoliDroid to know page is a search page
95$arrayofjs = array();
96$arrayofcss = array();
97
98llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-upload page-card');
99//top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
100
101print load_fiche_titre('', '', '', 0, '', '', '<h2>'.$title.'</h2>');
102
103
104// Instantiate hooks of thirdparty module
105$hookmanager->initHooks(array('uploadform'));
106
107// Define $uploadform
108$uploadform = '';
109
110
111$uploadform = '<div class="display-flex">';
112
113$langs->load("bills");
114$uploadform .= '
115<div id="supplierinvoice" class="flex-item flex-item-uploadfile">'.img_picto('', 'bill', 'class="fa-2x"').'<br>
116<div>'.$langs->trans("SupplierInvoice").'<br><br>';
117
118$uploadform .= img_picto('', 'company', 'class="pictofixedwidth"');
119$uploadform .= $form->select_company(GETPOSTINT('socid'), 'socid', 'statut=0', $langs->transnoentitiesnoconv("Supplier"));
120
121$uploadform .= '<br><br>
122<small>('.$langs->trans("OrClickToSelectAFile").')</small>
123</div>
124</div>';
125
126$langs->load("salaries");
127$uploadform .= '
128<div id="userpayroll" class="flex-item flex-item-uploadfile">'.img_picto('', 'salary', 'class="fa-2x"').'<br>
129<div>'.$langs->trans("UserPaySlip").'<br>
130<small>('.$langs->trans("OrClickToSelectAFile").')</small>
131</div>
132</div>';
133
134$uploadform .= '</div>';
135
136
137// Execute hook printSearchForm
138$parameters = array('uploadform' => $uploadform);
139$reshook = $hookmanager->executeHooks('printUploadForm', $parameters); // Note that $action and $object may have been modified by some hooks
140if (empty($reshook)) {
141 $uploadform .= $hookmanager->resPrint;
142} else {
143 $uploadform = $hookmanager->resPrint;
144}
145
146$uploadform .= '<br>';
147
148
149// Show all forms
150print "\n";
151print "<!-- Begin UploadForm -->\n";
152print '<form id="uploadform" enctype="multipart/form-data" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
153print '<input type="hidden" name="token" value="'.newToken().'">';
154print '<input type="hidden" name="action" value="uploadfile">';
155
156print '<div class="center"><div class="center" style="padding: 30px;">';
157print '<style>.menu_titre { padding-top: 7px; }</style>';
158print '<div id="blockupload" class="center">'."\n";
159//print '<input name="filenamePDF" id="filenamePDF" type="hideobject">';
160print $uploadform;
161
162print '<input type="file" id="fileInput" class="hideobject" accept=".pdf, image/*">';
163
164print "<script>
165$(document).ready(function() {
166 jQuery('#supplierinvoice').on('click', function(event) {
167 console.log('Click on link to open input file');
168 console.log(event);
169 $('#fileInput').click();
170 });
171
172 jQuery('#search_socid').on('click', function(event) {
173 event.stopPropagation();
174 console.log('Avoid to open the input select');
175 });
176
177 jQuery('#fileInput').on('change', function() {
178 console.log('A file was selected, we submit the form');
179 $('#uploadform').submit();
180 });
181});
182</script>";
183
184print '</div>'."\n";
185print '</div></div>';
186
187print '</form>';
188print "\n<!-- End UploadForm -->\n";
189
190
191
192// End of page
193llxFooter();
194$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.