28require_once
'../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
37require_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';
64 header(
"Location: ".$urlforuploadpage);
68if ($action ==
'uploadfile') {
70 print
'Error, modulepart param is empty';
76 $module = $arrayobject[
'module'];
77 $element = $arrayobject[
'element'];
78 $dir_output = $arrayobject[
'dir_output'];
79 $dir_temp = $arrayobject[
'dir_temp'];
83 $fileprefix =
'unknown';
84 if (in_array($modulepart, array(
'fournisseur',
'invoice_supplier'))) {
85 $permlevel1 =
'facture';
88 } elseif ($modulepart ==
'expensereport') {
89 $fileprefix =
'upload_page-by'.$user->id.
'-'.$modulepart.
'-'.(
GETPOSTINT(
'userexpensereportid') > 0 ?
GETPOSTINT(
'userexpensereportid') : 0).
'-'.(
GETPOSTINT(
'search_prodid') > 0 ?
GETPOSTINT(
'search_prodid') : 0);
90 } elseif ($modulepart ==
'salaries') {
91 $fileprefix =
'upload_page-by'.$user->id.
'-'.$modulepart.
'-'.(
GETPOSTINT(
'usersalaryid') > 0 ?
GETPOSTINT(
'usersalaryid') : 0);
95 $permissiontoadd = $user->hasRight($module, $permlevel1, $permlevel2);
97 $permissiontoadd = $user->hasRight($module, $permlevel1);
99 $forceFullTextIndexation =
'0';
102 if (!empty($_FILES[
'userfile'][
'name'])) {
103 $_FILES[
'userfile'][
'name'] = $fileprefix.
'-'.$_FILES[
'userfile'][
'name'];
105 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
109 header(
"Location: ".DOL_URL_ROOT.
'/core/upload_page2.php?file='.urlencode($fileprefix));
120$form =
new Form($db);
136$title = $langs->trans(
"UploadFile");
140$arrayofcss = array();
142llxHeader(
'', $title, $help_url,
'', 0, 0, $arrayofjs, $arrayofcss,
'',
'mod-upload page-card');
148$hookmanager->initHooks(array(
'uploadform'));
154$uploadform =
'<div class="display-flex">';
158 $langs->load(
"bills");
160 <div id="supplierinvoice" class="flex-item flex-item-uploadfile">'.img_picto(
'',
'bill',
'class="fa-2x"').
'<br>
161 <div>'.$langs->trans(
"SupplierInvoice").
'<br><br>';
163 $uploadform .=
img_picto(
'',
'company',
'class="pictofixedwidth"');
164 $uploadform .= $form->select_company(
GETPOSTINT(
'socid'),
'socid',
'(statut:=:0)', $langs->transnoentitiesnoconv(
"Supplier"), 0, 0, array(), 0,
'maxwidth200 disableautoopen');
166 $uploadform .=
'<br>';
169 $prodtext = $langs->trans(
"RefOrLabel");
172 $uploadform .=
img_picto(
'',
'product',
'class="pictofixedwidth"');
173 $uploadform .= $form->select_produits_fournisseurs(0, $prodid,
'prodid',
'',
'', array(), 1, 1,
'maxwidth200 disableautoopen', $prodtext, 1);
175 $uploadform .=
'<br>';
178 <small class="opacitymedium">'.$langs->trans(
"OrClickToSelectAFile").
'...</small>
185 $langs->load(
"expensereport");
187 <div id="userexpensereport" class="flex-item flex-item-uploadfile">'.img_picto(
'',
'expensereport',
'class="fa-2x"').
'<br>
188 <div>'.$langs->trans(
"ExpenseReport").
'<br><br>';
190 $uploadform .=
img_picto(
'',
'user',
'class="pictofixedwidth"');
192 $uploadform .= $form->select_dolusers(
GETPOSTINT(
'userexpensereportid') > 0 ?
GETPOSTINT(
'userexpensereportid') : $user->id,
'userexpensereportid', $langs->transnoentitiesnoconv(
"User"), null, 0,
'hierarchyme',
'',
'', 0, 0,
'', 0,
'',
'maxwidth200 disableautoopen', 1);
195 $uploadform .=
'<br>';
198 <small class="opacitymedium">'.$langs->trans(
"OrClickToSelectAFile").
'...</small>
206 $langs->load(
"salaries");
208 <div id="userpayroll" class="flex-item flex-item-uploadfile">'.img_picto(
'',
'salary',
'class="fa-2x"').
'<br>
209 <div>'.$langs->trans(
"UserPaySlip").
'<br><br>';
212 $uploadform .=
img_picto(
'',
'user',
'class="pictofixedwidth"');
214 $uploadform .= $form->select_dolusers(
GETPOSTINT(
'usersalaryid') > 0 ?
GETPOSTINT(
'usersalaryid') : $user->id,
'usersalaryid', $langs->transnoentitiesnoconv(
"Employee"), null, 0,
'hierarchyme',
'',
'', 0, 0,
'', 0,
'',
'maxwidth200 disableautoopen', 1);
217 $uploadform .=
'<br>';
220 <small class="opacitymedium">'.$langs->trans(
"OrClickToSelectAFile").
'...</small>
227$uploadform .=
'</div>';
231$parameters = array(
'uploadform' => $uploadform);
232$reshook = $hookmanager->executeHooks(
'printUploadForm', $parameters);
233if (empty($reshook)) {
234 $uploadform .= $hookmanager->resPrint;
236 $uploadform = $hookmanager->resPrint;
239$uploadform .=
'<br>';
244print
"<!-- Begin UploadForm -->\n";
245print
'<form id="uploadform" enctype="multipart/form-data" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
246print
'<input type="hidden" name="token" value="'.newToken().
'">';
247print
'<input type="hidden" name="action" value="uploadfile">';
248print
'<input type="hidden" name="sendit" value="1">';
249print
'<input type="hidden" name="modulepart" id="modulepart" value="">';
250print
'<input type="hidden" name="overwritefile" value="1">';
252print
'<div class="center"><div class="center" style="padding: 10px;">';
253print
'<style>.menu_titre { padding-top: 7px; }</style>';
254print
'<div id="blockupload" class="center">'.
"\n";
259$accept =
'.pdf,image/*';
265$max = $maxfilesizearray[
'max'];
266$maxmin = $maxfilesizearray[
'maxmin'];
267$maxphptoshow = $maxfilesizearray[
'maxphptoshow'];
268$maxphptoshowparam = $maxfilesizearray[
'maxphptoshowparam'];
271 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
273$out .=
'<input class="hideobject" type="file" id="fileInput" value=""';
275$out .= ((
getDolGlobalString(
'MAIN_DISABLE_MULTIPLE_FILEUPLOAD') || $disablemulti) ?
' name="userfile"' :
' name="userfile[]" multiple');
279$out .= (!empty($accept) ?
' accept="'.$accept.
'"' :
' accept=""');
281$out .= (!empty($capture) ?
' capture="capture"' :
'');
288$(document).ready(function() {
289 jQuery('#supplierinvoice:not(.disableautoopen)').on('click', function(event) {
290 console.log('Click on link supplierinvoice to open input file');
292 if (!event.target.closest('.disableautoopen')) {
293 $('#modulepart').val('invoice_supplier');
294 $('#fileInput').click();
298 jQuery('#userexpensereport:not(.disableautoopen)').on('click', function(event) {
299 console.log('Click on link userexpensereport to open input file');
301 if (!event.target.closest('.disableautoopen')) {
302 $('#modulepart').val('expensereport');
303 $('#fileInput').click();
307 jQuery('#userpayroll:not(.disableautoopen)').on('click', function(event) {
308 console.log('Click on link userpayroll to open input file');
310 if (!event.target.closest('.disableautoopen')) {
311 $('#modulepart').val('salaries');
312 $('#fileInput').click();
316 jQuery('#fileInput').on('change', function(event) {
318 console.log('A file was selected, we submit the form');
319 $('#uploadform').submit();
328print
"\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.
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.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getMaxFileSizeArray()
Return the max allowed for file upload.