68 $this->numoffiles = 0;
81 public function showImageToEdit(
string $htmlname,
string $modulepart,
string $dirformainimage,
string $subdirformainimage,
string $fileformainimage)
85 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
86 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
89 $maxwidthsmall = $tmparraysize[
'maxwidthsmall'];
90 $maxheightsmall = $tmparraysize[
'maxheightsmall'];
91 $maxwidthmini = $tmparraysize[
'maxwidthmini'];
92 $maxheightmini = $tmparraysize[
'maxheightmini'];
93 $quality = $tmparraysize[
'quality'];
98 if ($htmlname ==
'logo_squarred') {
105 $maxmin = $maxfilesizearray[
'maxmin'];
111 $out .=
'<div class="centpercent nobordernopadding valignmiddle"><div class="inline-block marginrightonly">';
113 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
115 $out .=
'<input type="file" class="flat minwidth100 maxwidthinputfileonsmartphone" name="'.$htmlname.
'" id="'.$htmlname.
'" accept="image/*">';
117 if (!empty($fileformainimagesmall)) {
118 $out .=
'<div class="inline-block valignmiddle marginrightonly">';
119 $out .=
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=remove'.$htmlname.
'&token='.
newToken().
'">'.
img_delete($langs->trans(
"Delete"),
'',
'marginleftonly').
'</a>';
121 if (file_exists($dirformainimage.
'/'.$subdirformainimage.$fileformainimagesmall)) {
122 $out .=
'<div class="inline-block valignmiddle marginrightonly">';
123 $out .=
'<img id="'.$htmlname.
'" style="'.$max.
'height: '.$imgheight.
'px; '.$max.
'width: '.$imgwidth.
'px;" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&file='.urlencode($subdirformainimage.$fileformainimagesmall).
'">';
125 } elseif (!empty($fileformainimage)) {
127 if (!file_exists($dirformainimage.
'/'.$subdirformainimage.$fileformainimagemini)) {
128 $imgThumbMini =
vignette($dirformainimage.
'/'.$subdirformainimage.$fileformainimage, $maxwidthmini, $maxheightmini,
'_mini', $quality);
130 $imgThumbSmall =
vignette($dirformainimage.
'/'.$subdirformainimage.$fileformainimage, $maxwidthsmall, $maxheightsmall,
'_small', $quality);
131 $out .=
'<div class="inline-block valignmiddle">';
132 $out .=
'<img id="'.$htmlname.
'" style="'.$max.
'height: '.$imgheight.
'px; '.$max.
'width: '.$imgwidth.
'px;" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&file='.urlencode($subdirformainimage.
'thumbs/'.basename($imgThumbSmall)).
'">';
135 } elseif (!empty($fileformainimage)) {
136 if (file_exists($dirformainimage.
'/'.$subdirformainimage.$fileformainimage)) {
137 $out .=
'<div class="inline-block valignmiddle">';
138 $out .=
'<img id="'.$htmlname.
'" style="'.$max.
'height: '.$imgheight.
'px; '.$max.
'width: '.$imgwidth.
'px;" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&file='.urlencode($subdirformainimage.$fileformainimage).
'">';
140 $out .=
'<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=remove'.$htmlname.
'&token='.
newToken().
'">'.
img_delete($langs->trans(
"Delete"),
'',
'marginleftonly').
'</a></div>';
142 $out .=
'<div class="inline-block valignmiddle">';
143 $out .=
'<img id="'.$htmlname.
'" height="'.$imgheight.
'" src="'.DOL_URL_ROOT.
'/public/theme/common/nophoto.png" title="File has been removed from disk">';
177 public function form_attach_new_file($url, $title =
'', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50,
$object =
null, $options =
'', $useajax = 1, $savingdocmask =
'', $linkfiles = 1, $htmlname =
'formuserfile', $accept =
'', $sectiondir =
'', $usewithoutform = 0, $capture = 0, $disablemulti = 0, $nooutput = 0)
180 global
$conf, $langs, $hookmanager;
181 $hookmanager->initHooks(array(
'formfile'));
185 dol_syslog(__METHOD__.
": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
188 if (!empty(
$conf->browser->layout) &&
$conf->browser->layout !=
'classic') {
202 $out =
"\n".
'<!-- Start form attach new file --><div class="formattachnewfile">'.
"\n";
204 if ($nooutput != 2) {
206 $title = $langs->trans(
"AttachANewFile");
208 if ($title !=
'none') {
213 if (empty($usewithoutform)) {
215 $url .= (strpos($url,
'?') ===
false ?
'?' :
'&').
'uploadform=1';
217 $out .=
'<form name="'.$htmlname.
'" id="'.$htmlname.
'" action="'.$url.
'" enctype="multipart/form-data" method="POST">'.
"\n";
219 if (empty($usewithoutform) || $usewithoutform == 2) {
220 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
221 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_dir" name="section_dir" value="'.$sectiondir.
'">'.
"\n";
222 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_id" name="section_id" value="'.$sectionid.
'">'.
"\n";
223 $out .=
'<input type="hidden" name="sortfield" value="'.GETPOST(
'sortfield',
'aZ09comma').
'">'.
"\n";
224 $out .=
'<input type="hidden" name="sortorder" value="'.GETPOST(
'sortorder',
'aZ09comma').
'">'.
"\n";
225 $out .=
'<input type="hidden" name="page_y" value="">'.
"\n";
228 $out .=
'<table class="nobordernopadding centpercent">';
231 if (!empty($options)) {
232 $out .=
'<td>'.$options.
'</td>';
235 $out .=
'<td class="valignmiddle nowrap">';
238 $max = $maxfilesizearray[
'max'];
239 $maxmin = $maxfilesizearray[
'maxmin'];
240 $maxphptoshow = $maxfilesizearray[
'maxphptoshow'];
241 $maxphptoshowparam = $maxfilesizearray[
'maxphptoshowparam'];
243 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
245 $out .=
'<input class="flat minwidth400 maxwidth200onsmartphone" type="file"';
246 $out .= ((
getDolGlobalString(
'MAIN_DISABLE_MULTIPLE_FILEUPLOAD') || $disablemulti) ?
' name="userfile"' :
' name="userfile[]" multiple');
248 $out .= (!empty($accept) ?
' accept="'.$accept.
'"' :
' accept=""');
249 $out .= (!empty($capture) ?
' capture="capture"' :
'');
253 $langs->load(
'link');
254 $out .=
'<span class="nowraponsmartphone"><input style="margin-right: 2px;" type="checkbox" id="overwritefile" name="overwritefile" value="1">';
255 $out .=
'<label for="overwritefile" class="opacitylow paddingleft paddingright">'.$langs->trans(
"OverwriteIfExists").
'</label>';
258 $out .=
'<input type="submit" class="button smallpaddingimp reposition" name="sendit" value="'.$langs->trans(
"Upload").
'"';
264 $out .=
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
268 if ($perm && empty(
$conf->dol_optimize_smallscreen)) {
269 $langs->load(
'other');
271 $menudolibarrsetupmax = $langs->transnoentitiesnoconv(
"Home").
' - '.$langs->transnoentitiesnoconv(
"Setup").
' - '.$langs->transnoentitiesnoconv(
"Security");
273 $tooltiptext = $langs->trans(
"ThisLimitIsDefinedInSetupAt", $menudolibarrsetupmax, $max, $maxphptoshowparam, $maxphptoshow);
275 $tooltiptext .=
'<br><br>Option to extract the file content in text to save it in database is ON <span class="opacitymedium">('.getDolGlobalString(
'MAIN_SAVE_FILE_CONTENT_AS_TEXT').
')</span>';
279 $out .=
info_admin($tooltiptext, 1, 0,
'1',
'classfortooltip');
282 $out .=
' ('.$langs->trans(
"UploadDisabled").
')';
284 $out .=
"</td></tr>";
286 if ($savingdocmask) {
288 $rename =
getDolGlobalString(
'MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT') ?
'' :
'checked';
291 if (!empty($options)) {
292 $out .=
'<td>'.$options.
'</td>';
294 $out .=
'<td valign="middle" class="nowrap">';
295 $out .=
'<input type="checkbox" '.$rename.
' class="savingdocmask" name="savingdocmask" id="savingdocmask" value="'.
dol_escape_js($savingdocmask).
'"> ';
296 $out .=
'<label class="opacitymedium small" for="savingdocmask">';
297 $out .= $langs->trans(
"SaveUploadedFileWithMask", preg_replace(
'/__file__/', $langs->transnoentitiesnoconv(
"OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv(
"OriginFileName"));
305 if (empty($usewithoutform)) {
307 if (empty($sectionid)) {
312 $parameters = array(
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url' => $url,
'perm' => $perm,
'options' => $options);
314 $res = $hookmanager->executeHooks(
'formattachOptionsUpload', $parameters,
$object);
316 $out =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').
'attacharea'.$htmlname)).
'">'.$out.
'</div>';
318 $out .= $hookmanager->resPrint;
320 $out .=
"\n</div><!-- End form class=formattachnewfile -->\n";
327 $out2 .=
"\n".
'<!-- Start form link new url --><div class="formlinknewurl">'.
"\n";
328 $langs->load(
'link');
330 if ($nooutput != 2) {
331 $title = $langs->trans(
"LinkANewFile");
335 if (empty($usewithoutform)) {
336 $out2 .=
'<form name="'.$htmlname.
'_link" id="'.$htmlname.
'_link" action="'.$url.
'" method="POST">'.
"\n";
337 $out2 .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
338 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_dir" name="link_section_dir" value="">'.
"\n";
339 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_id" name="link_section_id" value="'.$sectionid.
'">'.
"\n";
340 $out2 .=
'<input type="hidden" name="page_y" value="">'.
"\n";
343 $out2 .=
'<div class="valignmiddle">';
344 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
346 $out2 .=
'<label for="link">'.$langs->trans(
"URLToLink").
':</label> ';
348 $out2 .=
'<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans(
"URLToLink")).
'">';
350 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
352 $out2 .=
'<label for="label">'.$langs->trans(
"Label").
':</label> ';
354 $out2 .=
'<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans(
"Label")).
'">';
355 $out2 .=
'<input type="hidden" name="objecttype" value="'.$object->element.
'">';
356 $out2 .=
'<input type="hidden" name="objectid" value="'.$object->id.
'">';
358 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
359 $out2 .=
'<input type="submit" class="button smallpaddingimp reposition" name="linkit" value="'.$langs->trans(
"ToLink").
'"';
364 if (empty($usewithoutform)) {
365 $out2 .=
'<div class="clearboth"></div>';
366 $out2 .=
'</form><br>';
369 $parameters = array(
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url' => $url,
'perm' => $perm,
'options' => $options);
370 $res = $hookmanager->executeHooks(
'formattachOptions', $parameters,
$object);
372 $out2 =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').$htmlname)).
'">'.$out2.
'</div>';
374 $out2 .= $hookmanager->resPrint;
376 $out2 .=
"\n</div><!-- End form class=formlinknewurl -->\n";
380 if ($nooutput == 2) {
381 return array(
'formToUploadAFile' => $out,
'formToAddALink' => $out2);
382 } elseif ($nooutput) {
413 public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected =
'', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param =
'', $title =
'', $buttonlabel =
'', $codelang =
'')
416 $this->numoffiles = 0;
417 print $this->
showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
418 return $this->numoffiles;
448 public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected =
'', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param =
'', $title =
'', $buttonlabel =
'', $codelang =
'', $morepicto =
'',
$object =
null, $hideifempty = 0, $removeaction =
'remove_file', $tooltipontemplatecombo =
'')
453 if (!empty($iconPDF)) {
454 dol_syslog(__METHOD__.
": passing iconPDF parameter is deprecated", LOG_WARNING);
457 global $langs,
$conf, $user, $hookmanager;
461 if (is_object($hookmanager)) {
463 'modulepart' => &$modulepart,
464 'modulesubdir' => &$modulesubdir,
465 'filedir' => &$filedir,
466 'urlsource' => &$urlsource,
467 'genallowed' => &$genallowed,
468 'delallowed' => &$delallowed,
469 'modelselected' => &$modelselected,
470 'allowgenifempty' => &$allowgenifempty,
471 'forcenomultilang' => &$forcenomultilang,
472 'noform' => &$noform,
475 'buttonlabel' => &$buttonlabel,
476 'codelang' => &$codelang,
477 'morepicto' => &$morepicto,
478 'hideifempty' => &$hideifempty,
479 'removeaction' => &$removeaction
481 $reshook = $hookmanager->executeHooks(
'showDocuments', $parameters,
$object);
489 return $hookmanager->resPrint;
492 if (!is_object($form)) {
493 $form =
new Form($this->db);
496 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
499 if (!empty($iconPDF)) {
504 if (!preg_match(
'/entity\=[0-9]+/', $param)) {
505 $param .= ($param ?
'&' :
'').
'entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity);
508 $printer = ($user->hasRight(
'printing',
'read') &&
isModEnabled(
'printing'));
510 $hookmanager->initHooks(array(
'formfile'));
513 $file_list = array();
514 if (!empty($filedir)) {
515 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
517 if ($hideifempty && empty($file_list)) {
522 $forname =
'builddoc';
527 $out .=
"\n".
'<!-- Start show_document -->'.
"\n";
529 if (preg_match(
'/massfilesarea_/', $modulepart)) {
530 $out .=
'<div id="show_files"><br></div>'.
"\n";
531 $title = $langs->trans(
"MassFilesArea").
' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans(
"Hide").
')</a>';
532 $title .=
'<script nonce="'.getNonce().
'">
533 jQuery(document).ready(function() {
534 jQuery(\'#togglemassfilesarea\').click(function() {
535 if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown")
537 jQuery(\'#'.$modulepart.
'_table\').hide();
538 jQuery(\'#togglemassfilesarea\').attr("ref", "hidden");
539 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Show")).
')");
543 jQuery(\'#'.$modulepart.
'_table\').show();
544 jQuery(\'#togglemassfilesarea\').attr("ref","shown");
545 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Hide")).
')");
553 $titletoshow = $langs->trans(
"Documents");
554 if (!empty($title)) {
555 $titletoshow = ($title ==
'none' ?
'' : $title);
558 $submodulepart = $modulepart;
561 $tmp = explode(
':', $modulepart);
562 if (!empty($tmp[1])) {
563 $modulepart = $tmp[0];
564 $submodulepart = $tmp[1];
567 $addcolumforpicto = ($delallowed || $printer || $morepicto);
568 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
573 $modellist = array();
575 if ($modulepart ==
'company') {
577 if (is_array($genallowed)) {
578 $modellist = $genallowed;
580 include_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
583 } elseif ($modulepart ==
'propal') {
584 if (is_array($genallowed)) {
585 $modellist = $genallowed;
587 include_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
590 } elseif ($modulepart ==
'supplier_proposal') {
591 if (is_array($genallowed)) {
592 $modellist = $genallowed;
594 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
597 } elseif ($modulepart ==
'commande') {
598 if (is_array($genallowed)) {
599 $modellist = $genallowed;
601 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
604 } elseif ($modulepart ==
'expedition') {
605 if (is_array($genallowed)) {
606 $modellist = $genallowed;
608 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
611 } elseif ($modulepart ==
'reception') {
612 if (is_array($genallowed)) {
613 $modellist = $genallowed;
615 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
618 } elseif ($modulepart ==
'delivery') {
619 if (is_array($genallowed)) {
620 $modellist = $genallowed;
622 include_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
625 } elseif ($modulepart ==
'ficheinter') {
626 if (is_array($genallowed)) {
627 $modellist = $genallowed;
629 include_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
632 } elseif ($modulepart ==
'facture') {
633 if (is_array($genallowed)) {
634 $modellist = $genallowed;
636 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
639 } elseif ($modulepart ==
'contract') {
641 if (is_array($genallowed)) {
642 $modellist = $genallowed;
644 include_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
647 } elseif ($modulepart ==
'project') {
648 if (is_array($genallowed)) {
649 $modellist = $genallowed;
651 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
654 } elseif ($modulepart ==
'project_task') {
655 if (is_array($genallowed)) {
656 $modellist = $genallowed;
658 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
661 } elseif ($modulepart ==
'product') {
662 if (is_array($genallowed)) {
663 $modellist = $genallowed;
665 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
668 } elseif ($modulepart ==
'product_batch') {
669 if (is_array($genallowed)) {
670 $modellist = $genallowed;
672 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product_batch/modules_product_batch.class.php';
675 } elseif ($modulepart ==
'stock') {
676 if (is_array($genallowed)) {
677 $modellist = $genallowed;
679 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_stock.php';
682 } elseif ($modulepart ==
'hrm') {
683 if (is_array($genallowed)) {
684 $modellist = $genallowed;
686 include_once DOL_DOCUMENT_ROOT.
'/core/modules/hrm/modules_evaluation.php';
689 } elseif ($modulepart ==
'movement') {
690 if (is_array($genallowed)) {
691 $modellist = $genallowed;
693 include_once DOL_DOCUMENT_ROOT.
'/core/modules/movement/modules_movement.php';
696 } elseif ($modulepart ==
'export') {
697 if (is_array($genallowed)) {
698 $modellist = $genallowed;
700 include_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
702 $modellist = array();
704 } elseif ($modulepart ==
'commande_fournisseur' || $modulepart ==
'supplier_order') {
705 if (is_array($genallowed)) {
706 $modellist = $genallowed;
708 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
711 } elseif ($modulepart ==
'facture_fournisseur' || $modulepart ==
'supplier_invoice') {
713 if (is_array($genallowed)) {
714 $modellist = $genallowed;
716 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
719 } elseif ($modulepart ==
'supplier_payment') {
720 if (is_array($genallowed)) {
721 $modellist = $genallowed;
723 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
726 } elseif ($modulepart ==
'remisecheque') {
727 if (is_array($genallowed)) {
728 $modellist = $genallowed;
730 include_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
733 } elseif ($modulepart ==
'donation') {
734 if (is_array($genallowed)) {
735 $modellist = $genallowed;
737 include_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
740 } elseif ($modulepart ==
'member') {
741 if (is_array($genallowed)) {
742 $modellist = $genallowed;
744 include_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
747 } elseif ($modulepart ==
'agenda' || $modulepart ==
'actions') {
748 if (is_array($genallowed)) {
749 $modellist = $genallowed;
751 include_once DOL_DOCUMENT_ROOT.
'/core/modules/action/modules_action.php';
754 } elseif ($modulepart ==
'expensereport') {
755 if (is_array($genallowed)) {
756 $modellist = $genallowed;
758 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
761 } elseif ($modulepart ==
'unpaid') {
763 } elseif ($modulepart ==
'user') {
764 if (is_array($genallowed)) {
765 $modellist = $genallowed;
767 include_once DOL_DOCUMENT_ROOT.
'/core/modules/user/modules_user.class.php';
770 } elseif ($modulepart ==
'usergroup') {
771 if (is_array($genallowed)) {
772 $modellist = $genallowed;
774 include_once DOL_DOCUMENT_ROOT.
'/core/modules/usergroup/modules_usergroup.class.php';
779 $file =
dol_buildpath(
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
781 if (file_exists($file)) {
782 $res = include_once $file;
785 $file =
dol_buildpath(
'/'.$modulepart.
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
786 $res = include_once $file;
789 $class =
'ModelePDF'.ucfirst($submodulepart);
791 if (class_exists($class)) {
792 $modellist = call_user_func($class.
'::liste_modeles', $this->db);
794 dol_print_error($this->db,
"Bad value for modulepart '".$modulepart.
"' in showdocuments (class ".$class.
" for Doc generation not found)");
802 if (empty($buttonlabel)) {
803 $buttonlabel = $langs->trans(
'Generate');
806 if (
$conf->browser->layout ==
'phone') {
807 $urlsource .=
'#'.$forname.
'_form';
809 if (empty($noform)) {
810 $out .=
'<form action="'.$urlsource.
'" id="'.$forname.
'_form" method="post">';
812 $out .=
'<input type="hidden" name="action" value="builddoc">';
813 $out .=
'<input type="hidden" name="page_y" value="">';
814 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
819 $out .=
'<div class="div-table-responsive-no-min">';
820 $out .=
'<table class="liste formdoc noborder centpercent">';
822 $out .=
'<tr class="liste_titre">';
823 $addcolumforpicto = ($delallowed || $printer || $morepicto);
824 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
827 $out .=
'<th colspan="'.$colspan.
'" class="formdoc liste_titre maxwidthonsmartphone center">';
830 if (!empty($modellist)) {
832 $out .=
'<span class="hideonsmartphone">'.$langs->trans(
'Model').
' </span>';
833 if (is_array($modellist) && count($modellist) == 1) {
834 $arraykeys = array_keys($modellist);
835 $modelselected = $arraykeys[0];
837 $morecss =
'minwidth75 maxwidth200';
838 if (
$conf->browser->layout ==
'phone') {
839 $morecss =
'maxwidth100';
841 $out .= $form->selectarray(
'model', $modellist, $modelselected, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss, 1,
'', 0, 0);
842 if (
$conf->use_javascript_ajax) {
845 $out .= $form->textwithpicto(
'', $tooltipontemplatecombo, 1,
'help',
'marginrightonly', 0, 3,
'', 0);
847 $out .=
'<div class="float">'.$langs->trans(
"Files").
'</div>';
851 if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) &&
getDolGlobalInt(
'MAIN_MULTILANGS') && !$forcenomultilang && (!empty($modellist) || $showempty)) {
852 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
854 $defaultlang = ($codelang && $codelang !=
'auto') ? $codelang : $langs->getDefaultLang();
855 $morecss =
'maxwidth150';
856 if (
$conf->browser->layout ==
'phone') {
857 $morecss =
'maxwidth100';
859 $out .= $formadmin->select_language($defaultlang,
'lang_id', 0, array(), 0, 0, 0, $morecss);
865 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
866 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
867 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
868 $genbutton .=
' disabled';
871 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty(
$conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
872 $langs->load(
"errors");
873 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
878 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty(
$conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
881 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
887 if (!empty($hookmanager->hooks[
'formfile'])) {
888 foreach ($hookmanager->hooks[
'formfile'] as $module) {
889 if (method_exists($module,
'formBuilddocLineOptions')) {
898 $parameters = array(
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart);
899 if (is_object($hookmanager)) {
900 $reshook = $hookmanager->executeHooks(
'formBuilddocOptions', $parameters, $GLOBALS[
'object']);
901 $out .= $hookmanager->resPrint;
906 if (!empty($filedir)) {
907 $link_list = array();
909 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
910 $link =
new Link($this->db);
911 $sortfield = $sortorder =
'';
912 $res = $link->fetchAll($link_list,
$object->element,
$object->id, $sortfield, $sortorder);
915 $out .=
'<!-- html.formfile::showdocuments -->'.
"\n";
918 if ((!empty($file_list) || !empty($link_list) || preg_match(
'/^massfilesarea/', $modulepart))
921 $out .=
'<div class="titre paddingbottom">'.$titletoshow.
'</div>'.
"\n";
922 $out .=
'<div class="div-table-responsive-no-min">';
923 $out .=
'<table class="noborder centpercent" id="'.$modulepart.
'_table">'.
"\n";
927 if (is_array($file_list)) {
928 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string}> $file_list';
932 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
933 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
939 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
942 if (!empty($sortfield) && !empty($sortorder)) {
947 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $file_list';
949 require_once DOL_DOCUMENT_ROOT .
'/ecm/class/ecmfiles.class.php';
952 foreach ($file_list as $file) {
955 if (!empty($file[
'rowid']) && $user->hasRight(
'ecm',
'read')) {
959 $ecmfile->fetch($file[
'rowid']);
966 $relativepath = (
string) $file[
"name"];
968 $relativepath = (
string) $modulesubdir.
"/".$file[
"name"];
970 if ($modulepart ==
'export') {
971 $relativepath = (
string) $file[
"name"];
974 $tmpout =
'<tr class="oddeven'.((!$genallowed && $i == 1) ?
' trfirstline' :
'').
'">';
976 $documenturl =
getDolGlobalString(
'DOL_URL_ROOT_DOCUMENT_PHP', DOL_URL_ROOT.
'/document.php');
979 $imgpreview = $this->
showPreview($file, $modulepart, $relativepath, 0, $param.
'&preview=1');
980 $tmpout .=
'<td class="minwidth200 tdoverflowmax300">';
982 $tmpout .=
'<span class="spanoverflow widthcentpercentminusx valignmiddle">';
984 $tmpout .=
'<span class="spanoverflow">';
987 $tmpout .= $imgpreview;
990 if (is_object($ecmfile)) {
991 $tmpout .= $ecmfile->getNomUrl(1, $modulepart, 0, 0,
' documentdownload');
994 $tmpout .=
'<a class="documentdownload paddingright" ';
996 $tmpout .=
'target="_blank" ';
998 $tmpout .=
'href="'.$documenturl.
'?modulepart='.$modulepart.
'&file='.urlencode($relativepath).($param ?
'&'.$param :
'').
'"';
1000 if (preg_match(
'/text/', $mime)) {
1001 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
1003 $tmpout .=
' title="'.dol_escape_htmltag($file[
"name"]).
'"';
1005 $tmpout .=
img_mime($file[
"name"], $langs->trans(
"File").
': '.$file[
"name"]);
1006 $tmpout .=
dol_trunc($file[
"name"], 150);
1010 $tmpout .=
'</span>'.
"\n";
1012 $tmpout .= $imgpreview;
1018 $size = (!empty($file[
'size']) ? $file[
'size'] :
dol_filesize($filedir.
"/".$file[
"name"]));
1019 $tmpout .=
'<td class="nowraponall right" title="'.dolPrintHTML($size.
' '.$langs->trans(
"Bytes")).
'">'.
dol_print_size($size, 1, 1).
'</td>';
1022 $date = (!empty($file[
'date']) ? $file[
'date'] :
dol_filemtime($filedir.
"/".$file[
"name"]));
1023 $tmpout .=
'<td class="nowrap right">'.dol_print_date($date,
'dayhour',
'tzuser').
'</td>';
1026 $tmpout .=
'<td class="nowraponall">';
1027 if (!empty($file[
'share'])) {
1029 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
1030 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1034 $forcedownload =
getDolGlobalInt(
'MAIN_FORCE_DOWNLOAD_IN_HTML_FORMFILE');
1036 if (!empty($file[
'share'])) {
1037 $paramlink .=
'hashp='.$file[
'share'];
1039 if ($forcedownload) {
1040 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1043 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1045 $tmpout .=
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
1046 $tmpout .=
'<input type="text" class="quatrevingtpercentminusx width75 nopadding small downloadexternallink" id="downloadlink'.$file[
'rowid'].
'" name="downloadexternallink" title="'.
dol_escape_htmltag($langs->trans(
"FileSharedViaALink")).
'" value="'.
dol_escape_htmltag($fulllink).
'" spellcheck="false">';
1054 if ($delallowed || $printer || $morepicto) {
1055 $tmpout .=
'<td class="right nowraponall">';
1057 $tmpurlsource = preg_replace(
'/#[a-zA-Z0-9_]*$/',
'', $urlsource);
1058 $tmpout .=
'<a class="maginleftonly marginrightonly reposition" href="'.$tmpurlsource.((strpos($tmpurlsource,
'?') ===
false) ?
'?' :
'&').
'action='.urlencode($removeaction).
'&token='.
newToken().
'&file='.urlencode($relativepath);
1059 $tmpout .= ($param ?
'&'.$param :
'');
1062 $tmpout .=
'">'.img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
1065 $tmpout .=
'<a class="maginleftonly marginleftonly reposition" href="'.$urlsource.(strpos($urlsource,
'?') ?
'&' :
'?').
'action=print_file&token='.
newToken().
'&printer='.urlencode($modulepart).
'&file='.urlencode($relativepath);
1066 $tmpout .= ($param ?
'&'.$param :
'');
1067 $tmpout .=
'">'.img_picto($langs->trans(
"PrintFile", $relativepath),
'printer').
'</a>';
1070 $morepicto = preg_replace(
'/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto);
1071 $tmpout .= $morepicto;
1076 if (is_object($hookmanager)) {
1077 $addcolumforpicto = ($delallowed || $printer || $morepicto);
1078 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
1080 $parameters = array(
'tmpout' => &$tmpout,
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart,
'relativepath' => $relativepath);
1081 $res = $hookmanager->executeHooks(
'formBuilddocLineOptions', $parameters, $file);
1083 $tmpout .= $hookmanager->resPrint;
1086 $tmpout = $hookmanager->resPrint;
1095 $this->numoffiles++;
1098 if (is_array($link_list)) {
1101 foreach ($link_list as $file) {
1102 $out .=
'<tr class="oddeven">';
1103 $out .=
'<td colspan="'.$colspan.
'" class="maxwidhtonsmartphone">';
1104 $out .=
'<a data-ajax="false" href="'.$file->url.
'" target="_blank" rel="noopener noreferrer">';
1105 $out .= $file->label;
1108 $out .=
'<td class="right">';
1112 $out .=
'<td></td>';
1113 if ($delallowed || $printer || $morepicto) {
1114 $out .=
'<td></td>';
1116 $out .=
'</tr>'.
"\n";
1118 $this->numoffiles++;
1121 if (count($file_list) == 0 && count($link_list) == 0 && $headershown) {
1122 $out .=
'<tr><td colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>'.
"\n";
1128 $out .=
"</table>\n";
1131 if (empty($noform)) {
1132 $out .=
'</form>'.
"\n";
1136 $out .=
'<!-- End show_document -->'.
"\n";
1139 jQuery(document).ready(function() {
1140 var selectedValue = $(".selectformat").val();
1142 if (selectedValue === "excel2007" || selectedValue === "tsv") {
1143 $(".forhide").prop("disabled", true).hide();
1145 $(".forhide").prop("disabled", false).show();
1166 public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
'', $morecss =
'valignmiddle', $allfiles = 0)
1168 global
$conf, $langs;
1170 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1173 $this->infofiles = array(
'nboffiles' => 0,
'extensions' => array(),
'files' => array());
1180 preg_match(
'/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,
'/').
'$/', $filedir, $regs);
1181 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
1186 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/');
1188 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/').
'\.';
1190 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
1194 $out .=
'<!-- html.formfile::getDocumentsLink -->'.
"\n";
1195 if (!empty($file_list)) {
1196 $out =
'<dl class="dropdown inline-block">
1197 <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto(
'',
'listlight',
'', 0, 0, 0,
'', $morecss).
'</a></dt>
1198 <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
1204 foreach ($file_list as $file) {
1206 if ($filter && !preg_match(
'/'.$filter.
'/i', $file[
"name"])) {
1212 $relativepath = $file[
"name"];
1213 if ($modulesubdir) {
1214 $relativepath = (
string) $modulesubdir.
"/".$file[
"name"];
1217 if ($modulepart ==
'donation') {
1218 $relativepath = (
string)
get_exdir($modulesubdir, 2, 0, 0,
null,
'donation').$file[
"name"];
1220 if ($modulepart ==
'export') {
1221 $relativepath = (
string) $file[
"name"];
1224 $this->infofiles[
'nboffiles']++;
1225 $this->infofiles[
'files'][] = $file[
'fullname'];
1226 $ext = (
string) pathinfo($file[
'name'], PATHINFO_EXTENSION);
1227 if (!array_key_exists($ext, $this->infofiles[
'extensions'])) {
1228 $this->infofiles[
'extensions'][$ext] = 1;
1230 $this->infofiles[
'extensions'][$ext]++;
1234 if (!empty(
$conf->use_javascript_ajax) && (
$conf->browser->layout !=
'phone')) {
1236 if ($tmparray && $tmparray[
'url']) {
1237 $tmpout .=
'<li><a href="'.$tmparray[
'url'].
'"'.($tmparray[
'css'] ?
' class="'.$tmparray[
'css'].
'"' :
'').($tmparray[
'mime'] ?
' mime="'.$tmparray[
'mime'].
'"' :
'').($tmparray[
'target'] ?
' target="'.$tmparray[
'target'].
'"' :
'').
'>';
1239 $tmpout .=
img_picto(
'',
'search-plus',
'class="paddingright"');
1240 $tmpout .= $langs->trans(
"Preview").
' '.$ext.
'</a></li>';
1245 $tmpout .=
'<li class="nowrap"><a class="pictopreview nowrap" ';
1247 $tmpout .=
'target="_blank" ';
1249 $tmpout .=
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($relativepath).
'"';
1251 if (preg_match(
'/text/', $mime)) {
1252 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
1255 $tmpout .=
img_mime($relativepath, $file[
"name"]);
1256 $tmpout .= $langs->trans(
"Download").
' '.$ext;
1257 $tmpout .=
'</a></li>'.
"\n";
1260 $out .=
'</ul></div></dd>
1309 public function list_of_documents($filearray,
$object, $modulepart, $param =
'', $forcedownload = 0, $relativepath =
'', $permonobject = 1, $useinecm = 0, $textifempty =
'', $maxlength = 0, $title =
'', $url =
'', $showrelpart = 0, $permtoeditline = -1, $upload_dir =
'', $sortfield =
'', $sortorder =
'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1, $moreattrondiv =
'', $moreoptions = array())
1312 global $user,
$conf, $langs, $hookmanager, $form;
1313 global $sortfield, $sortorder;
1316 if ($disablecrop == -1) {
1319 if (in_array($modulepart, array(
'bank',
'bom',
'expensereport',
'facture',
'facture_fournisseur',
'holiday',
'medias',
'member',
'mrp',
'project',
'product',
'produit',
'propal',
'service',
'societe',
'tax',
'tax-vat',
'ticket',
'user'))) {
1325 if (empty($relativepath)) {
1328 $relativepath = (
$object->id).
'/';
1329 } elseif (!empty(
$object->element) &&
$object->element ==
'invoice_supplier') {
1331 } elseif (!empty(
$object->element) &&
$object->element ==
'project_task') {
1332 $relativepath =
'Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1336 if (
getDolGlobalInt(
'PRODUCT_USE_OLD_PATH_FOR_PHOTO') && isset($filearray[0]) && $filearray[0][
'level1name'] ==
'photos') {
1337 $relativepath = preg_replace(
'/^.*\/produit\//',
'', $filearray[0][
'path']).
'/';
1343 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $upload_dir);
1344 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1351 $hookmanager->initHooks(array(
'formfile'));
1352 $parameters = array(
1353 'filearray' => $filearray,
1354 'modulepart' => $modulepart,
1356 'forcedownload' => $forcedownload,
1357 'relativepath' => $relativepath,
1358 'relativedir' => $relativedir,
1359 'permtodelete' => $permonobject,
1360 'useinecm' => $useinecm,
1361 'textifempty' => $textifempty,
1362 'maxlength' => $maxlength,
1367 $reshook = $hookmanager->executeHooks(
'showFilesList', $parameters,
$object);
1369 if (!empty($reshook)) {
1372 if (!is_object($form)) {
1373 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1374 $form =
new Form($this->db);
1377 if (!preg_match(
'/&id=/', $param) && isset(
$object->id)) {
1378 $param .=
'&id='.$object->id;
1380 $relativepathwihtoutslashend = preg_replace(
'/\/$/',
'', $relativepath);
1381 if ($relativepathwihtoutslashend) {
1382 $param .=
'&file='.urlencode($relativepathwihtoutslashend);
1385 if ($permtoeditline < 0) {
1386 $permtoeditline = 0;
1387 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1388 '@phan-var-force Product $object';
1390 $permtoeditline = 1;
1393 $permtoeditline = 1;
1398 $permtoeditline = 0;
1402 $url = $_SERVER[
"PHP_SELF"];
1407 $morehtmlright =
'';
1408 if (!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) {
1409 $tmpurlforbutton =
'javascript:console.log("open add file form"); if (jQuery(".divattachnewfile").is(":hidden")) { jQuery(".divattachnewfile").removeClass("hidden"); jQuery(".divattachnewfile input[type=\'file\']").first().click(); } else { jQuery(".divattachnewfile").addClass("hidden"); } void(0);';
1410 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $tmpurlforbutton,
'', $permtoeditline);
1413 if ((empty($useinecm) || $useinecm == 3 || $useinecm == 6) && $title !=
'none') {
1414 print
load_fiche_titre($title ? $title : $langs->trans(
"AttachedFiles"), $morehtmlright,
'file-upload', 0,
'',
'table-list-of-attached-files');
1416 if (!empty($moreoptions) && $moreoptions[
'afteruploadtitle']) {
1417 print
'<!-- Add form from $moreoptions[\'afteruploadtitle\'] -->';
1418 print
'<div class="divattachnewfile'.((!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afteruploadtitle'].
'</div>';
1422 print
'<!-- html.formfile::list_of_documents -->'.
"\n";
1423 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1424 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?'.$param.
'" method="POST">';
1425 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1426 print
'<input type="hidden" name="action" value="renamefile">';
1427 print
'<input type="hidden" name="id" value="'.(is_object(
$object) ?
$object->id :
'').
'">';
1428 print
'<input type="hidden" name="modulepart" value="'.$modulepart.
'">';
1431 print
'<div class="div-table-responsive-no-min"'.($moreattrondiv ?
' '.$moreattrondiv :
'').
'>';
1432 print
'<table id="tablelines" class="centpercent liste noborder nobottom">'.
"\n";
1434 if (!empty($addfilterfields)) {
1435 print
'<tr class="liste_titre nodrag nodrop">';
1436 print
'<td><input type="search_doc_ref" value="'.dol_escape_htmltag(
GETPOST(
'search_doc_ref',
'alpha')).
'"></td>';
1439 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1444 if (empty($disablemove) && count($filearray) > 1) {
1453 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $filearray';
1456 if ($sortfield && $sortorder) {
1457 $filearray =
dol_sort_array($filearray, $sortfield, $sortorder, 1);
1461 print
'<tr class="liste_titre nodrag nodrop">';
1469 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1473 if (empty($moreoptions[
'hideshared'])) {
1478 if (!empty($moreoptions[
'buttons'])) {
1483 if (empty($disablemove) && count($filearray) > 1) {
1489 $nboffiles = count($filearray);
1490 if ($nboffiles > 0) {
1491 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1497 $parametersByDefault = array(
1498 'modulepart' => $modulepart,
1499 'relativepath' => $relativepath,
1500 'permtoedit' => $permtoeditline,
1501 'permonobject' => $permonobject,
1503 foreach ($filearray as $key => $file) {
1504 if ($file[
'name'] !=
'.' && $file[
'name'] !=
'..' && !preg_match(
'/\.meta$/i', $file[
'name'])) {
1505 if (array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) {
1506 $lastrowid = $filearray[$key][
'rowid'];
1511 $modulepart = ($file[
'modulepart'] ?? $parametersByDefault[
'modulepart']);
1512 $relativepath = ($file[
'relativepath'] ?? $parametersByDefault[
'relativepath']);
1513 $permtoeditline = ($file[
'permtoedit'] ?? $parametersByDefault[
'permtoedit']);
1514 $permonobject = ($file[
'permonobject'] ?? $parametersByDefault[
'permonobject']);
1517 if (empty($relativepath) || empty($modulepart)) {
1518 $filepath = $file[
'level1name'].
'/'.$file[
'name'];
1520 $filepath = $relativepath.$file[
'name'];
1522 if (empty($modulepart)) {
1523 $modulepart = basename(dirname($file[
'path']));
1525 if (empty($relativepath)) {
1526 $relativepath = preg_replace(
'/\/(.+)/',
'', $filepath) .
'/';
1531 print
'<!-- Line list_of_documents '.$key.
' relativepath = '.$relativepath.
' -->'.
"\n";
1534 print
'<!-- In database: position='.(array_key_exists(
'position', $filearray[$key]) ? $filearray[$key][
'position'] : 0).
' -->'.
"\n";
1535 print
'<tr class="oddeven" id="row-'.((array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) ? $filearray[$key][
'rowid'] :
'AFTER'.$lastrowid.
'POS'.($i + 1)).
'">';
1539 print
'<td class="minwidth200imp tdoverflowmax500" title="'.dolPrintHTMLForAttribute($file[
'name']).
'">';
1543 print
'<a class="paddingright valignmiddle" ';
1545 print
'target="_blank" ';
1547 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.urlencode($modulepart);
1548 if ($forcedownload) {
1549 print
'&attachment=1';
1551 if (!empty(
$object->entity)) {
1552 print
'&entity='.((int)
$object->entity);
1554 print
'&file='.urlencode($filepath);
1556 print
img_mime($file[
'name'], $file[
'name'].
' ('.
dol_print_size($file[
'size'], 0, 0).
')',
'inline-block valignmiddle paddingright');
1557 if ($showrelpart == 1) {
1558 print $relativepath;
1564 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $file[
'name'] == basename(
GETPOST(
'urlfile',
'alpha')) && dirname($filepath) == dirname(
GETPOST(
'urlfile',
'alpha'))) {
1566 $section_dir = dirname(
GETPOST(
'urlfile',
'alpha'));
1567 if (!preg_match(
'/\/$/', $section_dir)) {
1568 $section_dir .=
'/';
1570 print
'<input type="hidden" name="section_dir" value="'.$section_dir.
'">';
1571 print
'<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file[
'name']).
'">';
1572 print
'<input type="text" name="renamefileto" class="centpercentminusx" value="'.dol_escape_htmltag($file[
'name']).
'" spellcheck="false">';
1575 $filenametoshow = preg_replace(
'/\.noexe$/',
'', $file[
'name']);
1589 print
'<td class="right nowraponall">';
1590 if ($sizetoshow == $sizetoshowbytes) {
1593 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1598 print
'<td class="center nowraponall">'.dol_print_date($file[
'date'],
"dayhour",
"tzuser").
'</td>';
1601 $fileinfo = pathinfo($file[
'name']);
1602 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1603 print
'<td class="center">';
1605 if ($useinecm == 5 || $useinecm == 6) {
1618 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity));
1619 if (empty($urlforhref)) {
1620 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
1621 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
1623 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
1625 print
'<img class="photo maxwidth200 shadow valignmiddle"';
1626 if ($useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1627 print
' height="20"';
1630 print
' style="max-height: 24px"';
1632 print
' src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity).
'&file='.urlencode($relativepath.$smallfile);
1633 if (!empty($filearray[$key][
'date'])) {
1634 print
'&cache='.urlencode((
string) $filearray[$key][
'date']);
1636 print
'" title="">';
1643 if (empty($moreoptions[
'hideshared'])) {
1644 print
'<td class="center nowraponsmartphone">';
1645 if ($relativedir && $filearray[$key][
'rowid'] > 0) {
1647 print
'<label for="idshareenabled'.$key.
'">'.$langs->trans(
"FileSharedViaALink").
'</label> ';
1648 print
'<input class="inline-block" type="checkbox" id="idshareenabled'.$key.
'" name="shareenabled"'.($file[
'share'] ?
' checked="checked"' :
'').
' /> ';
1650 if ($file[
'share']) {
1652 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
1653 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1657 $forcedownload =
getDolGlobalInt(
'MAIN_FORCE_DOWNLOAD_IN_HTML_FORMFILE');
1659 if (!empty($file[
'share'])) {
1660 $paramlink .=
'hashp='.$file[
'share'];
1662 if ($forcedownload) {
1663 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1666 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1668 print
'<!-- shared link -->';
1669 print
'<a href="'.$fulllink.
'" target="_blank" rel="noopener" data-showidonhover="downloadlink'.$filearray[$key][
'rowid'].
'">';
1670 print
img_picto($langs->trans(
"FileSharedViaALink"),
'collab');
1672 print
'<input type="text" class="centpercentminusx minwidth50imp nopadding small downloadexternallink showonhover" id="downloadlink'.$filearray[$key][
'rowid'].
'" name="downloadexternallink" title="'.
dol_escape_htmltag($langs->trans(
"FileSharedViaALink")).
'" value="'.
dol_escape_htmltag($fulllink).
'" spellcheck="false">';
1682 if (!empty($moreoptions[
'buttons'])) {
1684 foreach ($moreoptions[
'buttons'] as $moreoptval) {
1685 print
'<a href="'.$moreoptval[
'url'].
'&urlfile='.urlencode($file[
'name']).
'">';
1686 print $moreoptval[
'picto'];
1696 print
'<td class="valignmiddle right actionbuttons nowraponall"><!-- action on files -->';
1697 if ($useinecm == 1 || $useinecm == 5) {
1699 $newparam = preg_replace(
'/&file=.*$/',
'', $param);
1700 $backtopage = DOL_URL_ROOT.
'/ecm/index.php?§ion_dir='.urlencode($relativepath).$newparam;
1701 print
'<a class="editfielda editfilelink" href="'.DOL_URL_ROOT.
'/ecm/file_card.php?urlfile='.urlencode($file[
'name']).$param.
'&backtopage='.urlencode($backtopage).
'" rel="'.urlencode($file[
'name']).
'">'.
img_edit(
'default', 0,
'class="paddingrightonly"').
'</a>';
1704 if (empty($useinecm) || $useinecm == 2 || $useinecm == 3 || $useinecm == 6) {
1705 $newmodulepart = $modulepart;
1706 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1707 $newmodulepart =
'produit|service';
1710 if ($permtoeditline) {
1711 $moreparaminurl =
'';
1713 $moreparaminurl .=
'&id='.$object->id;
1714 } elseif (
GETPOST(
'website',
'alpha')) {
1715 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1718 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1719 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1722 if (!preg_match(
'/\.webp$/i', $file[
'name'])) {
1723 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1724 print
'<a href="'.DOL_URL_ROOT.
'/ecm/index_medias.php?action=confirmconvertimgwebp&token='.
newToken().
'§ion_dir='.urlencode($relativepath).
'&filetoregenerate='.urlencode($fileinfo[
'basename']).
'&module='.$modulepart.$param.$moreparaminurl.
'" title="'.
dol_escape_htmltag($langs->trans(
"GenerateChosenImgWebp")).
'">'.
img_picto(
'',
'images',
'class="flip marginrightonly"').
'</a>';
1725 } elseif ($modulepart ==
'medias' &&
GETPOST(
'website')) {
1726 print
'<a href="'.DOL_URL_ROOT.
'/website/index.php?action=confirmconvertimgwebp&token='.
newToken().
'§ion_dir='.urlencode($relativepath).
'&filetoregenerate='.urlencode($fileinfo[
'basename']).
'&module='.$modulepart.$param.$moreparaminurl.
'" title="'.
dol_escape_htmltag($langs->trans(
"GenerateChosenImgWebp")).
'">'.
img_picto(
'',
'images',
'class="flip marginrightonly"').
'</a>';
1732 if ($permtoeditline) {
1734 $moreparaminurl =
'';
1736 $moreparaminurl .=
'&id='.$object->id;
1737 } elseif (
GETPOST(
'website',
'alpha')) {
1738 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1741 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1742 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1745 print
'<a class="editfielda" href="'.DOL_URL_ROOT.
'/core/photos_resize.php?modulepart='.urlencode($newmodulepart).$moreparaminurl.
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension'])).
'" title="'.
dol_escape_htmltag($langs->trans(
"ResizeOrCrop")).
'">'.
img_picto($langs->trans(
"ResizeOrCrop"),
'resize',
'class="paddingrightonly"').
'</a>';
1749 if ($permtoeditline) {
1750 $paramsectiondir = (in_array($modulepart, array(
'medias',
'ecm')) ?
'§ion_dir='.urlencode($relativepath) :
'');
1751 print
'<a class="editfielda reposition editfilelink paddingright marginleftonly" href="'.(($useinecm == 1 || $useinecm == 5) ?
'#' : ($url.
'?action=editfile&urlfile='.urlencode($filepath).$paramsectiondir.$param)).
'" rel="'.$filepath.
'">'.
img_edit(
'default', 0,
'class="paddingrightonly"').
'</a>';
1755 if ($permonobject) {
1757 if (!empty(
$conf->dol_use_jmobile)) {
1760 if (empty(
$conf->use_javascript_ajax)) {
1767 print
'<a href="'.((($useinecm && $useinecm != 3 && $useinecm != 6) && $useajax) ?
'#' : ($url.
'?action=deletefile&token='.
newToken().
'&urlfile='.urlencode($filepath).$param)).
'" class="reposition deletefilelink paddingright marginleftonly" rel="'.$filepath.
'">'.
img_delete().
'</a>';
1771 if (empty($disablemove) && count($filearray) > 1) {
1772 if ($nboffiles > 1 &&
$conf->browser->layout !=
'phone') {
1773 print
'<td class="linecolmove tdlineupdown center">';
1775 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=up&token='.
newToken().
'&rowid='.
$object->id.
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
1777 if ($i < ($nboffiles - 1)) {
1778 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=down&token='.
newToken().
'&rowid='.
$object->id.
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
1782 print
'<td'.(($conf->browser->layout !=
'phone') ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'>';
1787 print
'<td class="right">';
1788 print
'<input type="hidden" name="ecmfileid" value="'.(empty($filearray[$key][
'rowid']) ?
'' : $filearray[$key][
'rowid']).
'">';
1789 print
'<input type="submit" class="button button-save smallpaddingimp" name="renamefilesave" value="'.dolPrintHTMLForAttribute($langs->transnoentitiesnoconv(
"Save")).
'">';
1790 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.dolPrintHTMLForAttribute($langs->transnoentitiesnoconv(
"Cancel")).
'">';
1792 if (empty($disablemove) && count($filearray) > 1) {
1793 print
'<td class="right"></td>';
1801 if ($nboffiles == 0) {
1803 if (!empty($moreoptions[
'buttons'])) {
1806 if (!empty($moreoptions[
'hideshared'])) {
1809 if (empty($disablemove) && count($filearray) > 1) {
1812 print
'<tr class="oddeven"><td colspan="'.$colspan.
'">';
1813 if (empty($textifempty)) {
1814 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
1816 print
'<span class="opacitymedium">'.dolPrintHTML($textifempty).
'</span>';
1824 if ($nboflines > 1 && is_object(
$object)) {
1825 if (!empty(
$conf->use_javascript_ajax) && $permtoeditline) {
1826 $table_element_line =
'ecm_files';
1827 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1833 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1861 public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath =
'', $permissiontodelete = 1, $useinecm = 0, $textifempty =
'', $maxlength = 0, $url =
'', $addfilterfields = 0)
1864 global
$conf, $langs, $hookmanager, $form;
1865 global $sortfield, $sortorder;
1866 global $search_doc_ref;
1867 global $search_doc_date_start, $search_doc_date_end;
1870 dol_syslog(get_class($this).
'::list_of_autoecmfiles upload_dir='.$upload_dir.
' modulepart='.$modulepart);
1873 if (empty($useinecm) || $useinecm == 6) {
1877 $url = $_SERVER[
"PHP_SELF"];
1880 $enablebulkdownload = ($modulepart ==
'invoice_supplier');
1882 if (!empty($addfilterfields)) {
1883 print
'<form action="'.dol_escape_htmltag($url).
'" method="'.($enablebulkdownload ?
'POST' :
'GET').
'">';
1884 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1885 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($modulepart).
'">';
1887 print
'<input type="hidden" name="sortfield" value="'.dol_escape_htmltag($sortfield).
'">';
1890 print
'<input type="hidden" name="sortorder" value="'.dol_escape_htmltag($sortorder).
'">';
1894 print
'<div class="div-table-responsive-no-min">';
1895 print
'<table class="noborder centpercent">'.
"\n";
1897 if (!empty($addfilterfields)) {
1898 print
'<tr class="liste_titre nodrag nodrop">';
1899 if ($enablebulkdownload) {
1900 print
'<td class="liste_titre center">';
1901 print $form->showCheckAddButtons(
'checkforselect', 0);
1905 print
'<td class="liste_titre"></td>';
1907 print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1909 print
'<td class="liste_titre"></td>';
1911 print
'<td class="liste_titre center">';
1912 if ($enablebulkdownload) {
1913 print
'<div class="nowrap">';
1914 print $form->selectDate(!empty($search_doc_date_start) ? $search_doc_date_start :
'',
'search_doc_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
1916 print
'<div class="nowrap">';
1917 print $form->selectDate(!empty($search_doc_date_end) ? $search_doc_date_end :
'',
'search_doc_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
1922 print
'<td class="liste_titre right">';
1923 if ($enablebulkdownload) {
1924 print
'<button type="submit" class="button smallpaddingimp marginrightonly" name="action" value="download_selected">';
1925 print
img_picto(
'',
'download',
'class="pictofixedwidth"').$langs->trans(
"Download");
1928 $searchpicto = $form->showFilterButtons();
1934 print
'<tr class="liste_titre">';
1935 if ($enablebulkdownload) {
1936 print
'<th class="liste_titre center maxwidthsearch"></th>';
1938 $sortref =
"fullname";
1939 if ($modulepart ==
'invoice_supplier') {
1940 $sortref =
'level1name';
1950 $object_instance =
null;
1951 if ($modulepart ==
'company') {
1952 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1953 $object_instance =
new Societe($this->db);
1954 } elseif ($modulepart ==
'invoice') {
1955 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1956 $object_instance =
new Facture($this->db);
1957 } elseif ($modulepart ==
'invoice_supplier') {
1958 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1960 } elseif ($modulepart ==
'propal') {
1961 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
1962 $object_instance =
new Propal($this->db);
1963 } elseif ($modulepart ==
'supplier_proposal') {
1964 include_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
1966 } elseif ($modulepart ==
'order') {
1967 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1968 $object_instance =
new Commande($this->db);
1969 } elseif ($modulepart ==
'order_supplier') {
1970 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1972 } elseif ($modulepart ==
'contract') {
1973 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1974 $object_instance =
new Contrat($this->db);
1975 } elseif ($modulepart ==
'product') {
1976 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1977 $object_instance =
new Product($this->db);
1978 } elseif ($modulepart ==
'tax') {
1979 include_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
1981 } elseif ($modulepart ==
'tax-vat') {
1982 include_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
1983 $object_instance =
new Tva($this->db);
1984 } elseif ($modulepart ==
'salaries') {
1985 include_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
1986 $object_instance =
new Salary($this->db);
1987 } elseif ($modulepart ==
'project') {
1988 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1989 $object_instance =
new Project($this->db);
1990 } elseif ($modulepart ==
'project_task') {
1991 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1992 $object_instance =
new Task($this->db);
1993 } elseif ($modulepart ==
'fichinter') {
1994 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
1995 $object_instance =
new Fichinter($this->db);
1996 } elseif ($modulepart ==
'user') {
1997 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1998 $object_instance =
new User($this->db);
1999 } elseif ($modulepart ==
'expensereport') {
2000 include_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
2002 } elseif ($modulepart ==
'holiday') {
2003 include_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
2004 $object_instance =
new Holiday($this->db);
2005 } elseif ($modulepart ==
'recruitment-recruitmentcandidature') {
2006 include_once DOL_DOCUMENT_ROOT.
'/recruitment/class/recruitmentcandidature.class.php';
2008 } elseif ($modulepart ==
'banque') {
2009 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
2010 $object_instance =
new Account($this->db);
2011 } elseif ($modulepart ==
'bank-statement') {
2013 $object_instance =
null;
2014 } elseif ($modulepart ==
'chequereceipt') {
2015 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
2017 } elseif ($modulepart ==
'mrp-mo') {
2018 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
2019 $object_instance =
new Mo($this->db);
2021 $parameters = array(
'modulepart' => $modulepart);
2022 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
2023 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
2024 if (array_key_exists(
'classpath', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classpath'])) {
2026 if (array_key_exists(
'classname', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classname'])) {
2027 $tmpclassname = $hookmanager->resArray[
'classname'];
2028 if (is_string($tmpclassname) && class_exists($tmpclassname)) {
2029 $object_instance =
new $tmpclassname($this->db);
2040 $relativepathfromroot = preg_replace(
'/'.preg_quote(DOL_DATA_ROOT.
'/',
'/').
'/',
'', $upload_dir);
2041 if ($relativepathfromroot) {
2043 '@phan-var-force array<array{name:string,path:string,level1name:string,relativename:string,fullname:string,date:string,size:int,perm:int,type:string,position_name:string,cover:string,keywords:string,acl:string,rowid:int,label:string,share:string}> $filearray';
2046 if ($sortfield && $sortorder) {
2047 $filearray =
dol_sort_array($filearray, $sortfield, $sortorder, 1);
2053 foreach ($filearray as $key => $file) {
2054 if (!is_dir($file[
'name'])
2055 && $file[
'name'] !=
'.'
2056 && $file[
'name'] !=
'..'
2057 && $file[
'name'] !=
'CVS'
2058 && !preg_match(
'/\.meta$/i', $file[
'name'])) {
2060 $relativefile = preg_replace(
'/'.preg_quote($upload_dir.
'/',
'/').
'/',
'', $file[
'fullname']);
2068 if ($modulepart ==
'company' || $modulepart ==
'tax' || $modulepart ==
'tax-vat' || $modulepart ==
'salaries') {
2069 preg_match(
'/(\d+)\/[^\/]+$/', $relativefile, $reg);
2070 $id = (isset($reg[1]) ? $reg[1] :
'');
2071 } elseif ($modulepart ==
'invoice_supplier') {
2072 preg_match(
'/([^\/]+)\/[^\/]+$/', $relativefile, $reg);
2073 $ref = (isset($reg[1]) ? $reg[1] :
'');
2074 if (is_numeric($ref)) {
2078 } elseif ($modulepart ==
'user') {
2080 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
2081 $id = (isset($reg[1]) ? $reg[1] :
'');
2082 } elseif ($modulepart ==
'project_task') {
2084 $reg = explode(
"/", $relativefile);
2085 $ref = (isset($reg[1]) ? $reg[1] :
'');
2086 } elseif (in_array($modulepart, array(
2089 'supplier_proposal',
2098 'recruitment-recruitmentcandidature',
2103 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
2104 $ref = (isset($reg[1]) ? $reg[1] :
'');
2106 $parameters = array(
'modulepart' => $modulepart,
'fileinfo' => $file);
2107 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
2108 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
2109 if (array_key_exists(
'ref', $hookmanager->resArray) && !empty($hookmanager->resArray[
'ref'])) {
2110 $ref = $hookmanager->resArray[
'ref'];
2112 if (array_key_exists(
'id', $hookmanager->resArray) && !empty($hookmanager->resArray[
'id'])) {
2113 $id = $hookmanager->resArray[
'id'];
2119 if (!
$id && !$ref) {
2124 if (!empty(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2130 if (is_object($object_instance)) {
2131 $object_instance->id = 0;
2132 $object_instance->ref =
'';
2134 $result = $object_instance->fetch(
$id);
2136 $result = $object_instance->fetch(0, $ref);
2138 print $object_instance->error;
2139 } elseif ($result == 0) {
2145 $result = $object_instance->fetchOneLike($ref);
2152 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] = clone $object_instance;
2156 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] =
'notfound';
2157 unset($filearray[$key]);
2161 if ($found <= 0 || !is_object(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2164 if ($modulepart ==
'invoice_supplier' && (
int)
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref]->entity !== (
int)
$conf->entity) {
2168 print
'<!-- Line list_of_autoecmfiles key='.$key.
' -->'.
"\n";
2169 print
'<tr class="oddeven">';
2170 if ($enablebulkdownload) {
2171 print
'<td class="center">';
2172 print
'<input type="checkbox" class="flat checkforselect" name="selectedfiles[]" value="'.dol_escape_htmltag($relativefile).
'">';
2176 print
'<td class="tdoverflowmax150">';
2177 if ($found > 0 && is_object(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2178 $tmpobject =
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref];
2180 print $tmpobject->getNomUrl(1,
'document');
2185 print $langs->trans(
"ObjectDeleted", (
$id ?
$id : $ref));
2203 print
'target="_blank" ';
2205 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.urlencode($modulepart);
2206 if ($forcedownload) {
2207 print
'&attachment=1';
2209 print
'&file='.urlencode($relativefile).
'">';
2216 print $this->
showPreview($file, $modulepart, $file[
'relativename']);
2223 print
'<td class="right nowraponall">';
2224 if ($sizetoshow == $sizetoshowbytes) {
2227 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
2232 print
'<td class="center">'.dol_print_date($file[
'date'],
"dayhour").
'</td>';
2235 print
'<td class="right">';
2236 if (!empty($file[
'share'])) {
2238 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2239 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2243 $forcedownload =
getDolGlobalInt(
'MAIN_FORCE_DOWNLOAD_IN_HTML_FORMFILE');
2245 if (!empty($file[
'share'])) {
2246 $paramlink .=
'hashp='.$file[
'share'];
2248 if ($forcedownload) {
2249 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
2252 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
2254 print
'<!-- shared link -->';
2255 print
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
2256 print
'<input type="text" class="quatrevingtpercent width100 nopadding nopadding small downloadexternallink" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'" spellcheck="false">';
2270 if (count($filearray) == 0) {
2271 print
'<tr class="oddeven"><td colspan="'.($enablebulkdownload ?
'6' :
'5').
'">';
2272 if (empty($textifempty)) {
2273 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
2275 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
2282 if (!empty($addfilterfields)) {
2285 return count($filearray);
2301 public function listOfLinks(
$object, $permissiontodelete = 1, $action =
null, $selected =
null, $param =
'', $htmlname =
'formaddlink', $moreoptions = array())
2303 global
$conf, $langs;
2304 global $sortfield, $sortorder;
2306 $langs->load(
"link");
2308 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2309 $link =
new Link($this->db);
2311 if ($sortfield ==
"name") {
2312 $sortfield =
"label";
2313 } elseif ($sortfield ==
"date") {
2314 $sortfield =
"datea";
2318 $res = $link->fetchAll($links,
$object->element,
$object->id, $sortfield, $sortorder);
2319 $param .= (isset(
$object->id) && !preg_match(
'/&id='.
$object->id.
'/i', $param) ?
'&id='.$object->id :
'');
2321 $permissiontoedit = $permissiontodelete;
2323 print
'<!-- listOfLinks -->'.
"\n";
2325 $morehtmlright =
'';
2326 if (!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) {
2327 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
'javascript:console.log("open addlink form"); if (jQuery(".divlinkfile").is(":hidden")) { jQuery(".divlinkfile").removeClass("hidden"); } else { jQuery(".divlinkfile").addClass("hidden"); } void(0);',
'', $permissiontoedit);
2331 print
load_fiche_titre($langs->trans(
"LinkedFiles"), $morehtmlright,
'link', 0,
'',
'table-list-of-links');
2333 if (!empty($moreoptions) && $moreoptions[
'afterlinktitle']) {
2334 print
'<div class="divlinkfile'.((!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afterlinktitle'].
'</div>';
2337 print
'<form action="'.$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
'').
'" id="'.$htmlname.
'" method="POST">';
2338 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2339 print
'<div class="div-table-responsive-no-min">';
2341 print
'<table class="liste noborder nobottom centpercent">';
2342 print
'<tr class="liste_titre">';
2344 $langs->trans(
"Links"),
2345 $_SERVER[
'PHP_SELF'],
2366 $langs->trans(
"Date"),
2367 $_SERVER[
'PHP_SELF'],
2378 $_SERVER[
'PHP_SELF'],
2390 $nboflinks = count($links);
2391 if ($nboflinks > 0) {
2392 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2394 foreach ($links as $key => $link) {
2395 print
'<tr class="oddeven">';
2397 if ($action ==
'update' && (
int) $selected === (
int) $link->id && $permissiontoedit) {
2399 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2400 print
'<input type="hidden" name="linkid" value="'.$link->id.
'">';
2401 print
'<input type="hidden" name="action" value="confirm_updateline">';
2402 print $langs->trans(
'Link').
': <input type="text" name="link" value="'.$link->url.
'">';
2405 print $langs->trans(
'Label').
': <input type="text" name="label" value="'.
dol_escape_htmltag($link->label).
'">';
2407 print
'<td class="center">'.dol_print_date(
dol_now(),
"dayhour",
"tzuser").
'</td>';
2408 print
'<td class="right">';
2409 print
'<label for="idshareenabled'.$key.
'">'.$langs->trans(
"LinkSharedViaALink").
'</label> ';
2410 print
'<input class="inline-block" type="checkbox" id="idshareenabled'.$key.
'" name="shareenabled"'.($link->share ?
' checked="checked"' :
'').
' /> ';
2412 print
'<td class="right">';
2413 print
'<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2414 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2419 print
'<a data-ajax="false" href="'.$link->url.
'" target="_blank" rel="noopener noreferrer">';
2423 print
'<td class="right"></td>';
2424 print
'<td class="center">'.dol_print_date($link->datea,
"dayhour",
"tzuser").
'</td>';
2425 print
'<td class="center">';
2428 $urlwithouturlroot = preg_replace(
'/' . preg_quote(DOL_URL_ROOT,
'/') .
'$/i',
'', trim(
$dolibarr_main_url_root));
2429 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
2430 $fulllink = $urlwithroot.
'/document.php?type=link&hashp=' . $link->share;
2432 print
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
2433 print
'<input type="text" class="centpercentminusx minwidth200imp nopadding small downloadexternallink" id="downloadlink'.$link->id.
'" name="downloadexternallink" title="'.
dol_escape_htmltag($langs->trans(
"LinkSharedViaALink")).
'" value="'.
dol_escape_htmltag($fulllink).
'" spellcheck="false">';
2436 print
'<td class="right">';
2437 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=update&linkid='.$link->id.$param.
'&token='.
newToken().
'" class="editfilelink editfielda reposition" >'.
img_edit().
'</a>';
2438 if ($permissiontodelete) {
2439 print
' <a class="deletefilelink reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=deletelink&token='.
newToken().
'&linkid='.((int) $link->id).$param.
'">'.
img_delete().
'</a>';
2447 if ($nboflinks == 0) {
2448 print
'<tr class="oddeven"><td colspan="5">';
2449 print
'<span class="opacitymedium">'.$langs->trans(
"NoLinkFound").
'</span>';
2470 public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0, $param =
'')
2472 global $langs,
$conf;
2475 if ((
$conf->browser->layout !=
'phone' ||
getDolGlobalString(
'MAIN_SHOW_PREVIEW_PICTO_EVEN_ON_PHONE')) && !empty(
$conf->use_javascript_ajax)) {
2477 if (count($urladvancedpreview)) {
2478 $out .=
'<a class="pictopreview '.$urladvancedpreview[
'css'].
'" href="'.$urladvancedpreview[
'url'].
'"'.(empty($urladvancedpreview[
'mime']) ?
'' :
' mime="'.$urladvancedpreview[
'mime'].
'"').
' '.(empty($urladvancedpreview[
'target']) ?
'' :
' target="'.$urladvancedpreview[
'target'].
'"').
'>';
2480 if (empty($ruleforpicto)) {
2481 $out .=
img_picto(
'',
'search-plus',
'class="pictofixedwidth"');
2483 $out .=
img_mime($relativepath, $langs->trans(
'Preview').
' '.$file[
'name'],
'pictofixedwidth');
2487 if ($ruleforpicto < 0) {
2488 $out .=
img_picto(
'',
'generic',
'', 0, 0, 0,
'',
'paddingright pictofixedwidth');
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
global $dolibarr_main_url_root
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Class to manage bank accounts.
Class for managing the social charges.
Class to manage predefined suppliers products.
Class to manage customers orders.
Class to manage ECM files.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class of the module paid holiday.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class to manage projects.
Class to manage proposals.
Class for RecruitmentCandidature.
Class to manage cheque delivery receipts.
Class to manage salary payments.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage price ask supplier.
Class to manage VAT - Value-added tax (also known in French as TVA)
Class to manage Dolibarr users.
dol_filemtime($pathoffile)
Return time of a file.
dol_filesize($pathoffile)
Return size of a file.
completeFileArrayWithDatabaseInfo(&$filearray, $relativedir, $object=null)
Complete $filearray with data from database.
dol_is_file($pathoffile)
Return if path is a file.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_now($mode='gmt')
Return date for now.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
vignette($file, $maxWidth=160, $maxHeight=120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0)
Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp).
if(!defined( 'IMAGETYPE_WEBP')) getDefaultImageSizes()
Return default values for image sizes.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
getMaxFileSizeArray()
Return the max allowed for file upload.