28require_once
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
41 $langs->setDefaultLang(
GETPOST(
'lang',
'aZ09'));
44$langs->loadLangs(array(
"main",
"other"));
46$action =
GETPOST(
'action',
'aZ09');
47$modulepart =
GETPOST(
'modulepart',
'aZ09');
49$upload_dir =
$conf->admin->dir_temp.
'/import';
62 header(
"Location: ".$urlforuploadpage);
66if ($action ==
'uploadfile') {
69 $module = $arrayobject[
'module'];
70 $element = $arrayobject[
'element'];
71 $dir_output = $arrayobject[
'dir_output'];
72 $dir_temp = $arrayobject[
'dir_temp'];
76 $fileprefix =
'unknown';
77 if (in_array($modulepart, array(
'fournisseur',
'invoice_supplier'))) {
78 $permlevel1 =
'facture';
81 } elseif ($modulepart ==
'expensereport') {
82 $fileprefix =
'upload_page-by'.$user->id.
'-'.$modulepart.
'-'.(
GETPOSTINT(
'userexpensereportid') > 0 ?
GETPOSTINT(
'userexpensereportid') : 0);
83 } elseif ($modulepart ==
'salaries') {
84 $fileprefix =
'upload_page-by'.$user->id.
'-'.$modulepart.
'-'.(
GETPOSTINT(
'usersalaryid') > 0 ?
GETPOSTINT(
'usersalaryid') : 0);
88 $permissiontoadd = $user->hasRight($module, $permlevel1, $permlevel2);
90 $permissiontoadd = $user->hasRight($module, $permlevel1);
92 $forceFullTextIndexation =
'1';
94 $_FILES[
'userfile'][
'name'] = $fileprefix.
'-'.$_FILES[
'userfile'][
'name'];
96 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
106$form =
new Form($db);
109if (empty($dolibarr_nocache) &&
GETPOSTINT(
'cache')) {
110 header(
'Cache-Control: max-age='.
GETPOSTINT(
'cache').
', public');
112 header(
'Expires: '.gmdate(
'D, d M Y H:i:s',
dol_now(
'gmt') +
GETPOSTINT(
'cache')).
' GMT');
114 header(
'Pragma: token=public');
117 header(
'Cache-Control: no-cache');
120$title = $langs->trans(
"UploadFile");
124$head =
'<!-- Upload file -->'.
"\n";
126$arrayofcss = array();
128llxHeader(
'', $title, $help_url,
'', 0, 0, $arrayofjs, $arrayofcss,
'',
'mod-upload page-card');
135$hookmanager->initHooks(array(
'uploadform'));
141$uploadform =
'<div class="display-flex">';
144if (isModEnabled(
'supplier_invoice')) {
145 $langs->load(
"bills");
147 <div id="supplierinvoice" class="flex-item flex-item-uploadfile">'.img_picto(
'',
'bill',
'class="fa-2x"').
'<br>
148 <div>'.$langs->trans(
"SupplierInvoice").
'<br><br>';
150 $uploadform .=
img_picto(
'',
'company',
'class="pictofixedwidth"');
152 $uploadform .= $form->select_company(
GETPOSTINT(
'socid'),
'socid',
'(statut:=:0)', $langs->transnoentitiesnoconv(
"Supplier"), 0, 0, array(), 0,
'maxwidth200 disableautoopen');
155 $uploadform .=
'<br>';
157 $uploadform .=
img_picto(
'',
'product',
'class="pictofixedwidth"');
159 $prodtext = $langs->trans(
"RefOrLabel");
163 $uploadform .= $form->select_produits_fournisseurs(0, $prodid,
'prodid',
'',
'', array(), 1, 1,
'maxwidth200 disableautoopen', $prodtext, 1);
166 $uploadform .=
'<br>';
169 <small>('.$langs->trans(
"OrClickToSelectAFile").
')</small>
175if (isModEnabled(
'expensereport')) {
176 $langs->load(
"expensereport");
178 <div id="userexpensereport" class="flex-item flex-item-uploadfile">'.img_picto(
'',
'expensereport',
'class="fa-2x"').
'<br>
179 <div>'.$langs->trans(
"ExpenseReport").
'<br><br>';
181 $uploadform .=
img_picto(
'',
'user',
'class="pictofixedwidth"');
183 $uploadform .= $form->select_dolusers(
GETPOSTINT(
'userexpensereportid') > 0 ?
GETPOSTINT(
'userexpensereportid') : $user->id,
'userexpensereportid', $langs->transnoentitiesnoconv(
"User"), null, 0,
'hierarchyme',
'',
'', 0, 0,
'', 0,
'',
'maxwidth200 disableautoopen', 1);
186 $uploadform .=
'<br>';
189 <small>('.$langs->trans(
"OrClickToSelectAFile").
')</small>
196if (isModEnabled(
'salaries')) {
197 $langs->load(
"salaries");
199 <div id="userpayroll" class="flex-item flex-item-uploadfile">'.img_picto(
'',
'salary',
'class="fa-2x"').
'<br>
200 <div>'.$langs->trans(
"UserPaySlip").
'<br><br>';
203 $uploadform .=
img_picto(
'',
'user',
'class="pictofixedwidth"');
205 $uploadform .= $form->select_dolusers(
GETPOSTINT(
'usersalaryid') > 0 ?
GETPOSTINT(
'usersalaryid') : $user->id,
'usersalaryid', $langs->transnoentitiesnoconv(
"Employee"), null, 0,
'hierarchyme',
'',
'', 0, 0,
'', 0,
'',
'maxwidth200 disableautoopen', 1);
208 $uploadform .=
'<br>';
211 <small>('.$langs->trans(
"OrClickToSelectAFile").
')</small>
218$uploadform .=
'</div>';
222$parameters = array(
'uploadform' => $uploadform);
223$reshook = $hookmanager->executeHooks(
'printUploadForm', $parameters);
224if (empty($reshook)) {
225 $uploadform .= $hookmanager->resPrint;
227 $uploadform = $hookmanager->resPrint;
230$uploadform .=
'<br>';
235print
"<!-- Begin UploadForm -->\n";
236print
'<form id="uploadform" enctype="multipart/form-data" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
237print
'<input type="hidden" name="token" value="'.newToken().
'">';
238print
'<input type="hidden" name="action" value="uploadfile">';
239print
'<input type="hidden" name="sendit" value="1">';
240print
'<input type="hidden" name="modulepart" id="modulepart" value="">';
242print
'<div class="center"><div class="center" style="padding: 30px;">';
243print
'<style>.menu_titre { padding-top: 7px; }</style>';
244print
'<div id="blockupload" class="center">'.
"\n";
249$accept =
'.pdf, image';
255$max = $maxfilesizearray[
'max'];
256$maxmin = $maxfilesizearray[
'maxmin'];
257$maxphptoshow = $maxfilesizearray[
'maxphptoshow'];
258$maxphptoshowparam = $maxfilesizearray[
'maxphptoshowparam'];
261 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
263$out .=
'<input class="hideobject" type="file" id="fileInput"';
265$out .= ((
getDolGlobalString(
'MAIN_DISABLE_MULTIPLE_FILEUPLOAD') || $disablemulti) ?
' name="userfile"' :
' name="userfile[]" multiple');
269$out .= (!empty($accept) ?
' accept="'.$accept.
'"' :
' accept=""');
271$out .= (!empty($capture) ?
' capture="capture"' :
'');
278$(document).ready(function() {
279 jQuery('#supplierinvoice:not(.disableautoopen)').on('click', function(event) {
280 console.log('Click on link supplierinvoice to open input file');
282 if (!event.target.closest('.disableautoopen')) {
283 $('#modulepart').val('invoice_supplier');
284 $('#fileInput').click();
288 jQuery('#userexpensereport:not(.disableautoopen)').on('click', function(event) {
289 console.log('Click on link userexpensereport to open input file');
291 if (!event.target.closest('.disableautoopen')) {
292 $('#modulepart').val('expensereport');
293 $('#fileInput').click();
297 jQuery('#userpayroll:not(.disableautoopen)').on('click', function(event) {
298 console.log('Click on link userpayroll to open input file');
300 if (!event.target.closest('.disableautoopen')) {
301 $('#modulepart').val('salaries');
302 $('#fileInput').click();
306 jQuery('#fileInput').on('change', function(event) {
308 console.log('A file was selected, we submit the form');
309 $('#uploadform').submit();
318print
"\n<!-- End UploadForm -->\n";
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
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, $allowothertags=array())
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.
getElementProperties($elementType)
Get an array with properties of an element.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
getMaxFileSizeArray()
Return the max allowed for file upload.