67 $this->numoffiles = 0;
80 public function showImageToEdit(
string $htmlname,
string $modulepart,
string $dirformainimage,
string $subdirformainimage,
string $fileformainimage)
84 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
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.
'thumbs/'.$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.
'thumbs/'.$fileformainimagesmall).
'">';
125 } elseif (!empty($fileformainimage)) {
127 if (!file_exists($dirformainimage.
'/'.$subdirformainimage.
'thumbs/'.$fileformainimagemini)) {
128 $imgThumbMini =
vignette($dirformainimage.
'/'.$subdirformainimage.$fileformainimage, $maxwidthmini, $maxheightmini,
'_mini', $quality);
130 $imgThumbSmall =
vignette($dirformainimage.
'/'.$subdirformainimage.$fileformainimage, $maxwidthmini, $maxheightmini,
'_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 paddingright">'.$langs->trans(
"OverwriteIfExists").
'</label>';
258 $out .=
'<input type="submit" class="button small reposition" name="sendit" value="'.$langs->trans(
"Upload").
'"';
264 $out .=
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
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);
313 $res = $hookmanager->executeHooks(
'formattachOptionsUpload', $parameters,
$object);
315 $out =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').
'attacharea'.$htmlname)).
'">'.$out.
'</div>';
317 $out .= $hookmanager->resPrint;
319 $out .=
"\n</div><!-- End form class=formattachnewfile -->\n";
326 $out2 .=
"\n".
'<!-- Start form link new url --><div class="formlinknewurl">'.
"\n";
327 $langs->load(
'link');
329 if ($nooutput != 2) {
330 $title = $langs->trans(
"LinkANewFile");
334 if (empty($usewithoutform)) {
335 $out2 .=
'<form name="'.$htmlname.
'_link" id="'.$htmlname.
'_link" action="'.$url.
'" method="POST">'.
"\n";
336 $out2 .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
337 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_dir" name="link_section_dir" value="">'.
"\n";
338 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_id" name="link_section_id" value="'.$sectionid.
'">'.
"\n";
339 $out2 .=
'<input type="hidden" name="page_y" value="">'.
"\n";
342 $out2 .=
'<div class="valignmiddle">';
343 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
345 $out2 .=
'<label for="link">'.$langs->trans(
"URLToLink").
':</label> ';
347 $out2 .=
'<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans(
"URLToLink")).
'">';
349 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
351 $out2 .=
'<label for="label">'.$langs->trans(
"Label").
':</label> ';
353 $out2 .=
'<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans(
"Label")).
'">';
354 $out2 .=
'<input type="hidden" name="objecttype" value="'.$object->element.
'">';
355 $out2 .=
'<input type="hidden" name="objectid" value="'.$object->id.
'">';
357 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
358 $out2 .=
'<input type="submit" class="button small reposition" name="linkit" value="'.$langs->trans(
"ToLink").
'"';
363 if (empty($usewithoutform)) {
364 $out2 .=
'<div class="clearboth"></div>';
365 $out2 .=
'</form><br>';
368 $parameters = array(
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url' => $url,
'perm' => $perm,
'options' => $options);
369 $res = $hookmanager->executeHooks(
'formattachOptions', $parameters,
$object);
371 $out2 =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').$htmlname)).
'">'.$out2.
'</div>';
373 $out2 .= $hookmanager->resPrint;
375 $out2 .=
"\n</div><!-- End form class=formlinknewurl -->\n";
379 if ($nooutput == 2) {
380 return array(
'formToUploadAFile' => $out,
'formToAddALink' => $out2);
381 } elseif ($nooutput) {
412 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 =
'')
415 $this->numoffiles = 0;
416 print $this->
showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
417 return $this->numoffiles;
447 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 =
'')
449 global $dolibarr_main_url_root;
452 if (!empty($iconPDF)) {
453 dol_syslog(__METHOD__.
": passing iconPDF parameter is deprecated", LOG_WARNING);
456 global $langs,
$conf, $user, $hookmanager;
460 if (is_object($hookmanager)) {
462 'modulepart' => &$modulepart,
463 'modulesubdir' => &$modulesubdir,
464 'filedir' => &$filedir,
465 'urlsource' => &$urlsource,
466 'genallowed' => &$genallowed,
467 'delallowed' => &$delallowed,
468 'modelselected' => &$modelselected,
469 'allowgenifempty' => &$allowgenifempty,
470 'forcenomultilang' => &$forcenomultilang,
471 'noform' => &$noform,
474 'buttonlabel' => &$buttonlabel,
475 'codelang' => &$codelang,
476 'morepicto' => &$morepicto,
477 'hideifempty' => &$hideifempty,
478 'removeaction' => &$removeaction
480 $reshook = $hookmanager->executeHooks(
'showDocuments', $parameters,
$object);
488 return $hookmanager->resPrint;
491 if (!is_object($form)) {
492 $form =
new Form($this->db);
495 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
498 if (!empty($iconPDF)) {
503 if (!preg_match(
'/entity\=[0-9]+/', $param)) {
504 $param .= ($param ?
'&' :
'').
'entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity);
509 if (in_array($modulepart, array(
'contract',
'facture',
'supplier_proposal',
'propal',
'proposal',
'order',
'commande',
'expedition',
'commande_fournisseur',
'expensereport',
'delivery',
'ticket'))) {
510 $printer = ($user->hasRight(
'printing',
'read') && isModEnabled(
'printing'));
513 $hookmanager->initHooks(array(
'formfile'));
516 $file_list = array();
517 if (!empty($filedir)) {
518 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
520 if ($hideifempty && empty($file_list)) {
525 $forname =
'builddoc';
530 $out .=
"\n".
'<!-- Start show_document -->'.
"\n";
533 if (preg_match(
'/massfilesarea_/', $modulepart)) {
534 $out .=
'<div id="show_files"><br></div>'.
"\n";
535 $title = $langs->trans(
"MassFilesArea").
' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans(
"Hide").
')</a>';
536 $title .=
'<script nonce="'.getNonce().
'">
537 jQuery(document).ready(function() {
538 jQuery(\'#togglemassfilesarea\').click(function() {
539 if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown")
541 jQuery(\'#'.$modulepart.
'_table\').hide();
542 jQuery(\'#togglemassfilesarea\').attr("ref", "hidden");
543 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Show")).
')");
547 jQuery(\'#'.$modulepart.
'_table\').show();
548 jQuery(\'#togglemassfilesarea\').attr("ref","shown");
549 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Hide")).
')");
557 $titletoshow = $langs->trans(
"Documents");
558 if (!empty($title)) {
559 $titletoshow = ($title ==
'none' ?
'' : $title);
562 $submodulepart = $modulepart;
565 $tmp = explode(
':', $modulepart);
566 if (!empty($tmp[1])) {
567 $modulepart = $tmp[0];
568 $submodulepart = $tmp[1];
571 $addcolumforpicto = ($delallowed || $printer || $morepicto);
572 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
577 $modellist = array();
579 if ($modulepart ==
'company') {
581 if (is_array($genallowed)) {
582 $modellist = $genallowed;
584 include_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
587 } elseif ($modulepart ==
'propal') {
588 if (is_array($genallowed)) {
589 $modellist = $genallowed;
591 include_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
594 } elseif ($modulepart ==
'supplier_proposal') {
595 if (is_array($genallowed)) {
596 $modellist = $genallowed;
598 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
601 } elseif ($modulepart ==
'commande') {
602 if (is_array($genallowed)) {
603 $modellist = $genallowed;
605 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
608 } elseif ($modulepart ==
'expedition') {
609 if (is_array($genallowed)) {
610 $modellist = $genallowed;
612 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
615 } elseif ($modulepart ==
'reception') {
616 if (is_array($genallowed)) {
617 $modellist = $genallowed;
619 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
622 } elseif ($modulepart ==
'delivery') {
623 if (is_array($genallowed)) {
624 $modellist = $genallowed;
626 include_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
629 } elseif ($modulepart ==
'ficheinter') {
630 if (is_array($genallowed)) {
631 $modellist = $genallowed;
633 include_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
636 } elseif ($modulepart ==
'facture') {
637 if (is_array($genallowed)) {
638 $modellist = $genallowed;
640 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
643 } elseif ($modulepart ==
'contract') {
645 if (is_array($genallowed)) {
646 $modellist = $genallowed;
648 include_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
651 } elseif ($modulepart ==
'project') {
652 if (is_array($genallowed)) {
653 $modellist = $genallowed;
655 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
658 } elseif ($modulepart ==
'project_task') {
659 if (is_array($genallowed)) {
660 $modellist = $genallowed;
662 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
665 } elseif ($modulepart ==
'product') {
666 if (is_array($genallowed)) {
667 $modellist = $genallowed;
669 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
672 } elseif ($modulepart ==
'product_batch') {
673 if (is_array($genallowed)) {
674 $modellist = $genallowed;
676 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product_batch/modules_product_batch.class.php';
679 } elseif ($modulepart ==
'stock') {
680 if (is_array($genallowed)) {
681 $modellist = $genallowed;
683 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_stock.php';
686 } elseif ($modulepart ==
'hrm') {
687 if (is_array($genallowed)) {
688 $modellist = $genallowed;
690 include_once DOL_DOCUMENT_ROOT.
'/core/modules/hrm/modules_evaluation.php';
693 } elseif ($modulepart ==
'movement') {
694 if (is_array($genallowed)) {
695 $modellist = $genallowed;
697 include_once DOL_DOCUMENT_ROOT.
'/core/modules/movement/modules_movement.php';
700 } elseif ($modulepart ==
'export') {
701 if (is_array($genallowed)) {
702 $modellist = $genallowed;
704 include_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
706 $modellist = array();
708 } elseif ($modulepart ==
'commande_fournisseur' || $modulepart ==
'supplier_order') {
709 if (is_array($genallowed)) {
710 $modellist = $genallowed;
712 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
715 } elseif ($modulepart ==
'facture_fournisseur' || $modulepart ==
'supplier_invoice') {
717 if (is_array($genallowed)) {
718 $modellist = $genallowed;
720 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
723 } elseif ($modulepart ==
'supplier_payment') {
724 if (is_array($genallowed)) {
725 $modellist = $genallowed;
727 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
730 } elseif ($modulepart ==
'remisecheque') {
731 if (is_array($genallowed)) {
732 $modellist = $genallowed;
734 include_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
737 } elseif ($modulepart ==
'donation') {
738 if (is_array($genallowed)) {
739 $modellist = $genallowed;
741 include_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
744 } elseif ($modulepart ==
'member') {
745 if (is_array($genallowed)) {
746 $modellist = $genallowed;
748 include_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
751 } elseif ($modulepart ==
'agenda' || $modulepart ==
'actions') {
752 if (is_array($genallowed)) {
753 $modellist = $genallowed;
755 include_once DOL_DOCUMENT_ROOT.
'/core/modules/action/modules_action.php';
758 } elseif ($modulepart ==
'expensereport') {
759 if (is_array($genallowed)) {
760 $modellist = $genallowed;
762 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
765 } elseif ($modulepart ==
'unpaid') {
767 } elseif ($modulepart ==
'user') {
768 if (is_array($genallowed)) {
769 $modellist = $genallowed;
771 include_once DOL_DOCUMENT_ROOT.
'/core/modules/user/modules_user.class.php';
774 } elseif ($modulepart ==
'usergroup') {
775 if (is_array($genallowed)) {
776 $modellist = $genallowed;
778 include_once DOL_DOCUMENT_ROOT.
'/core/modules/usergroup/modules_usergroup.class.php';
783 $file =
dol_buildpath(
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
784 if (file_exists($file)) {
785 $res = include_once $file;
788 $file =
dol_buildpath(
'/'.$modulepart.
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
789 $res = include_once $file;
792 $class =
'ModelePDF'.ucfirst($submodulepart);
794 if (class_exists($class)) {
795 $modellist = call_user_func($class.
'::liste_modeles', $this->db);
797 dol_print_error($this->db,
"Bad value for modulepart '".$modulepart.
"' in showdocuments (class ".$class.
" for Doc generation not found)");
805 if (empty($buttonlabel)) {
806 $buttonlabel = $langs->trans(
'Generate');
809 if (
$conf->browser->layout ==
'phone') {
810 $urlsource .=
'#'.$forname.
'_form';
812 if (empty($noform)) {
813 $out .=
'<form action="'.$urlsource.
'" id="'.$forname.
'_form" method="post">';
815 $out .=
'<input type="hidden" name="action" value="builddoc">';
816 $out .=
'<input type="hidden" name="page_y" value="">';
817 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
820 $out .=
'<div class="div-table-responsive-no-min">';
821 $out .=
'<table class="liste formdoc noborder centpercent">';
823 $out .=
'<tr class="liste_titre">';
824 $addcolumforpicto = ($delallowed || $printer || $morepicto);
825 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
828 $out .=
'<th colspan="'.$colspan.
'" class="formdoc liste_titre maxwidthonsmartphone center">';
831 if (!empty($modellist)) {
833 $out .=
'<span class="hideonsmartphone">'.$langs->trans(
'Model').
' </span>';
834 if (is_array($modellist) && count($modellist) == 1) {
835 $arraykeys = array_keys($modellist);
836 $modelselected = $arraykeys[0];
838 $morecss =
'minwidth75 maxwidth200';
839 if (
$conf->browser->layout ==
'phone') {
840 $morecss =
'maxwidth100';
842 $out .= $form->selectarray(
'model', $modellist, $modelselected, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss, 1,
'', 0, 0);
876 if (
$conf->use_javascript_ajax) {
879 $out .= $form->textwithpicto(
'', $tooltipontemplatecombo, 1,
'help',
'marginrightonly', 0, 3,
'', 0);
881 $out .=
'<div class="float">'.$langs->trans(
"Files").
'</div>';
885 if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) &&
getDolGlobalInt(
'MAIN_MULTILANGS') && !$forcenomultilang && (!empty($modellist) || $showempty)) {
886 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
888 $defaultlang = ($codelang && $codelang !=
'auto') ? $codelang : $langs->getDefaultLang();
889 $morecss =
'maxwidth150';
890 if (
$conf->browser->layout ==
'phone') {
891 $morecss =
'maxwidth100';
893 $out .= $formadmin->select_language($defaultlang,
'lang_id', 0, array(), 0, 0, 0, $morecss);
899 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
900 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
901 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
902 $genbutton .=
' disabled';
905 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty(
$conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
906 $langs->load(
"errors");
907 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
909 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty(
$conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
912 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
918 if (!empty($hookmanager->hooks[
'formfile'])) {
919 foreach ($hookmanager->hooks[
'formfile'] as $module) {
920 if (method_exists($module,
'formBuilddocLineOptions')) {
929 $parameters = array(
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart);
930 if (is_object($hookmanager)) {
931 $reshook = $hookmanager->executeHooks(
'formBuilddocOptions', $parameters, $GLOBALS[
'object']);
932 $out .= $hookmanager->resPrint;
937 if (!empty($filedir)) {
938 $link_list = array();
940 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
941 $link =
new Link($this->db);
942 $sortfield = $sortorder =
'';
943 $res = $link->fetchAll($link_list,
$object->element,
$object->id, $sortfield, $sortorder);
946 $out .=
'<!-- html.formfile::showdocuments -->'.
"\n";
949 if ((!empty($file_list) || !empty($link_list) || preg_match(
'/^massfilesarea/', $modulepart))
952 $out .=
'<div class="titre">'.$titletoshow.
'</div>'.
"\n";
953 $out .=
'<div class="div-table-responsive-no-min">';
954 $out .=
'<table class="noborder centpercent" id="'.$modulepart.
'_table">'.
"\n";
958 if (is_array($file_list)) {
959 '@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';
963 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
964 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
970 '@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';
973 if (!empty($sortfield) && !empty($sortorder)) {
978 require_once DOL_DOCUMENT_ROOT .
'/ecm/class/ecmfiles.class.php';
981 foreach ($file_list as $file) {
984 if (!empty($file[
'rowid'])) {
986 $ecmfile->fetch($file[
'rowid']);
992 $relativepath = (string) $file[
"name"];
994 $relativepath = (string) $modulesubdir.
"/".$file[
"name"];
996 if ($modulepart ==
'export') {
997 $relativepath = (string) $file[
"name"];
1000 $out .=
'<tr class="oddeven'.((!$genallowed && $i == 1) ?
' trfirstline' :
'').
'">';
1002 $documenturl = DOL_URL_ROOT.
'/document.php';
1003 if (isset(
$conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
1008 $imgpreview = $this->
showPreview($file, $modulepart, $relativepath, 0, $param);
1010 $out .=
'<td class="minwidth200 tdoverflowmax300">';
1012 $out .=
'<span class="spanoverflow widthcentpercentminusx valignmiddle">';
1014 $out .=
'<span class="spanoverflow">';
1016 if (is_object($ecmfile)) {
1017 $out .= $ecmfile->getNomUrl(1, $modulepart, 0, 0,
' documentdownload');
1019 $out .=
'<a class="documentdownload paddingright" ';
1021 $out .=
'target="_blank" ';
1023 $out .=
'href="'.$documenturl.
'?modulepart='.$modulepart.
'&file='.urlencode($relativepath).($param ?
'&'.$param :
'').
'"';
1026 if (preg_match(
'/text/', $mime)) {
1027 $out .=
' target="_blank" rel="noopener noreferrer"';
1029 $out .=
' title="'.dol_escape_htmltag($file[
"name"]).
'"';
1031 $out .=
img_mime($file[
"name"], $langs->trans(
"File").
': '.$file[
"name"]);
1035 $out .=
'</span>'.
"\n";
1036 $out .= $imgpreview;
1040 $size = (!empty($file[
'size']) ? $file[
'size'] :
dol_filesize($filedir.
"/".$file[
"name"]));
1041 $out .=
'<td class="nowraponall right" title="'.dolPrintHTML($size.
' '.$langs->trans(
"Bytes")).
'">'.
dol_print_size($size, 1, 1).
'</td>';
1044 $date = (!empty($file[
'date']) ? $file[
'date'] :
dol_filemtime($filedir.
"/".$file[
"name"]));
1045 $out .=
'<td class="nowrap right">'.dol_print_date($date,
'dayhour',
'tzuser').
'</td>';
1048 $out .=
'<td class="nowraponall">';
1049 if (!empty($file[
'share'])) {
1051 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1052 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1058 if (!empty($file[
'share'])) {
1059 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
1061 if ($forcedownload) {
1062 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1065 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1067 $out .=
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
1068 $out .=
'<input type="text" class="quatrevingtpercentminusx width75 nopadding small" id="downloadlink'.$file[
'rowid'].
'" name="downloadexternallink" title="'.
dol_escape_htmltag($langs->trans(
"FileSharedViaALink")).
'" value="'.
dol_escape_htmltag($fulllink).
'">';
1076 if ($delallowed || $printer || $morepicto) {
1077 $out .=
'<td class="right nowraponall">';
1079 $tmpurlsource = preg_replace(
'/#[a-zA-Z0-9_]*$/',
'', $urlsource);
1080 $out .=
'<a class="reposition" href="'.$tmpurlsource.((strpos($tmpurlsource,
'?') ===
false) ?
'?' :
'&').
'action='.urlencode($removeaction).
'&token='.
newToken().
'&file='.urlencode($relativepath);
1081 $out .= ($param ?
'&'.$param :
'');
1084 $out .=
'">'.img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
1087 $out .=
'<a class="marginleftonly reposition" href="'.$urlsource.(strpos($urlsource,
'?') ?
'&' :
'?').
'action=print_file&token='.
newToken().
'&printer='.urlencode($modulepart).
'&file='.urlencode($relativepath);
1088 $out .= ($param ?
'&'.$param :
'');
1089 $out .=
'">'.img_picto($langs->trans(
"PrintFile", $relativepath),
'printer.png').
'</a>';
1092 $morepicto = preg_replace(
'/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto);
1098 if (is_object($hookmanager)) {
1099 $addcolumforpicto = ($delallowed || $printer || $morepicto);
1100 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
1102 $parameters = array(
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart,
'relativepath' => $relativepath);
1103 $res = $hookmanager->executeHooks(
'formBuilddocLineOptions', $parameters, $file);
1105 $out .= $hookmanager->resPrint;
1108 $out = $hookmanager->resPrint;
1113 $this->numoffiles++;
1116 if (is_array($link_list)) {
1119 foreach ($link_list as $file) {
1120 $out .=
'<tr class="oddeven">';
1121 $out .=
'<td colspan="'.$colspan.
'" class="maxwidhtonsmartphone">';
1122 $out .=
'<a data-ajax="false" href="'.$file->url.
'" target="_blank" rel="noopener noreferrer">';
1123 $out .= $file->label;
1126 $out .=
'<td class="right">';
1130 $out .=
'<td></td>';
1131 if ($delallowed || $printer || $morepicto) {
1132 $out .=
'<td></td>';
1134 $out .=
'</tr>'.
"\n";
1136 $this->numoffiles++;
1139 if (count($file_list) == 0 && count($link_list) == 0 && $headershown) {
1140 $out .=
'<tr><td colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>'.
"\n";
1146 $out .=
"</table>\n";
1149 if (empty($noform)) {
1150 $out .=
'</form>'.
"\n";
1154 $out .=
'<!-- End show_document -->'.
"\n";
1157 jQuery(document).ready(function() {
1158 var selectedValue = $(".selectformat").val();
1160 if (selectedValue === "excel2007" || selectedValue === "tsv") {
1161 $(".forhide").prop("disabled", true).hide();
1163 $(".forhide").prop("disabled", false).show();
1184 public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
'', $morecss =
'valignmiddle', $allfiles = 0)
1186 global
$conf, $langs;
1188 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1191 $this->infofiles = array(
'nboffiles' => 0,
'extensions' => array(),
'files' => array());
1196 if (isModEnabled(
'multicompany')) {
1198 preg_match(
'/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,
'/').
'$/', $filedir, $regs);
1199 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
1204 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/');
1206 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/').
'\.';
1208 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
1212 $out .=
'<!-- html.formfile::getDocumentsLink -->'.
"\n";
1213 if (!empty($file_list)) {
1214 $out =
'<dl class="dropdown inline-block">
1215 <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto(
'',
'listlight',
'', 0, 0, 0,
'', $morecss).
'</a></dt>
1216 <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
1222 foreach ($file_list as $file) {
1224 if ($filter && !preg_match(
'/'.$filter.
'/i', $file[
"name"])) {
1230 $relativepath = $file[
"name"];
1231 if ($modulesubdir) {
1232 $relativepath = (string) $modulesubdir.
"/".$file[
"name"];
1235 if ($modulepart ==
'donation') {
1236 $relativepath = (string)
get_exdir($modulesubdir, 2, 0, 0,
null,
'donation').$file[
"name"];
1238 if ($modulepart ==
'export') {
1239 $relativepath = (string) $file[
"name"];
1242 $this->infofiles[
'nboffiles']++;
1243 $this->infofiles[
'files'][] = $file[
'fullname'];
1244 $ext = (string) pathinfo($file[
'name'], PATHINFO_EXTENSION);
1245 if (!array_key_exists($ext, $this->infofiles[
'extensions'])) {
1246 $this->infofiles[
'extensions'][$ext] = 1;
1248 $this->infofiles[
'extensions'][$ext]++;
1252 if (!empty(
$conf->use_javascript_ajax) && (
$conf->browser->layout !=
'phone')) {
1254 if ($tmparray && $tmparray[
'url']) {
1255 $tmpout .=
'<li><a href="'.$tmparray[
'url'].
'"'.($tmparray[
'css'] ?
' class="'.$tmparray[
'css'].
'"' :
'').($tmparray[
'mime'] ?
' mime="'.$tmparray[
'mime'].
'"' :
'').($tmparray[
'target'] ?
' target="'.$tmparray[
'target'].
'"' :
'').
'>';
1257 $tmpout .=
'<i class="fa fa-search-plus paddingright" style="color: gray"></i>';
1258 $tmpout .= $langs->trans(
"Preview").
' '.$ext.
'</a></li>';
1263 $tmpout .=
'<li class="nowrap"><a class="pictopreview nowrap" ';
1265 $tmpout .=
'target="_blank" ';
1267 $tmpout .=
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($relativepath).
'"';
1269 if (preg_match(
'/text/', $mime)) {
1270 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
1273 $tmpout .=
img_mime($relativepath, $file[
"name"]);
1274 $tmpout .= $langs->trans(
"Download").
' '.$ext;
1275 $tmpout .=
'</a></li>'.
"\n";
1278 $out .=
'</ul></div></dd>
1327 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())
1330 global $user,
$conf, $langs, $hookmanager, $form;
1331 global $sortfield, $sortorder;
1332 global $dolibarr_main_url_root;
1334 if ($disablecrop == -1) {
1337 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'))) {
1343 if (empty($relativepath)) {
1345 if (!empty(
$object->element) &&
$object->element ==
'invoice_supplier') {
1348 if (!empty(
$object->element) &&
$object->element ==
'project_task') {
1349 $relativepath =
'Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1353 if (
getDolGlobalInt(
'PRODUCT_USE_OLD_PATH_FOR_PHOTO') && isset($filearray[0]) && $filearray[0][
'level1name'] ==
'photos') {
1354 $relativepath = preg_replace(
'/^.*\/produit\//',
'', $filearray[0][
'path']).
'/';
1360 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $upload_dir);
1361 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1367 $hookmanager->initHooks(array(
'formfile'));
1368 $parameters = array(
1369 'filearray' => $filearray,
1370 'modulepart' => $modulepart,
1372 'forcedownload' => $forcedownload,
1373 'relativepath' => $relativepath,
1374 'relativedir' => $relativedir,
1375 'permtodelete' => $permonobject,
1376 'useinecm' => $useinecm,
1377 'textifempty' => $textifempty,
1378 'maxlength' => $maxlength,
1382 $reshook = $hookmanager->executeHooks(
'showFilesList', $parameters,
$object);
1384 if (!empty($reshook)) {
1387 if (!is_object($form)) {
1388 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1389 $form =
new Form($this->db);
1392 if (!preg_match(
'/&id=/', $param) && isset(
$object->id)) {
1393 $param .=
'&id='.$object->id;
1395 $relativepathwihtoutslashend = preg_replace(
'/\/$/',
'', $relativepath);
1396 if ($relativepathwihtoutslashend) {
1397 $param .=
'&file='.urlencode($relativepathwihtoutslashend);
1400 if ($permtoeditline < 0) {
1401 $permtoeditline = 0;
1402 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1404 $permtoeditline = 1;
1407 $permtoeditline = 1;
1412 $permtoeditline = 0;
1416 $url = $_SERVER[
"PHP_SELF"];
1421 $morehtmlright =
'';
1422 if (!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) {
1423 $tmpurlforbutton =
'javascript:console.log("open add file form");jQuery(".divattachnewfile").toggle(); if (!jQuery(".divattachnewfile").is(":hidden")) { jQuery("input[type=\'file\']").click(); }';
1424 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $tmpurlforbutton,
'', $permtoeditline);
1427 if ((empty($useinecm) || $useinecm == 3 || $useinecm == 6) && $title !=
'none') {
1428 print
load_fiche_titre($title ? $title : $langs->trans(
"AttachedFiles"), $morehtmlright,
'file-upload', 0,
'',
'table-list-of-attached-files');
1430 if (!empty($moreoptions) && $moreoptions[
'afteruploadtitle']) {
1431 print
'<div class="divattachnewfile'.((!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afteruploadtitle'].
'</div>';
1435 print
'<!-- html.formfile::list_of_documents -->'.
"\n";
1436 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1437 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?'.$param.
'" method="POST">';
1438 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1439 print
'<input type="hidden" name="action" value="renamefile">';
1440 print
'<input type="hidden" name="id" value="'.(is_object(
$object) ?
$object->id :
'').
'">';
1441 print
'<input type="hidden" name="modulepart" value="'.$modulepart.
'">';
1444 print
'<div class="div-table-responsive-no-min"'.($moreattrondiv ?
' '.$moreattrondiv :
'').
'>';
1445 print
'<table id="tablelines" class="centpercent liste noborder nobottom">'.
"\n";
1447 if (!empty($addfilterfields)) {
1448 print
'<tr class="liste_titre nodrag nodrop">';
1449 print
'<td><input type="search_doc_ref" value="'.dol_escape_htmltag(
GETPOST(
'search_doc_ref',
'alpha')).
'"></td>';
1452 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1457 if (empty($disablemove) && count($filearray) > 1) {
1466 '@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';
1469 if ($sortfield && $sortorder) {
1474 print
'<tr class="liste_titre nodrag nodrop">';
1479 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1486 if (empty($disablemove) && count($filearray) > 1) {
1491 $nboffiles = count($filearray);
1492 if ($nboffiles > 0) {
1493 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1499 $parametersByDefault = array(
1500 'modulepart' => $modulepart,
1501 'relativepath' => $relativepath,
1502 'permtoedit' => $permtoeditline,
1503 'permonobject' => $permonobject,
1505 foreach ($filearray as $key => $file) {
1506 if ($file[
'name'] !=
'.' && $file[
'name'] !=
'..' && !preg_match(
'/\.meta$/i', $file[
'name'])) {
1507 if (array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) {
1508 $lastrowid = $filearray[$key][
'rowid'];
1513 $modulepart = ($file[
'modulepart'] ?? $parametersByDefault[
'modulepart']);
1514 $relativepath = ($file[
'relativepath'] ?? $parametersByDefault[
'relativepath']);
1515 $permtoeditline = ($file[
'permtoedit'] ?? $parametersByDefault[
'permtoedit']);
1516 $permonobject = ($file[
'permonobject'] ?? $parametersByDefault[
'permonobject']);
1519 if (empty($relativepath) || empty($modulepart)) {
1520 $filepath = $file[
'level1name'].
'/'.$file[
'name'];
1522 $filepath = $relativepath.$file[
'name'];
1524 if (empty($modulepart)) {
1525 $modulepart = basename(dirname($file[
'path']));
1527 if (empty($relativepath)) {
1528 $relativepath = preg_replace(
'/\/(.+)/',
'', $filepath) .
'/';
1533 print
'<!-- Line list_of_documents '.$key.
' relativepath = '.$relativepath.
' -->'.
"\n";
1536 print
'<!-- In database: position='.(array_key_exists(
'position', $filearray[$key]) ? $filearray[$key][
'position'] : 0).
' -->'.
"\n";
1537 print
'<tr class="oddeven" id="row-'.((array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) ? $filearray[$key][
'rowid'] :
'AFTER'.$lastrowid.
'POS'.($i + 1)).
'">';
1541 print
'<td class="minwidth200 tdoverflowmax500" title="'.dolPrintHTMLForAttribute($file[
'name']).
'">';
1545 print
'<a class="paddingright valignmiddle" ';
1547 print
'target="_blank" ';
1549 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart;
1550 if ($forcedownload) {
1551 print
'&attachment=1';
1553 if (!empty(
$object->entity)) {
1554 print
'&entity='.$object->entity;
1556 print
'&file='.urlencode($filepath);
1558 print
img_mime($file[
'name'], $file[
'name'].
' ('.
dol_print_size($file[
'size'], 0, 0).
')',
'inline-block valignmiddle paddingright');
1559 if ($showrelpart == 1) {
1560 print $relativepath;
1566 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $file[
'name'] == basename(
GETPOST(
'urlfile',
'alpha')) && dirname($filepath) == dirname(
GETPOST(
'urlfile',
'alpha'))) {
1568 $section_dir = dirname(
GETPOST(
'urlfile',
'alpha'));
1569 if (!preg_match(
'/\/$/', $section_dir)) {
1570 $section_dir .=
'/';
1572 print
'<input type="hidden" name="section_dir" value="'.$section_dir.
'">';
1573 print
'<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file[
'name']).
'">';
1574 print
'<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file[
'name']).
'">';
1577 $filenametoshow = preg_replace(
'/\.noexe$/',
'', $file[
'name']);
1591 print
'<td class="right nowraponall">';
1592 if ($sizetoshow == $sizetoshowbytes) {
1595 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1600 print
'<td class="center nowraponall">'.dol_print_date($file[
'date'],
"dayhour",
"tzuser").
'</td>';
1603 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1604 $fileinfo = pathinfo($file[
'name']);
1605 print
'<td class="center">';
1607 if ($useinecm == 5 || $useinecm == 6) {
1621 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity));
1622 if (empty($urlforhref)) {
1623 $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']));
1624 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
1626 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
1628 print
'<img class="photo maxwidth200 shadow valignmiddle"';
1629 if ($useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1630 print
' height="20"';
1633 print
' style="max-height: 24px"';
1635 print
' src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity).
'&file='.urlencode($relativepath.$smallfile);
1636 if (!empty($filearray[$key][
'date'])) {
1637 print
'&cache='.urlencode((
string) $filearray[$key][
'date']);
1639 print
'" title="">';
1646 print
'<td class="center">';
1647 if ($relativedir && $filearray[$key][
'rowid'] > 0) {
1649 print
'<label for="idshareenabled'.$key.
'">'.$langs->trans(
"FileSharedViaALink").
'</label> ';
1650 print
'<input class="inline-block" type="checkbox" id="idshareenabled'.$key.
'" name="shareenabled"'.($file[
'share'] ?
' checked="checked"' :
'').
' /> ';
1652 if ($file[
'share']) {
1654 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1655 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1661 if (!empty($file[
'share'])) {
1662 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
1664 if ($forcedownload) {
1665 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1668 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1670 print
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
1671 print
'<input type="text" class="quatrevingtpercent minwidth200imp nopadding small" id="downloadlink'.$filearray[$key][
'rowid'].
'" name="downloadexternallink" title="'.
dol_escape_htmltag($langs->trans(
"FileSharedViaALink")).
'" value="'.
dol_escape_htmltag($fulllink).
'">';
1683 print
'<td class="valignmiddle right actionbuttons nowraponall"><!-- action on files -->';
1684 if ($useinecm == 1 || $useinecm == 5) {
1686 $newparam = preg_replace(
'/&file=.*$/',
'', $param);
1687 $backtopage = DOL_URL_ROOT.
'/ecm/index.php?§ion_dir='.urlencode($relativepath).$newparam;
1688 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>';
1691 if (empty($useinecm) || $useinecm == 2 || $useinecm == 3 || $useinecm == 6) {
1692 $newmodulepart = $modulepart;
1693 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1694 $newmodulepart =
'produit|service';
1697 if ($permtoeditline) {
1698 $moreparaminurl =
'';
1700 $moreparaminurl .=
'&id='.$object->id;
1701 } elseif (
GETPOST(
'website',
'alpha')) {
1702 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1705 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1706 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1709 if (!preg_match(
'/\.webp$/i', $file[
'name'])) {
1710 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1711 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>';
1712 } elseif ($modulepart ==
'medias' &&
GETPOST(
'website')) {
1713 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>';
1719 if ($permtoeditline) {
1721 $moreparaminurl =
'';
1723 $moreparaminurl .=
'&id='.$object->id;
1724 } elseif (
GETPOST(
'website',
'alpha')) {
1725 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1728 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1729 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1732 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>';
1736 if ($permtoeditline) {
1737 $paramsectiondir = (in_array($modulepart, array(
'medias',
'ecm')) ?
'§ion_dir='.urlencode($relativepath) :
'');
1738 print
'<a class="editfielda reposition editfilelink paddingright marginleftonly" href="'.(($useinecm == 1 || $useinecm == 5) ?
'#' : ($url.
'?action=editfile&token='.
newToken().
'&urlfile='.urlencode($filepath).$paramsectiondir.$param)).
'" rel="'.$filepath.
'">'.
img_edit(
'default', 0,
'class="paddingrightonly"').
'</a>';
1742 if ($permonobject) {
1744 if (!empty(
$conf->dol_use_jmobile)) {
1747 if (empty(
$conf->use_javascript_ajax)) {
1754 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>';
1758 if (empty($disablemove) && count($filearray) > 1) {
1759 if ($nboffiles > 1 &&
$conf->browser->layout !=
'phone') {
1760 print
'<td class="linecolmove tdlineupdown center">';
1762 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=up&rowid='.
$object->id.
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
1764 if ($i < ($nboffiles - 1)) {
1765 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=down&rowid='.
$object->id.
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
1769 print
'<td'.(($conf->browser->layout !=
'phone') ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'>';
1774 print
'<td class="right">';
1775 print
'<input type="hidden" name="ecmfileid" value="'.(empty($filearray[$key][
'rowid']) ?
'' : $filearray[$key][
'rowid']).
'">';
1776 print
'<input type="submit" class="button button-save smallpaddingimp" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
1777 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
1779 if (empty($disablemove) && count($filearray) > 1) {
1780 print
'<td class="right"></td>';
1788 if ($nboffiles == 0) {
1790 if (empty($disablemove) && count($filearray) > 1) {
1793 print
'<tr class="oddeven"><td colspan="'.$colspan.
'">';
1794 if (empty($textifempty)) {
1795 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
1797 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
1805 if ($nboflines > 1 && is_object(
$object)) {
1806 if (!empty(
$conf->use_javascript_ajax) && $permtoeditline) {
1807 $table_element_line =
'ecm_files';
1808 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1814 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1842 public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath =
'', $permissiontodelete = 1, $useinecm = 0, $textifempty =
'', $maxlength = 0, $url =
'', $addfilterfields = 0)
1845 global
$conf, $langs, $hookmanager, $form;
1846 global $sortfield, $sortorder;
1847 global $search_doc_ref;
1848 global $dolibarr_main_url_root;
1850 dol_syslog(get_class($this).
'::list_of_autoecmfiles upload_dir='.$upload_dir.
' modulepart='.$modulepart);
1853 if (empty($useinecm) || $useinecm == 6) {
1857 $url = $_SERVER[
"PHP_SELF"];
1860 if (!empty($addfilterfields)) {
1861 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'">';
1862 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1863 print
'<input type="hidden" name="module" value="'.$modulepart.
'">';
1866 print
'<div class="div-table-responsive-no-min">';
1867 print
'<table width="100%" class="noborder">'.
"\n";
1869 if (!empty($addfilterfields)) {
1870 print
'<tr class="liste_titre nodrag nodrop">';
1871 print
'<td class="liste_titre"></td>';
1872 print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1873 print
'<td class="liste_titre"></td>';
1874 print
'<td class="liste_titre"></td>';
1876 print
'<td class="liste_titre right">';
1877 $searchpicto = $form->showFilterButtons();
1883 print
'<tr class="liste_titre">';
1884 $sortref =
"fullname";
1885 if ($modulepart ==
'invoice_supplier') {
1886 $sortref =
'level1name';
1896 $object_instance =
null;
1897 if ($modulepart ==
'company') {
1898 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1899 $object_instance =
new Societe($this->db);
1900 } elseif ($modulepart ==
'invoice') {
1901 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1902 $object_instance =
new Facture($this->db);
1903 } elseif ($modulepart ==
'invoice_supplier') {
1904 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1906 } elseif ($modulepart ==
'propal') {
1907 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
1908 $object_instance =
new Propal($this->db);
1909 } elseif ($modulepart ==
'supplier_proposal') {
1910 include_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
1912 } elseif ($modulepart ==
'order') {
1913 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1914 $object_instance =
new Commande($this->db);
1915 } elseif ($modulepart ==
'order_supplier') {
1916 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1918 } elseif ($modulepart ==
'contract') {
1919 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1920 $object_instance =
new Contrat($this->db);
1921 } elseif ($modulepart ==
'product') {
1922 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1923 $object_instance =
new Product($this->db);
1924 } elseif ($modulepart ==
'tax') {
1925 include_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
1927 } elseif ($modulepart ==
'tax-vat') {
1928 include_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
1929 $object_instance =
new Tva($this->db);
1930 } elseif ($modulepart ==
'salaries') {
1931 include_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
1932 $object_instance =
new Salary($this->db);
1933 } elseif ($modulepart ==
'project') {
1934 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1935 $object_instance =
new Project($this->db);
1936 } elseif ($modulepart ==
'project_task') {
1937 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1938 $object_instance =
new Task($this->db);
1939 } elseif ($modulepart ==
'fichinter') {
1940 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
1941 $object_instance =
new Fichinter($this->db);
1942 } elseif ($modulepart ==
'user') {
1943 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1944 $object_instance =
new User($this->db);
1945 } elseif ($modulepart ==
'expensereport') {
1946 include_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1948 } elseif ($modulepart ==
'holiday') {
1949 include_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
1950 $object_instance =
new Holiday($this->db);
1951 } elseif ($modulepart ==
'recruitment-recruitmentcandidature') {
1952 include_once DOL_DOCUMENT_ROOT.
'/recruitment/class/recruitmentcandidature.class.php';
1954 } elseif ($modulepart ==
'banque') {
1955 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1956 $object_instance =
new Account($this->db);
1957 } elseif ($modulepart ==
'chequereceipt') {
1958 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
1960 } elseif ($modulepart ==
'mrp-mo') {
1961 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
1962 $object_instance =
new Mo($this->db);
1964 $parameters = array(
'modulepart' => $modulepart);
1965 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
1966 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
1967 if (array_key_exists(
'classpath', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classpath'])) {
1969 if (array_key_exists(
'classname', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classname'])) {
1970 $tmpclassname = $hookmanager->resArray[
'classname'];
1971 if (is_string($tmpclassname) && class_exists($tmpclassname)) {
1972 $object_instance =
new $tmpclassname($this->db);
1983 $relativepathfromroot = preg_replace(
'/'.preg_quote(DOL_DATA_ROOT.
'/',
'/').
'/',
'', $upload_dir);
1984 if ($relativepathfromroot) {
1986 '@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';
1989 if ($sortfield && $sortorder) {
1990 $filearray =
dol_sort_array($filearray, $sortfield, $sortorder, 1);
1996 foreach ($filearray as $key => $file) {
1997 if (!is_dir($file[
'name'])
1998 && $file[
'name'] !=
'.'
1999 && $file[
'name'] !=
'..'
2000 && $file[
'name'] !=
'CVS'
2001 && !preg_match(
'/\.meta$/i', $file[
'name'])) {
2003 $relativefile = preg_replace(
'/'.preg_quote($upload_dir.
'/',
'/').
'/',
'', $file[
'fullname']);
2011 if ($modulepart ==
'company' || $modulepart ==
'tax' || $modulepart ==
'tax-vat' || $modulepart ==
'salaries') {
2012 preg_match(
'/(\d+)\/[^\/]+$/', $relativefile, $reg);
2013 $id = (isset($reg[1]) ? $reg[1] :
'');
2014 } elseif ($modulepart ==
'invoice_supplier') {
2015 preg_match(
'/([^\/]+)\/[^\/]+$/', $relativefile, $reg);
2016 $ref = (isset($reg[1]) ? $reg[1] :
'');
2017 if (is_numeric($ref)) {
2021 } elseif ($modulepart ==
'user') {
2023 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
2024 $id = (isset($reg[1]) ? $reg[1] :
'');
2025 } elseif ($modulepart ==
'project_task') {
2027 $reg = explode(
"/", $relativefile);
2028 $ref = (isset($reg[1]) ? $reg[1] :
'');
2029 } elseif (in_array($modulepart, array(
2032 'supplier_proposal',
2041 'recruitment-recruitmentcandidature',
2046 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
2047 $ref = (isset($reg[1]) ? $reg[1] :
'');
2049 $parameters = array(
'modulepart' => $modulepart,
'fileinfo' => $file);
2050 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
2051 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
2052 if (array_key_exists(
'ref', $hookmanager->resArray) && !empty($hookmanager->resArray[
'ref'])) {
2053 $ref = $hookmanager->resArray[
'ref'];
2055 if (array_key_exists(
'id', $hookmanager->resArray) && !empty($hookmanager->resArray[
'id'])) {
2056 $id = $hookmanager->resArray[
'id'];
2062 if (!
$id && !$ref) {
2067 if (!empty(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2073 if (is_object($object_instance)) {
2074 $object_instance->id = 0;
2075 $object_instance->ref =
'';
2077 $result = $object_instance->fetch(
$id);
2079 if (!($result = $object_instance->fetch(0, $ref))) {
2085 $result = $object_instance->fetchOneLike($ref);
2092 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] = clone $object_instance;
2096 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] =
'notfound';
2097 unset($filearray[$key]);
2101 if ($found <= 0 || !is_object(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2105 print
'<!-- Line list_of_autoecmfiles key='.$key.
' -->'.
"\n";
2106 print
'<tr class="oddeven">';
2108 if ($found > 0 && is_object(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2109 $tmpobject =
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref];
2111 print $tmpobject->getNomUrl(1,
'document');
2116 print $langs->trans(
"ObjectDeleted", (
$id ?
$id : $ref));
2134 print
'target="_blank" ';
2136 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.urlencode($modulepart);
2137 if ($forcedownload) {
2138 print
'&attachment=1';
2140 print
'&file='.urlencode($relativefile).
'">';
2147 print $this->
showPreview($file, $modulepart, $file[
'relativename']);
2154 print
'<td class="right nowraponall">';
2155 if ($sizetoshow == $sizetoshowbytes) {
2158 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
2163 print
'<td class="center">'.dol_print_date($file[
'date'],
"dayhour").
'</td>';
2166 print
'<td class="right">';
2167 if (!empty($file[
'share'])) {
2169 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2170 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2176 if (!empty($file[
'share'])) {
2177 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
2179 if ($forcedownload) {
2180 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
2183 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
2185 print
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
2186 print
'<input type="text" class="quatrevingtpercent width100 nopadding nopadding small" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
2200 if (count($filearray) == 0) {
2201 print
'<tr class="oddeven"><td colspan="5">';
2202 if (empty($textifempty)) {
2203 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
2205 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
2212 if (!empty($addfilterfields)) {
2215 return count($filearray);
2231 public function listOfLinks(
$object, $permissiontodelete = 1, $action =
null, $selected =
null, $param =
'', $htmlname =
'formaddlink', $moreoptions = array())
2233 global
$conf, $langs;
2234 global $sortfield, $sortorder;
2236 $langs->load(
"link");
2238 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2239 $link =
new Link($this->db);
2241 if ($sortfield ==
"name") {
2242 $sortfield =
"label";
2243 } elseif ($sortfield ==
"date") {
2244 $sortfield =
"datea";
2248 $res = $link->fetchAll($links,
$object->element,
$object->id, $sortfield, $sortorder);
2249 $param .= (isset(
$object->id) ?
'&id='.$object->id :
'');
2251 $permissiontoedit = $permissiontodelete;
2253 print
'<!-- listOfLinks -->'.
"\n";
2255 $morehtmlright =
'';
2256 if (!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) {
2257 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
'javascript:console.log("open addlink form"); jQuery(".divlinkfile").toggle();',
'', $permissiontoedit);
2261 print
load_fiche_titre($langs->trans(
"LinkedFiles"), $morehtmlright,
'link', 0,
'',
'table-list-of-links');
2263 if (!empty($moreoptions) && $moreoptions[
'afterlinktitle']) {
2264 print
'<div class="divlinkfile'.((!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afterlinktitle'].
'</div>';
2267 print
'<form action="'.$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
'').
'" id="'.$htmlname.
'" method="POST">';
2268 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2270 print
'<table class="liste noborder nobottom centpercent">';
2271 print
'<tr class="liste_titre">';
2273 $langs->trans(
"Links"),
2274 $_SERVER[
'PHP_SELF'],
2295 $langs->trans(
"Date"),
2296 $_SERVER[
'PHP_SELF'],
2307 $_SERVER[
'PHP_SELF'],
2318 $nboflinks = count($links);
2319 if ($nboflinks > 0) {
2320 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2322 foreach ($links as $link) {
2323 print
'<tr class="oddeven">';
2325 if ($action ==
'update' && $selected === (
int) $link->id && $permissiontoedit) {
2327 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2328 print
'<input type="hidden" name="linkid" value="'.$link->id.
'">';
2329 print
'<input type="hidden" name="action" value="confirm_updateline">';
2330 print $langs->trans(
'Link').
': <input type="text" name="link" value="'.$link->url.
'">';
2333 print $langs->trans(
'Label').
': <input type="text" name="label" value="'.
dol_escape_htmltag($link->label).
'">';
2335 print
'<td class="center">'.dol_print_date(
dol_now(),
"dayhour",
"tzuser").
'</td>';
2336 print
'<td class="right"></td>';
2337 print
'<td class="right">';
2338 print
'<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2339 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2344 print
'<a data-ajax="false" href="'.$link->url.
'" target="_blank" rel="noopener noreferrer">';
2348 print
'<td class="right"></td>';
2349 print
'<td class="center">'.dol_print_date($link->datea,
"dayhour",
"tzuser").
'</td>';
2350 print
'<td class="center"></td>';
2351 print
'<td class="right">';
2352 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=update&linkid='.$link->id.$param.
'&token='.
newToken().
'" class="editfilelink editfielda reposition" >'.
img_edit().
'</a>';
2353 if ($permissiontodelete) {
2354 print
' <a class="deletefilelink reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=deletelink&token='.
newToken().
'&linkid='.((int) $link->id).$param.
'">'.
img_delete().
'</a>';
2362 if ($nboflinks == 0) {
2363 print
'<tr class="oddeven"><td colspan="5">';
2364 print
'<span class="opacitymedium">'.$langs->trans(
"NoLinkFound").
'</span>';
2385 public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0, $param =
'')
2387 global $langs,
$conf;
2390 if (
$conf->browser->layout !=
'phone' && !empty(
$conf->use_javascript_ajax)) {
2392 if (count($urladvancedpreview)) {
2393 $out .=
'<a class="pictopreview '.$urladvancedpreview[
'css'].
'" href="'.$urladvancedpreview[
'url'].
'"'.(empty($urladvancedpreview[
'mime']) ?
'' :
' mime="'.$urladvancedpreview[
'mime'].
'"').
' '.(empty($urladvancedpreview[
'target']) ?
'' :
' target="'.$urladvancedpreview[
'target'].
'"').
'>';
2395 if (empty($ruleforpicto)) {
2397 $out .=
'<span class="fa fa-search-plus pictofixedwidth" style="color: gray"></span>';
2399 $out .=
img_mime($relativepath, $langs->trans(
'Preview').
' '.$file[
'name'],
'pictofixedwidth');
2403 if ($ruleforpicto < 0) {
2404 $out .=
img_picto(
'',
'generic',
'', 0, 0, 0,
'',
'paddingright pictofixedwidth');
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 - Taxe sur la valeur ajoutée)
Class to manage Dolibarr users.
dol_filemtime($pathoffile)
Return time of a file.
dol_filesize($pathoffile)
Return size of a file.
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.
completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
Complete $filearray with data from database.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formatted size.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dol_now($mode='auto')
Return date for now.
img_mime($file, $titlealt='', $morecss='')
Show MIME img of a file.
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.
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getImageFileNameForSize($file, $extName, $extImgTarget='')
Return the filename of file to get the thumbs.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
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.
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.
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.