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/functions.lib.php';
86 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
87 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
90 $maxwidthsmall = $tmparraysize[
'maxwidthsmall'];
91 $maxheightsmall = $tmparraysize[
'maxheightsmall'];
92 $maxwidthmini = $tmparraysize[
'maxwidthmini'];
93 $maxheightmini = $tmparraysize[
'maxheightmini'];
94 $quality = $tmparraysize[
'quality'];
99 if ($htmlname ==
'logo_squarred') {
106 $maxmin = $maxfilesizearray[
'maxmin'];
112 $out .=
'<div class="centpercent nobordernopadding valignmiddle"><div class="inline-block marginrightonly">';
114 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
116 $out .=
'<input type="file" class="flat minwidth100 maxwidthinputfileonsmartphone" name="'.$htmlname.
'" id="'.$htmlname.
'" accept="image/*">';
118 if (!empty($fileformainimagesmall)) {
119 $out .=
'<div class="inline-block valignmiddle marginrightonly">';
120 $out .=
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=remove'.$htmlname.
'&token='.
newToken().
'">'.
img_delete($langs->trans(
"Delete"),
'',
'marginleftonly').
'</a>';
122 if (file_exists($dirformainimage.
'/'.$subdirformainimage.$fileformainimagesmall)) {
123 $out .=
'<div class="inline-block valignmiddle marginrightonly">';
124 $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).
'">';
126 } elseif (!empty($fileformainimage)) {
128 if (!file_exists($dirformainimage.
'/'.$subdirformainimage.$fileformainimagemini)) {
129 $imgThumbMini =
vignette($dirformainimage.
'/'.$subdirformainimage.$fileformainimage, $maxwidthmini, $maxheightmini,
'_mini', $quality);
131 $imgThumbSmall =
vignette($dirformainimage.
'/'.$subdirformainimage.$fileformainimage, $maxwidthsmall, $maxheightsmall,
'_small', $quality);
132 $out .=
'<div class="inline-block valignmiddle">';
133 $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)).
'">';
136 } elseif (!empty($fileformainimage)) {
137 if (file_exists($dirformainimage.
'/'.$subdirformainimage.$fileformainimage)) {
138 $out .=
'<div class="inline-block valignmiddle">';
139 $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).
'">';
141 $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>';
143 $out .=
'<div class="inline-block valignmiddle">';
144 $out .=
'<img id="'.$htmlname.
'" height="'.$imgheight.
'" src="'.DOL_URL_ROOT.
'/public/theme/common/nophoto.png" title="File has been removed from disk">';
178 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)
181 global
$conf, $langs, $hookmanager;
182 $hookmanager->initHooks(array(
'formfile'));
186 dol_syslog(__METHOD__.
": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
189 if (!empty(
$conf->browser->layout) &&
$conf->browser->layout !=
'classic') {
203 $out =
"\n".
'<!-- Start form attach new file --><div class="formattachnewfile">'.
"\n";
205 if ($nooutput != 2) {
207 $title = $langs->trans(
"AttachANewFile");
209 if ($title !=
'none') {
214 if (empty($usewithoutform)) {
216 $url .= (strpos($url,
'?') ===
false ?
'?' :
'&').
'uploadform=1';
218 $out .=
'<form name="'.$htmlname.
'" id="'.$htmlname.
'" action="'.$url.
'" enctype="multipart/form-data" method="POST">'.
"\n";
220 if (empty($usewithoutform) || $usewithoutform == 2) {
221 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
222 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_dir" name="section_dir" value="'.$sectiondir.
'">'.
"\n";
223 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_id" name="section_id" value="'.$sectionid.
'">'.
"\n";
224 $out .=
'<input type="hidden" name="sortfield" value="'.GETPOST(
'sortfield',
'aZ09comma').
'">'.
"\n";
225 $out .=
'<input type="hidden" name="sortorder" value="'.GETPOST(
'sortorder',
'aZ09comma').
'">'.
"\n";
226 $out .=
'<input type="hidden" name="page_y" value="">'.
"\n";
229 $out .=
'<table class="nobordernopadding centpercent">';
232 if (!empty($options)) {
233 $out .=
'<td>'.$options.
'</td>';
236 $out .=
'<td class="valignmiddle nowrap">';
239 $max = $maxfilesizearray[
'max'];
240 $maxmin = $maxfilesizearray[
'maxmin'];
241 $maxphptoshow = $maxfilesizearray[
'maxphptoshow'];
242 $maxphptoshowparam = $maxfilesizearray[
'maxphptoshowparam'];
244 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
246 $out .=
'<input class="flat minwidth400 maxwidth200onsmartphone" type="file"';
247 $out .= ((
getDolGlobalString(
'MAIN_DISABLE_MULTIPLE_FILEUPLOAD') || $disablemulti) ?
' name="userfile"' :
' name="userfile[]" multiple');
249 $out .= (!empty($accept) ?
' accept="'.$accept.
'"' :
' accept=""');
250 $out .= (!empty($capture) ?
' capture="capture"' :
'');
254 $langs->load(
'link');
255 $out .=
'<span class="nowraponsmartphone"><input style="margin-right: 2px;" type="checkbox" id="overwritefile" name="overwritefile" value="1">';
256 $out .=
'<label for="overwritefile" class="opacitylow paddingleft paddingright">'.$langs->trans(
"OverwriteIfExists").
'</label>';
259 $out .=
'<input type="submit" class="button smallpaddingimp reposition" name="sendit" value="'.$langs->trans(
"Upload").
'"';
265 $out .=
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
269 if ($perm && empty(
$conf->dol_optimize_smallscreen)) {
270 $langs->load(
'other');
272 $menudolibarrsetupmax = $langs->transnoentitiesnoconv(
"Home").
' - '.$langs->transnoentitiesnoconv(
"Setup").
' - '.$langs->transnoentitiesnoconv(
"Security");
274 $tooltiptext = $langs->trans(
"ThisLimitIsDefinedInSetupAt", $menudolibarrsetupmax, $max, $maxphptoshowparam, $maxphptoshow);
276 $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>';
280 $out .=
info_admin($tooltiptext, 1, 0,
'1',
'classfortooltip');
283 $out .=
' ('.$langs->trans(
"UploadDisabled").
')';
285 $out .=
"</td></tr>";
287 if ($savingdocmask) {
289 $rename =
getDolGlobalString(
'MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT') ?
'' :
'checked';
292 if (!empty($options)) {
293 $out .=
'<td>'.$options.
'</td>';
295 $out .=
'<td valign="middle" class="nowrap">';
296 $out .=
'<input type="checkbox" '.$rename.
' class="savingdocmask" name="savingdocmask" id="savingdocmask" value="'.
dol_escape_js($savingdocmask).
'"> ';
297 $out .=
'<label class="opacitymedium small" for="savingdocmask">';
298 $out .= $langs->trans(
"SaveUploadedFileWithMask", preg_replace(
'/__file__/', $langs->transnoentitiesnoconv(
"OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv(
"OriginFileName"));
306 if (empty($usewithoutform)) {
308 if (empty($sectionid)) {
313 $parameters = array(
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url' => $url,
'perm' => $perm,
'options' => $options);
315 $res = $hookmanager->executeHooks(
'formattachOptionsUpload', $parameters,
$object);
317 $out =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').
'attacharea'.$htmlname)).
'">'.$out.
'</div>';
319 $out .= $hookmanager->resPrint;
321 $out .=
"\n</div><!-- End form class=formattachnewfile -->\n";
328 $out2 .=
"\n".
'<!-- Start form link new url --><div class="formlinknewurl">'.
"\n";
329 $langs->load(
'link');
331 if ($nooutput != 2) {
332 $title = $langs->trans(
"LinkANewFile");
336 if (empty($usewithoutform)) {
337 $out2 .=
'<form name="'.$htmlname.
'_link" id="'.$htmlname.
'_link" action="'.$url.
'" method="POST">'.
"\n";
338 $out2 .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
339 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_dir" name="link_section_dir" value="">'.
"\n";
340 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_id" name="link_section_id" value="'.$sectionid.
'">'.
"\n";
341 $out2 .=
'<input type="hidden" name="page_y" value="">'.
"\n";
344 $out2 .=
'<div class="valignmiddle">';
345 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
347 $out2 .=
'<label for="link">'.$langs->trans(
"URLToLink").
':</label> ';
349 $out2 .=
'<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans(
"URLToLink")).
'">';
351 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
353 $out2 .=
'<label for="label">'.$langs->trans(
"Label").
':</label> ';
355 $out2 .=
'<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans(
"Label")).
'">';
356 $out2 .=
'<input type="hidden" name="objecttype" value="'.$object->element.
'">';
357 $out2 .=
'<input type="hidden" name="objectid" value="'.$object->id.
'">';
359 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
360 $out2 .=
'<input type="submit" class="button smallpaddingimp reposition" name="linkit" value="'.$langs->trans(
"ToLink").
'"';
365 if (empty($usewithoutform)) {
366 $out2 .=
'<div class="clearboth"></div>';
367 $out2 .=
'</form><br>';
370 $parameters = array(
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url' => $url,
'perm' => $perm,
'options' => $options);
371 $res = $hookmanager->executeHooks(
'formattachOptions', $parameters,
$object);
373 $out2 =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').$htmlname)).
'">'.$out2.
'</div>';
375 $out2 .= $hookmanager->resPrint;
377 $out2 .=
"\n</div><!-- End form class=formlinknewurl -->\n";
381 if ($nooutput == 2) {
382 return array(
'formToUploadAFile' => $out,
'formToAddALink' => $out2);
383 } elseif ($nooutput) {
414 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 =
'')
417 $this->numoffiles = 0;
418 print $this->
showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
419 return $this->numoffiles;
449 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 =
'')
454 if (!empty($iconPDF)) {
455 dol_syslog(__METHOD__.
": passing iconPDF parameter is deprecated", LOG_WARNING);
458 global $langs,
$conf, $user, $hookmanager;
462 if (is_object($hookmanager)) {
464 'modulepart' => &$modulepart,
465 'modulesubdir' => &$modulesubdir,
466 'filedir' => &$filedir,
467 'urlsource' => &$urlsource,
468 'genallowed' => &$genallowed,
469 'delallowed' => &$delallowed,
470 'modelselected' => &$modelselected,
471 'allowgenifempty' => &$allowgenifempty,
472 'forcenomultilang' => &$forcenomultilang,
473 'noform' => &$noform,
476 'buttonlabel' => &$buttonlabel,
477 'codelang' => &$codelang,
478 'morepicto' => &$morepicto,
479 'hideifempty' => &$hideifempty,
480 'removeaction' => &$removeaction
482 $reshook = $hookmanager->executeHooks(
'showDocuments', $parameters,
$object);
490 return $hookmanager->resPrint;
493 if (!is_object($form)) {
494 $form =
new Form($this->db);
497 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
500 if (!empty($iconPDF)) {
505 if (!preg_match(
'/entity\=[0-9]+/', $param)) {
506 $param .= ($param ?
'&' :
'').
'entity='.(empty(
$object->entity) ?
$conf->entity :
$object->entity);
509 $printer = ($user->hasRight(
'printing',
'read') &&
isModEnabled(
'printing'));
511 $hookmanager->initHooks(array(
'formfile'));
514 $file_list = array();
515 if (!empty($filedir)) {
516 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
518 if ($hideifempty && empty($file_list)) {
523 $forname =
'builddoc';
528 $out .=
"\n".
'<!-- Start show_document -->'.
"\n";
530 if (preg_match(
'/massfilesarea_/', $modulepart)) {
531 $out .=
'<div id="show_files"><br></div>'.
"\n";
532 $title = $langs->trans(
"MassFilesArea").
' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans(
"Hide").
')</a>';
533 $title .=
'<script nonce="'.getNonce().
'">
534 jQuery(document).ready(function() {
535 jQuery(\'#togglemassfilesarea\').click(function() {
536 if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown")
538 jQuery(\'#'.$modulepart.
'_table\').hide();
539 jQuery(\'#togglemassfilesarea\').attr("ref", "hidden");
540 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Show")).
')");
544 jQuery(\'#'.$modulepart.
'_table\').show();
545 jQuery(\'#togglemassfilesarea\').attr("ref","shown");
546 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Hide")).
')");
554 $titletoshow = $langs->trans(
"Documents");
555 if (!empty($title)) {
556 $titletoshow = ($title ==
'none' ?
'' : $title);
559 $submodulepart = $modulepart;
562 $tmp = explode(
':', $modulepart);
563 if (!empty($tmp[1])) {
564 $modulepart = $tmp[0];
565 $submodulepart = $tmp[1];
568 $addcolumforpicto = ($delallowed || $printer || $morepicto);
569 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
574 $modellist = array();
576 if ($modulepart ==
'company') {
578 if (is_array($genallowed)) {
579 $modellist = $genallowed;
581 include_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
584 } elseif ($modulepart ==
'propal') {
585 if (is_array($genallowed)) {
586 $modellist = $genallowed;
588 include_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
591 } elseif ($modulepart ==
'supplier_proposal') {
592 if (is_array($genallowed)) {
593 $modellist = $genallowed;
595 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
598 } elseif ($modulepart ==
'commande') {
599 if (is_array($genallowed)) {
600 $modellist = $genallowed;
602 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
605 } elseif ($modulepart ==
'expedition') {
606 if (is_array($genallowed)) {
607 $modellist = $genallowed;
609 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
612 } elseif ($modulepart ==
'reception') {
613 if (is_array($genallowed)) {
614 $modellist = $genallowed;
616 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
619 } elseif ($modulepart ==
'delivery') {
620 if (is_array($genallowed)) {
621 $modellist = $genallowed;
623 include_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
626 } elseif ($modulepart ==
'ficheinter') {
627 if (is_array($genallowed)) {
628 $modellist = $genallowed;
630 include_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
633 } elseif ($modulepart ==
'facture') {
634 if (is_array($genallowed)) {
635 $modellist = $genallowed;
637 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
640 } elseif ($modulepart ==
'contract') {
642 if (is_array($genallowed)) {
643 $modellist = $genallowed;
645 include_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
648 } elseif ($modulepart ==
'project') {
649 if (is_array($genallowed)) {
650 $modellist = $genallowed;
652 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
655 } elseif ($modulepart ==
'project_task') {
656 if (is_array($genallowed)) {
657 $modellist = $genallowed;
659 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
662 } elseif ($modulepart ==
'product') {
663 if (is_array($genallowed)) {
664 $modellist = $genallowed;
666 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
669 } elseif ($modulepart ==
'product_batch') {
670 if (is_array($genallowed)) {
671 $modellist = $genallowed;
673 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product_batch/modules_product_batch.class.php';
676 } elseif ($modulepart ==
'stock') {
677 if (is_array($genallowed)) {
678 $modellist = $genallowed;
680 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_stock.php';
683 } elseif ($modulepart ==
'hrm') {
684 if (is_array($genallowed)) {
685 $modellist = $genallowed;
687 include_once DOL_DOCUMENT_ROOT.
'/core/modules/hrm/modules_evaluation.php';
690 } elseif ($modulepart ==
'movement') {
691 if (is_array($genallowed)) {
692 $modellist = $genallowed;
694 include_once DOL_DOCUMENT_ROOT.
'/core/modules/movement/modules_movement.php';
697 } elseif ($modulepart ==
'export') {
698 if (is_array($genallowed)) {
699 $modellist = $genallowed;
701 include_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
703 $modellist = array();
705 } elseif ($modulepart ==
'commande_fournisseur' || $modulepart ==
'supplier_order') {
706 if (is_array($genallowed)) {
707 $modellist = $genallowed;
709 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
712 } elseif ($modulepart ==
'facture_fournisseur' || $modulepart ==
'supplier_invoice') {
714 if (is_array($genallowed)) {
715 $modellist = $genallowed;
717 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
720 } elseif ($modulepart ==
'supplier_payment') {
721 if (is_array($genallowed)) {
722 $modellist = $genallowed;
724 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
727 } elseif ($modulepart ==
'remisecheque') {
728 if (is_array($genallowed)) {
729 $modellist = $genallowed;
731 include_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
734 } elseif ($modulepart ==
'donation') {
735 if (is_array($genallowed)) {
736 $modellist = $genallowed;
738 include_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
741 } elseif ($modulepart ==
'member') {
742 if (is_array($genallowed)) {
743 $modellist = $genallowed;
745 include_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
748 } elseif ($modulepart ==
'agenda' || $modulepart ==
'actions') {
749 if (is_array($genallowed)) {
750 $modellist = $genallowed;
752 include_once DOL_DOCUMENT_ROOT.
'/core/modules/action/modules_action.php';
755 } elseif ($modulepart ==
'expensereport') {
756 if (is_array($genallowed)) {
757 $modellist = $genallowed;
759 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
762 } elseif ($modulepart ==
'unpaid') {
764 } elseif ($modulepart ==
'user') {
765 if (is_array($genallowed)) {
766 $modellist = $genallowed;
768 include_once DOL_DOCUMENT_ROOT.
'/core/modules/user/modules_user.class.php';
771 } elseif ($modulepart ==
'usergroup') {
772 if (is_array($genallowed)) {
773 $modellist = $genallowed;
775 include_once DOL_DOCUMENT_ROOT.
'/core/modules/usergroup/modules_usergroup.class.php';
780 $file =
dol_buildpath(
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
782 if (file_exists($file)) {
783 $res = include_once $file;
786 $file =
dol_buildpath(
'/'.$modulepart.
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
787 $res = include_once $file;
790 $class =
'ModelePDF'.ucfirst($submodulepart);
792 if (class_exists($class)) {
793 $modellist = call_user_func($class.
'::liste_modeles', $this->db);
795 dol_print_error($this->db,
"Bad value for modulepart '".$modulepart.
"' in showdocuments (class ".$class.
" for Doc generation not found)");
803 if (empty($buttonlabel)) {
804 $buttonlabel = $langs->trans(
'Generate');
807 if (
$conf->browser->layout ==
'phone') {
808 $urlsource .=
'#'.$forname.
'_form';
810 if (empty($noform)) {
811 $out .=
'<form action="'.$urlsource.
'" id="'.$forname.
'_form" method="post">';
813 $out .=
'<input type="hidden" name="action" value="builddoc">';
814 $out .=
'<input type="hidden" name="page_y" value="">';
815 $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,
'', 1, 0, 0,
'', $morecss, 1,
'', 0, 0);
843 if (
$conf->use_javascript_ajax) {
846 $out .= $form->textwithpicto(
'', $tooltipontemplatecombo, 1,
'help',
'marginrightonly', 0, 3,
'', 0);
848 $out .=
'<div class="float">'.$langs->trans(
"Files").
'</div>';
852 if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) &&
getDolGlobalInt(
'MAIN_MULTILANGS') && !$forcenomultilang && (!empty($modellist) || $showempty)) {
853 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
855 $defaultlang = ($codelang && $codelang !=
'auto') ? $codelang : $langs->getDefaultLang();
856 $morecss =
'maxwidth150';
857 if (
$conf->browser->layout ==
'phone') {
858 $morecss =
'maxwidth100';
860 $out .= $formadmin->select_language($defaultlang,
'lang_id', 0, array(), 0, 0, 0, $morecss);
866 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
867 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
868 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
869 $genbutton .=
' disabled';
872 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty(
$conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
873 $langs->load(
"errors");
874 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
879 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty(
$conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
882 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
888 if (!empty($hookmanager->hooks[
'formfile'])) {
889 foreach ($hookmanager->hooks[
'formfile'] as $module) {
890 if (method_exists($module,
'formBuilddocLineOptions')) {
899 $parameters = array(
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart);
900 if (is_object($hookmanager)) {
901 $reshook = $hookmanager->executeHooks(
'formBuilddocOptions', $parameters, $GLOBALS[
'object']);
902 $out .= $hookmanager->resPrint;
907 if (!empty($filedir)) {
908 $link_list = array();
910 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
911 $link =
new Link($this->db);
912 $sortfield = $sortorder =
'';
913 $res = $link->fetchAll($link_list,
$object->element,
$object->id, $sortfield, $sortorder);
916 $out .=
'<!-- html.formfile::showdocuments -->'.
"\n";
919 if ((!empty($file_list) || !empty($link_list) || preg_match(
'/^massfilesarea/', $modulepart))
922 $out .=
'<div class="titre paddingbottom">'.$titletoshow.
'</div>'.
"\n";
923 $out .=
'<div class="div-table-responsive-no-min">';
924 $out .=
'<table class="noborder centpercent" id="'.$modulepart.
'_table">'.
"\n";
928 if (is_array($file_list)) {
929 '@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';
933 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
934 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
940 '@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';
943 if (!empty($sortfield) && !empty($sortorder)) {
948 '@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';
950 require_once DOL_DOCUMENT_ROOT .
'/ecm/class/ecmfiles.class.php';
953 foreach ($file_list as $file) {
956 if (!empty($file[
'rowid']) && $user->hasRight(
'ecm',
'read')) {
960 $ecmfile->fetch($file[
'rowid']);
967 $relativepath = (
string) $file[
"name"];
969 $relativepath = (
string) $modulesubdir.
"/".$file[
"name"];
971 if ($modulepart ==
'export') {
972 $relativepath = (
string) $file[
"name"];
975 $tmpout =
'<tr class="oddeven'.((!$genallowed && $i == 1) ?
' trfirstline' :
'').
'">';
977 $documenturl =
getDolGlobalString(
'DOL_URL_ROOT_DOCUMENT_PHP', DOL_URL_ROOT.
'/document.php');
980 $imgpreview = $this->
showPreview($file, $modulepart, $relativepath, 0, $param.
'&preview=1');
981 $tmpout .=
'<td class="minwidth200 tdoverflowmax300">';
983 $tmpout .=
'<span class="spanoverflow widthcentpercentminusx valignmiddle">';
985 $tmpout .=
'<span class="spanoverflow">';
988 $tmpout .= $imgpreview;
991 if (is_object($ecmfile)) {
992 $tmpout .= $ecmfile->getNomUrl(1, $modulepart, 0, 0,
' documentdownload');
995 $tmpout .=
'<a class="documentdownload paddingright" ';
997 $tmpout .=
'target="_blank" ';
999 $tmpout .=
'href="'.$documenturl.
'?modulepart='.$modulepart.
'&file='.urlencode($relativepath).($param ?
'&'.$param :
'').
'"';
1001 if (preg_match(
'/text/', $mime)) {
1002 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
1004 $tmpout .=
' title="'.dol_escape_htmltag($file[
"name"]).
'"';
1006 $tmpout .=
img_mime($file[
"name"], $langs->trans(
"File").
': '.$file[
"name"]);
1007 $tmpout .=
dol_trunc($file[
"name"], 150);
1011 $tmpout .=
'</span>'.
"\n";
1013 $tmpout .= $imgpreview;
1019 $size = (!empty($file[
'size']) ? $file[
'size'] :
dol_filesize($filedir.
"/".$file[
"name"]));
1020 $tmpout .=
'<td class="nowraponall right" title="'.dolPrintHTML($size.
' '.$langs->trans(
"Bytes")).
'">'.
dol_print_size($size, 1, 1).
'</td>';
1023 $date = (!empty($file[
'date']) ? $file[
'date'] :
dol_filemtime($filedir.
"/".$file[
"name"]));
1024 $tmpout .=
'<td class="nowrap right">'.dol_print_date($date,
'dayhour',
'tzuser').
'</td>';
1027 $tmpout .=
'<td class="nowraponall">';
1028 if (!empty($file[
'share'])) {
1030 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
1031 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1035 $forcedownload =
getDolGlobalInt(
'MAIN_FORCE_DOWNLOAD_IN_HTML_FORMFILE');
1037 if (!empty($file[
'share'])) {
1038 $paramlink .=
'hashp='.$file[
'share'];
1040 if ($forcedownload) {
1041 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1044 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1046 $tmpout .=
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
1047 $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">';
1055 if ($delallowed || $printer || $morepicto) {
1056 $tmpout .=
'<td class="right nowraponall">';
1058 $tmpurlsource = preg_replace(
'/#[a-zA-Z0-9_]*$/',
'', $urlsource);
1059 $tmpout .=
'<a class="maginleftonly marginrightonly reposition" href="'.$tmpurlsource.((strpos($tmpurlsource,
'?') ===
false) ?
'?' :
'&').
'action='.urlencode($removeaction).
'&token='.
newToken().
'&file='.urlencode($relativepath);
1060 $tmpout .= ($param ?
'&'.$param :
'');
1063 $tmpout .=
'">'.img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
1066 $tmpout .=
'<a class="maginleftonly marginleftonly reposition" href="'.$urlsource.(strpos($urlsource,
'?') ?
'&' :
'?').
'action=print_file&token='.
newToken().
'&printer='.urlencode($modulepart).
'&file='.urlencode($relativepath);
1067 $tmpout .= ($param ?
'&'.$param :
'');
1068 $tmpout .=
'">'.img_picto($langs->trans(
"PrintFile", $relativepath),
'printer').
'</a>';
1071 $morepicto = preg_replace(
'/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto);
1072 $tmpout .= $morepicto;
1077 if (is_object($hookmanager)) {
1078 $addcolumforpicto = ($delallowed || $printer || $morepicto);
1079 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
1081 $parameters = array(
'tmpout' => &$tmpout,
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart,
'relativepath' => $relativepath);
1082 $res = $hookmanager->executeHooks(
'formBuilddocLineOptions', $parameters, $file);
1084 $tmpout .= $hookmanager->resPrint;
1087 $tmpout = $hookmanager->resPrint;
1096 $this->numoffiles++;
1099 if (is_array($link_list)) {
1102 foreach ($link_list as $file) {
1103 $out .=
'<tr class="oddeven">';
1104 $out .=
'<td colspan="'.$colspan.
'" class="maxwidhtonsmartphone">';
1105 $out .=
'<a data-ajax="false" href="'.$file->url.
'" target="_blank" rel="noopener noreferrer">';
1106 $out .= $file->label;
1109 $out .=
'<td class="right">';
1113 $out .=
'<td></td>';
1114 if ($delallowed || $printer || $morepicto) {
1115 $out .=
'<td></td>';
1117 $out .=
'</tr>'.
"\n";
1119 $this->numoffiles++;
1122 if (count($file_list) == 0 && count($link_list) == 0 && $headershown) {
1123 $addcolumforpicto = ($delallowed || $printer || $morepicto);
1124 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
1125 $out .=
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>'.
"\n";
1131 $out .=
"</table>\n";
1134 if (empty($noform)) {
1135 $out .=
'</form>'.
"\n";
1139 $out .=
'<!-- End show_document -->'.
"\n";
1142 jQuery(document).ready(function() {
1143 var selectedValue = $(".selectformat").val();
1145 if (selectedValue === "excel2007" || selectedValue === "tsv") {
1146 $(".forhide").prop("disabled", true).hide();
1148 $(".forhide").prop("disabled", false).show();
1169 public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
'', $morecss =
'valignmiddle', $allfiles = 0)
1171 global
$conf, $langs;
1173 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1176 $this->infofiles = array(
'nboffiles' => 0,
'extensions' => array(),
'files' => array());
1183 preg_match(
'/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,
'/').
'$/', $filedir, $regs);
1184 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
1189 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/');
1191 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/').
'\.';
1193 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
1197 $out .=
'<!-- html.formfile::getDocumentsLink -->'.
"\n";
1198 if (!empty($file_list)) {
1199 $out =
'<dl class="dropdown inline-block">
1200 <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto(
'',
'listlight',
'', 0, 0, 0,
'', $morecss).
'</a></dt>
1201 <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
1207 foreach ($file_list as $file) {
1209 if ($filter && !preg_match(
'/'.$filter.
'/i', $file[
"name"])) {
1215 $relativepath = $file[
"name"];
1216 if ($modulesubdir) {
1217 $relativepath = (
string) $modulesubdir.
"/".$file[
"name"];
1220 if ($modulepart ==
'donation') {
1221 $relativepath = (
string)
get_exdir($modulesubdir, 2, 0, 0,
null,
'donation').$file[
"name"];
1223 if ($modulepart ==
'export') {
1224 $relativepath = (
string) $file[
"name"];
1227 $this->infofiles[
'nboffiles']++;
1228 $this->infofiles[
'files'][] = $file[
'fullname'];
1229 $ext = (
string) pathinfo($file[
'name'], PATHINFO_EXTENSION);
1230 if (!array_key_exists($ext, $this->infofiles[
'extensions'])) {
1231 $this->infofiles[
'extensions'][$ext] = 1;
1233 $this->infofiles[
'extensions'][$ext]++;
1237 if (!empty(
$conf->use_javascript_ajax) && (
$conf->browser->layout !=
'phone')) {
1239 if ($tmparray && $tmparray[
'url']) {
1240 $tmpout .=
'<li><a href="'.$tmparray[
'url'].
'"'.($tmparray[
'css'] ?
' class="'.$tmparray[
'css'].
'"' :
'').($tmparray[
'mime'] ?
' mime="'.$tmparray[
'mime'].
'"' :
'').($tmparray[
'target'] ?
' target="'.$tmparray[
'target'].
'"' :
'').
'>';
1242 $tmpout .=
img_picto(
'',
'search-plus',
'class="paddingright"');
1243 $tmpout .= $langs->trans(
"Preview").
' '.$ext.
'</a></li>';
1248 $tmpout .=
'<li class="nowrap"><a class="pictopreview nowrap" ';
1250 $tmpout .=
'target="_blank" ';
1252 $tmpout .=
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($relativepath).
'"';
1254 if (preg_match(
'/text/', $mime)) {
1255 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
1258 $tmpout .=
img_mime($relativepath, $file[
"name"]);
1259 $tmpout .= $langs->trans(
"Download").
' '.$ext;
1260 $tmpout .=
'</a></li>'.
"\n";
1263 $out .=
'</ul></div></dd>
1312 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())
1315 global $user,
$conf, $langs, $hookmanager, $form;
1316 global $sortfield, $sortorder;
1319 if ($disablecrop == -1) {
1322 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'))) {
1328 if (empty($relativepath)) {
1331 $relativepath = (
$object->id).
'/';
1332 } elseif (!empty(
$object->element) &&
$object->element ==
'invoice_supplier') {
1334 } elseif (!empty(
$object->element) &&
$object->element ==
'project_task') {
1335 $relativepath =
'Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1339 if (
getDolGlobalInt(
'PRODUCT_USE_OLD_PATH_FOR_PHOTO') && isset($filearray[0]) && $filearray[0][
'level1name'] ==
'photos') {
1340 $relativepath = preg_replace(
'/^.*\/produit\//',
'', $filearray[0][
'path']).
'/';
1346 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $upload_dir);
1347 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1354 $hookmanager->initHooks(array(
'formfile'));
1355 $parameters = array(
1356 'filearray' => $filearray,
1357 'modulepart' => $modulepart,
1359 'forcedownload' => $forcedownload,
1360 'relativepath' => $relativepath,
1361 'relativedir' => $relativedir,
1362 'permtodelete' => $permonobject,
1363 'useinecm' => $useinecm,
1364 'textifempty' => $textifempty,
1365 'maxlength' => $maxlength,
1370 $reshook = $hookmanager->executeHooks(
'showFilesList', $parameters,
$object);
1372 if (!empty($reshook)) {
1375 if (!is_object($form)) {
1376 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1377 $form =
new Form($this->db);
1380 if (!preg_match(
'/&id=/', $param) && isset(
$object->id)) {
1381 $param .=
'&id='.$object->id;
1383 $relativepathwihtoutslashend = preg_replace(
'/\/$/',
'', $relativepath);
1384 if ($relativepathwihtoutslashend) {
1385 $param .=
'&file='.urlencode($relativepathwihtoutslashend);
1388 if ($permtoeditline < 0) {
1389 $permtoeditline = 0;
1390 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1391 '@phan-var-force Product $object';
1393 $permtoeditline = 1;
1396 $permtoeditline = 1;
1401 $permtoeditline = 0;
1405 $url = $_SERVER[
"PHP_SELF"];
1410 $morehtmlright =
'';
1411 if (!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) {
1412 $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);';
1413 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle', $tmpurlforbutton,
'', $permtoeditline);
1416 if ((empty($useinecm) || $useinecm == 3 || $useinecm == 6) && $title !=
'none') {
1417 print
load_fiche_titre($title ? $title : $langs->trans(
"AttachedFiles"), $morehtmlright,
'file-upload', 0,
'',
'table-list-of-attached-files');
1419 if (!empty($moreoptions) && $moreoptions[
'afteruploadtitle']) {
1420 print
'<!-- Add form from $moreoptions[\'afteruploadtitle\'] -->';
1421 print
'<div class="divattachnewfile'.((!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afteruploadtitle'].
'</div>';
1425 print
'<!-- html.formfile::list_of_documents -->'.
"\n";
1426 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1427 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?'.$param.
'" method="POST">';
1428 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1429 print
'<input type="hidden" name="action" value="renamefile">';
1430 print
'<input type="hidden" name="id" value="'.(is_object(
$object) ?
$object->id :
'').
'">';
1431 print
'<input type="hidden" name="modulepart" value="'.$modulepart.
'">';
1434 print
'<div class="div-table-responsive-no-min"'.($moreattrondiv ?
' '.$moreattrondiv :
'').
'>';
1435 print
'<table id="tablelines" class="centpercent liste noborder nobottom">'.
"\n";
1437 if (!empty($addfilterfields)) {
1438 print
'<tr class="liste_titre nodrag nodrop">';
1439 print
'<td><input type="search_doc_ref" value="'.dol_escape_htmltag(
GETPOST(
'search_doc_ref',
'alpha')).
'"></td>';
1442 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1447 if (empty($disablemove) && count($filearray) > 1) {
1456 '@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';
1459 if ($sortfield && $sortorder) {
1460 $filearray =
dol_sort_array($filearray, $sortfield, $sortorder, 1);
1464 print
'<tr class="liste_titre nodrag nodrop">';
1472 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1476 if (empty($moreoptions[
'hideshared'])) {
1481 if (!empty($moreoptions[
'buttons'])) {
1486 if (empty($disablemove) && count($filearray) > 1) {
1492 $nboffiles = count($filearray);
1493 if ($nboffiles > 0) {
1494 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1500 $parametersByDefault = array(
1501 'modulepart' => $modulepart,
1502 'relativepath' => $relativepath,
1503 'permtoedit' => $permtoeditline,
1504 'permonobject' => $permonobject,
1506 foreach ($filearray as $key => $file) {
1507 if ($file[
'name'] !=
'.' && $file[
'name'] !=
'..' && !preg_match(
'/\.meta$/i', $file[
'name'])) {
1508 if (array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) {
1509 $lastrowid = $filearray[$key][
'rowid'];
1514 $modulepart = ($file[
'modulepart'] ?? $parametersByDefault[
'modulepart']);
1515 $relativepath = ($file[
'relativepath'] ?? $parametersByDefault[
'relativepath']);
1516 $permtoeditline = ($file[
'permtoedit'] ?? $parametersByDefault[
'permtoedit']);
1517 $permonobject = ($file[
'permonobject'] ?? $parametersByDefault[
'permonobject']);
1520 if (empty($relativepath) || empty($modulepart)) {
1521 $filepath = $file[
'level1name'].
'/'.$file[
'name'];
1523 $filepath = $relativepath.$file[
'name'];
1525 if (empty($modulepart)) {
1526 $modulepart = basename(dirname($file[
'path']));
1528 if (empty($relativepath)) {
1529 $relativepath = preg_replace(
'/\/(.+)/',
'', $filepath) .
'/';
1534 print
'<!-- Line list_of_documents '.$key.
' relativepath = '.$relativepath.
' -->'.
"\n";
1537 print
'<!-- In database: position='.(array_key_exists(
'position', $filearray[$key]) ? $filearray[$key][
'position'] : 0).
' -->'.
"\n";
1538 print
'<tr class="oddeven" id="row-'.((array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) ? $filearray[$key][
'rowid'] :
'AFTER'.$lastrowid.
'POS'.($i + 1)).
'">';
1542 print
'<td class="minwidth200imp tdoverflowmax500" title="'.dolPrintHTMLForAttribute($file[
'name']).
'">';
1546 print
'<a class="paddingright valignmiddle" ';
1548 print
'target="_blank" ';
1550 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.urlencode($modulepart);
1551 if ($forcedownload) {
1552 print
'&attachment=1';
1554 if (!empty(
$object->entity)) {
1555 print
'&entity='.((int)
$object->entity);
1557 print
'&file='.urlencode($filepath);
1559 print
img_mime($file[
'name'], $file[
'name'].
' ('.
dol_print_size($file[
'size'], 0, 0).
')',
'inline-block valignmiddle paddingright');
1560 if ($showrelpart == 1) {
1561 print $relativepath;
1567 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $file[
'name'] == basename(
GETPOST(
'urlfile',
'alpha')) && dirname($filepath) == dirname(
GETPOST(
'urlfile',
'alpha'))) {
1569 $section_dir = dirname(
GETPOST(
'urlfile',
'alpha'));
1570 if (!preg_match(
'/\/$/', $section_dir)) {
1571 $section_dir .=
'/';
1573 print
'<input type="hidden" name="section_dir" value="'.$section_dir.
'">';
1574 print
'<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file[
'name']).
'">';
1575 print
'<input type="text" name="renamefileto" class="centpercentminusx" value="'.dol_escape_htmltag($file[
'name']).
'" spellcheck="false">';
1578 $filenametoshow = preg_replace(
'/\.noexe$/',
'', $file[
'name']);
1592 print
'<td class="right nowraponall">';
1593 if ($sizetoshow == $sizetoshowbytes) {
1596 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1601 print
'<td class="center nowraponall">'.dol_print_date($file[
'date'],
"dayhour",
"tzuser").
'</td>';
1604 $fileinfo = pathinfo($file[
'name']);
1605 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1606 print
'<td class="center">';
1608 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 if (empty($moreoptions[
'hideshared'])) {
1647 print
'<td class="center nowraponsmartphone">';
1648 if ($relativedir && $filearray[$key][
'rowid'] > 0) {
1650 print
'<label for="idshareenabled'.$key.
'">'.$langs->trans(
"FileSharedViaALink").
'</label> ';
1651 print
'<input class="inline-block" type="checkbox" id="idshareenabled'.$key.
'" name="shareenabled"'.($file[
'share'] ?
' checked="checked"' :
'').
' /> ';
1653 if ($file[
'share']) {
1655 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
1656 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1660 $forcedownload =
getDolGlobalInt(
'MAIN_FORCE_DOWNLOAD_IN_HTML_FORMFILE');
1662 if (!empty($file[
'share'])) {
1663 $paramlink .=
'hashp='.$file[
'share'];
1665 if ($forcedownload) {
1666 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1669 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1671 print
'<!-- shared link -->';
1672 print
'<a href="'.$fulllink.
'" target="_blank" rel="noopener" data-showidonhover="downloadlink'.$filearray[$key][
'rowid'].
'">';
1673 print
img_picto($langs->trans(
"FileSharedViaALink"),
'collab');
1675 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">';
1685 if (!empty($moreoptions[
'buttons'])) {
1687 foreach ($moreoptions[
'buttons'] as $moreoptval) {
1688 print
'<a href="'.$moreoptval[
'url'].
'&urlfile='.urlencode($file[
'name']).
'">';
1689 print $moreoptval[
'picto'];
1699 print
'<td class="valignmiddle right actionbuttons nowraponall"><!-- action on files -->';
1700 if ($useinecm == 1 || $useinecm == 5) {
1702 $newparam = preg_replace(
'/&file=.*$/',
'', $param);
1703 $backtopage = DOL_URL_ROOT.
'/ecm/index.php?§ion_dir='.urlencode($relativepath).$newparam;
1704 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>';
1707 if (empty($useinecm) || $useinecm == 2 || $useinecm == 3 || $useinecm == 6) {
1708 $newmodulepart = $modulepart;
1709 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1710 $newmodulepart =
'produit|service';
1713 if ($permtoeditline) {
1714 $moreparaminurl =
'';
1716 $moreparaminurl .=
'&id='.$object->id;
1717 } elseif (
GETPOST(
'website',
'alpha')) {
1718 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1721 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1722 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1725 if (!preg_match(
'/\.webp$/i', $file[
'name'])) {
1726 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1727 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>';
1728 } elseif ($modulepart ==
'medias' &&
GETPOST(
'website')) {
1729 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>';
1735 if ($permtoeditline) {
1737 $moreparaminurl =
'';
1739 $moreparaminurl .=
'&id='.$object->id;
1740 } elseif (
GETPOST(
'website',
'alpha')) {
1741 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1744 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1745 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1748 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>';
1752 if ($permtoeditline) {
1753 $paramsectiondir = (in_array($modulepart, array(
'medias',
'ecm')) ?
'§ion_dir='.urlencode($relativepath) :
'');
1754 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>';
1758 if ($permonobject) {
1760 if (!empty(
$conf->dol_use_jmobile)) {
1763 if (empty(
$conf->use_javascript_ajax)) {
1770 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>';
1774 if (empty($disablemove) && count($filearray) > 1) {
1775 if ($nboffiles > 1 &&
$conf->browser->layout !=
'phone') {
1776 print
'<td class="linecolmove tdlineupdown center">';
1778 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=up&token='.
newToken().
'&rowid='.
$object->id.
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
1780 if ($i < ($nboffiles - 1)) {
1781 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=down&token='.
newToken().
'&rowid='.
$object->id.
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
1785 print
'<td'.(($conf->browser->layout !=
'phone') ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'>';
1790 print
'<td class="right">';
1791 print
'<input type="hidden" name="ecmfileid" value="'.(empty($filearray[$key][
'rowid']) ?
'' : $filearray[$key][
'rowid']).
'">';
1792 print
'<input type="submit" class="button button-save smallpaddingimp" name="renamefilesave" value="'.dolPrintHTMLForAttribute($langs->transnoentitiesnoconv(
"Save")).
'">';
1793 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.dolPrintHTMLForAttribute($langs->transnoentitiesnoconv(
"Cancel")).
'">';
1795 if (empty($disablemove) && count($filearray) > 1) {
1796 print
'<td class="right"></td>';
1804 if ($nboffiles == 0) {
1806 if (!empty($moreoptions[
'buttons'])) {
1809 if (!empty($moreoptions[
'hideshared'])) {
1812 if (empty($disablemove) && count($filearray) > 1) {
1815 print
'<tr class="oddeven"><td colspan="'.$colspan.
'">';
1816 if (empty($textifempty)) {
1817 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
1819 print
'<span class="opacitymedium">'.dolPrintHTML($textifempty).
'</span>';
1827 if ($nboflines > 1 && is_object(
$object)) {
1828 if (!empty(
$conf->use_javascript_ajax) && $permtoeditline) {
1829 $table_element_line =
'ecm_files';
1830 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1836 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1864 public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath =
'', $permissiontodelete = 1, $useinecm = 0, $textifempty =
'', $maxlength = 0, $url =
'', $addfilterfields = 0)
1867 global
$conf, $langs, $hookmanager, $form;
1868 global $sortfield, $sortorder;
1869 global $search_doc_ref;
1872 dol_syslog(get_class($this).
'::list_of_autoecmfiles upload_dir='.$upload_dir.
' modulepart='.$modulepart);
1875 if (empty($useinecm) || $useinecm == 6) {
1879 $url = $_SERVER[
"PHP_SELF"];
1882 if (!empty($addfilterfields)) {
1883 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'">';
1884 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1885 print
'<input type="hidden" name="module" value="'.$modulepart.
'">';
1888 print
'<div class="div-table-responsive-no-min">';
1889 print
'<table class="noborder centpercent">'.
"\n";
1891 if (!empty($addfilterfields)) {
1892 print
'<tr class="liste_titre nodrag nodrop">';
1894 print
'<td class="liste_titre"></td>';
1896 print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1898 print
'<td class="liste_titre"></td>';
1900 print
'<td class="liste_titre"></td>';
1902 print
'<td class="liste_titre right">';
1903 $searchpicto = $form->showFilterButtons();
1909 print
'<tr class="liste_titre">';
1910 $sortref =
"fullname";
1911 if ($modulepart ==
'invoice_supplier') {
1912 $sortref =
'level1name';
1922 $object_instance =
null;
1923 if ($modulepart ==
'company') {
1924 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1925 $object_instance =
new Societe($this->db);
1926 } elseif ($modulepart ==
'invoice') {
1927 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1928 $object_instance =
new Facture($this->db);
1929 } elseif ($modulepart ==
'invoice_supplier') {
1930 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1932 } elseif ($modulepart ==
'propal') {
1933 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
1934 $object_instance =
new Propal($this->db);
1935 } elseif ($modulepart ==
'supplier_proposal') {
1936 include_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
1938 } elseif ($modulepart ==
'order') {
1939 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1940 $object_instance =
new Commande($this->db);
1941 } elseif ($modulepart ==
'order_supplier') {
1942 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1944 } elseif ($modulepart ==
'contract') {
1945 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1946 $object_instance =
new Contrat($this->db);
1947 } elseif ($modulepart ==
'product') {
1948 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1949 $object_instance =
new Product($this->db);
1950 } elseif ($modulepart ==
'tax') {
1951 include_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
1953 } elseif ($modulepart ==
'tax-vat') {
1954 include_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
1955 $object_instance =
new Tva($this->db);
1956 } elseif ($modulepart ==
'salaries') {
1957 include_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
1958 $object_instance =
new Salary($this->db);
1959 } elseif ($modulepart ==
'project') {
1960 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1961 $object_instance =
new Project($this->db);
1962 } elseif ($modulepart ==
'project_task') {
1963 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1964 $object_instance =
new Task($this->db);
1965 } elseif ($modulepart ==
'fichinter') {
1966 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
1967 $object_instance =
new Fichinter($this->db);
1968 } elseif ($modulepart ==
'user') {
1969 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1970 $object_instance =
new User($this->db);
1971 } elseif ($modulepart ==
'expensereport') {
1972 include_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1974 } elseif ($modulepart ==
'holiday') {
1975 include_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
1976 $object_instance =
new Holiday($this->db);
1977 } elseif ($modulepart ==
'recruitment-recruitmentcandidature') {
1978 include_once DOL_DOCUMENT_ROOT.
'/recruitment/class/recruitmentcandidature.class.php';
1980 } elseif ($modulepart ==
'banque') {
1981 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1982 $object_instance =
new Account($this->db);
1983 } elseif ($modulepart ==
'bank-statement') {
1985 $object_instance =
null;
1986 } elseif ($modulepart ==
'chequereceipt') {
1987 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
1989 } elseif ($modulepart ==
'mrp-mo') {
1990 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
1991 $object_instance =
new Mo($this->db);
1993 $parameters = array(
'modulepart' => $modulepart);
1994 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
1995 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
1996 if (array_key_exists(
'classpath', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classpath'])) {
1998 if (array_key_exists(
'classname', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classname'])) {
1999 $tmpclassname = $hookmanager->resArray[
'classname'];
2000 if (is_string($tmpclassname) && class_exists($tmpclassname)) {
2001 $object_instance =
new $tmpclassname($this->db);
2012 $relativepathfromroot = preg_replace(
'/'.preg_quote(DOL_DATA_ROOT.
'/',
'/').
'/',
'', $upload_dir);
2013 if ($relativepathfromroot) {
2015 '@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';
2018 if ($sortfield && $sortorder) {
2019 $filearray =
dol_sort_array($filearray, $sortfield, $sortorder, 1);
2025 foreach ($filearray as $key => $file) {
2026 if (!is_dir($file[
'name'])
2027 && $file[
'name'] !=
'.'
2028 && $file[
'name'] !=
'..'
2029 && $file[
'name'] !=
'CVS'
2030 && !preg_match(
'/\.meta$/i', $file[
'name'])) {
2032 $relativefile = preg_replace(
'/'.preg_quote($upload_dir.
'/',
'/').
'/',
'', $file[
'fullname']);
2040 if ($modulepart ==
'company' || $modulepart ==
'tax' || $modulepart ==
'tax-vat' || $modulepart ==
'salaries') {
2041 preg_match(
'/(\d+)\/[^\/]+$/', $relativefile, $reg);
2042 $id = (isset($reg[1]) ? $reg[1] :
'');
2043 } elseif ($modulepart ==
'invoice_supplier') {
2044 preg_match(
'/([^\/]+)\/[^\/]+$/', $relativefile, $reg);
2045 $ref = (isset($reg[1]) ? $reg[1] :
'');
2046 if (is_numeric($ref)) {
2050 } elseif ($modulepart ==
'user') {
2052 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
2053 $id = (isset($reg[1]) ? $reg[1] :
'');
2054 } elseif ($modulepart ==
'project_task') {
2056 $reg = explode(
"/", $relativefile);
2057 $ref = (isset($reg[1]) ? $reg[1] :
'');
2058 } elseif (in_array($modulepart, array(
2061 'supplier_proposal',
2070 'recruitment-recruitmentcandidature',
2075 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
2076 $ref = (isset($reg[1]) ? $reg[1] :
'');
2078 $parameters = array(
'modulepart' => $modulepart,
'fileinfo' => $file);
2079 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
2080 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
2081 if (array_key_exists(
'ref', $hookmanager->resArray) && !empty($hookmanager->resArray[
'ref'])) {
2082 $ref = $hookmanager->resArray[
'ref'];
2084 if (array_key_exists(
'id', $hookmanager->resArray) && !empty($hookmanager->resArray[
'id'])) {
2085 $id = $hookmanager->resArray[
'id'];
2091 if (!
$id && !$ref) {
2096 if (!empty(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2102 if (is_object($object_instance)) {
2103 $object_instance->id = 0;
2104 $object_instance->ref =
'';
2106 $result = $object_instance->fetch(
$id);
2108 $result = $object_instance->fetch(0, $ref);
2110 print $object_instance->error;
2111 } elseif ($result == 0) {
2117 $result = $object_instance->fetchOneLike($ref);
2124 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] = clone $object_instance;
2128 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] =
'notfound';
2129 unset($filearray[$key]);
2133 if ($found <= 0 || !is_object(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2137 print
'<!-- Line list_of_autoecmfiles key='.$key.
' -->'.
"\n";
2138 print
'<tr class="oddeven">';
2140 print
'<td class="tdoverflowmax150">';
2141 if ($found > 0 && is_object(
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2142 $tmpobject =
$conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref];
2144 print $tmpobject->getNomUrl(1,
'document');
2149 print $langs->trans(
"ObjectDeleted", (
$id ?
$id : $ref));
2167 print
'target="_blank" ';
2169 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.urlencode($modulepart);
2170 if ($forcedownload) {
2171 print
'&attachment=1';
2173 print
'&file='.urlencode($relativefile).
'">';
2180 print $this->
showPreview($file, $modulepart, $file[
'relativename']);
2187 print
'<td class="right nowraponall">';
2188 if ($sizetoshow == $sizetoshowbytes) {
2191 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
2196 print
'<td class="center">'.dol_print_date($file[
'date'],
"dayhour").
'</td>';
2199 print
'<td class="right">';
2200 if (!empty($file[
'share'])) {
2202 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim(
$dolibarr_main_url_root));
2203 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2207 $forcedownload =
getDolGlobalInt(
'MAIN_FORCE_DOWNLOAD_IN_HTML_FORMFILE');
2209 if (!empty($file[
'share'])) {
2210 $paramlink .=
'hashp='.$file[
'share'];
2212 if ($forcedownload) {
2213 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
2216 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
2218 print
'<!-- shared link -->';
2219 print
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
2220 print
'<input type="text" class="quatrevingtpercent width100 nopadding nopadding small downloadexternallink" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'" spellcheck="false">';
2234 if (count($filearray) == 0) {
2235 print
'<tr class="oddeven"><td colspan="5">';
2236 if (empty($textifempty)) {
2237 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
2239 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
2246 if (!empty($addfilterfields)) {
2249 return count($filearray);
2265 public function listOfLinks(
$object, $permissiontodelete = 1, $action =
null, $selected =
null, $param =
'', $htmlname =
'formaddlink', $moreoptions = array())
2267 global
$conf, $langs;
2268 global $sortfield, $sortorder;
2270 $langs->load(
"link");
2272 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2273 $link =
new Link($this->db);
2275 if ($sortfield ==
"name") {
2276 $sortfield =
"label";
2277 } elseif ($sortfield ==
"date") {
2278 $sortfield =
"datea";
2282 $res = $link->fetchAll($links,
$object->element,
$object->id, $sortfield, $sortorder);
2283 $param .= (isset(
$object->id) && !preg_match(
'/&id='.
$object->id.
'/i', $param) ?
'&id='.$object->id :
'');
2285 $permissiontoedit = $permissiontodelete;
2287 print
'<!-- listOfLinks -->'.
"\n";
2289 $morehtmlright =
'';
2290 if (!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) {
2291 $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);
2295 print
load_fiche_titre($langs->trans(
"LinkedFiles"), $morehtmlright,
'link', 0,
'',
'table-list-of-links');
2297 if (!empty($moreoptions) && $moreoptions[
'afterlinktitle']) {
2298 print
'<div class="divlinkfile'.((!empty($moreoptions[
'showhideaddbutton']) &&
$conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afterlinktitle'].
'</div>';
2301 print
'<form action="'.$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
'').
'" id="'.$htmlname.
'" method="POST">';
2302 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2303 print
'<div class="div-table-responsive-no-min">';
2305 print
'<table class="liste noborder nobottom centpercent">';
2306 print
'<tr class="liste_titre">';
2308 $langs->trans(
"Links"),
2309 $_SERVER[
'PHP_SELF'],
2330 $langs->trans(
"Date"),
2331 $_SERVER[
'PHP_SELF'],
2342 $_SERVER[
'PHP_SELF'],
2354 $nboflinks = count($links);
2355 if ($nboflinks > 0) {
2356 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2358 foreach ($links as $key => $link) {
2359 print
'<tr class="oddeven">';
2361 if ($action ==
'update' && (
int) $selected === (
int) $link->id && $permissiontoedit) {
2363 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2364 print
'<input type="hidden" name="linkid" value="'.$link->id.
'">';
2365 print
'<input type="hidden" name="action" value="confirm_updateline">';
2366 print $langs->trans(
'Link').
': <input type="text" name="link" value="'.$link->url.
'">';
2369 print $langs->trans(
'Label').
': <input type="text" name="label" value="'.
dol_escape_htmltag($link->label).
'">';
2371 print
'<td class="center">'.dol_print_date(
dol_now(),
"dayhour",
"tzuser").
'</td>';
2372 print
'<td class="right">';
2373 print
'<label for="idshareenabled'.$key.
'">'.$langs->trans(
"LinkSharedViaALink").
'</label> ';
2374 print
'<input class="inline-block" type="checkbox" id="idshareenabled'.$key.
'" name="shareenabled"'.($link->share ?
' checked="checked"' :
'').
' /> ';
2376 print
'<td class="right">';
2377 print
'<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2378 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2383 print
'<a data-ajax="false" href="'.$link->url.
'" target="_blank" rel="noopener noreferrer">';
2387 print
'<td class="right"></td>';
2388 print
'<td class="center">'.dol_print_date($link->datea,
"dayhour",
"tzuser").
'</td>';
2389 print
'<td class="center">';
2392 $urlwithouturlroot = preg_replace(
'/' . preg_quote(DOL_URL_ROOT,
'/') .
'$/i',
'', trim(
$dolibarr_main_url_root));
2393 $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
2394 $fulllink = $urlwithroot.
'/document.php?type=link&hashp=' . $link->share;
2396 print
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
2397 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">';
2400 print
'<td class="right">';
2401 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=update&linkid='.$link->id.$param.
'&token='.
newToken().
'" class="editfilelink editfielda reposition" >'.
img_edit().
'</a>';
2402 if ($permissiontodelete) {
2403 print
' <a class="deletefilelink reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=deletelink&token='.
newToken().
'&linkid='.((int) $link->id).$param.
'">'.
img_delete().
'</a>';
2411 if ($nboflinks == 0) {
2412 print
'<tr class="oddeven"><td colspan="5">';
2413 print
'<span class="opacitymedium">'.$langs->trans(
"NoLinkFound").
'</span>';
2434 public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0, $param =
'')
2436 global $langs,
$conf;
2439 if ((
$conf->browser->layout !=
'phone' ||
getDolGlobalString(
'MAIN_SHOW_PREVIEW_PICTO_EVEN_ON_PHONE')) && !empty(
$conf->use_javascript_ajax)) {
2441 if (count($urladvancedpreview)) {
2442 $out .=
'<a class="pictopreview '.$urladvancedpreview[
'css'].
'" href="'.$urladvancedpreview[
'url'].
'"'.(empty($urladvancedpreview[
'mime']) ?
'' :
' mime="'.$urladvancedpreview[
'mime'].
'"').
' '.(empty($urladvancedpreview[
'target']) ?
'' :
' target="'.$urladvancedpreview[
'target'].
'"').
'>';
2444 if (empty($ruleforpicto)) {
2445 $out .=
img_picto(
'',
'search-plus',
'class="pictofixedwidth"');
2447 $out .=
img_mime($relativepath, $langs->trans(
'Preview').
' '.$file[
'name'],
'pictofixedwidth');
2451 if ($ruleforpicto < 0) {
2452 $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.
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.
dol_mimetype($file, $default='application/octet-stream', $mode=0)
Return MIME type of a file from its name with extension.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
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_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.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param='')
Return URL we can use for advanced preview links.
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_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.
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.
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.
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.
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
buildzip.php
getMaxFileSizeArray()
Return the max allowed for file upload.