67 $this->numoffiles = 0;
96 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)
99 global $conf, $langs, $hookmanager;
100 $hookmanager->initHooks(array(
'formfile'));
104 dol_syslog(__METHOD__.
": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
107 if (!empty($conf->browser->layout) && $conf->browser->layout !=
'classic') {
121 $out =
"\n".
'<!-- Start form attach new file --><div class="formattachnewfile">'.
"\n";
123 if ($nooutput != 2) {
125 $title = $langs->trans(
"AttachANewFile");
127 if ($title !=
'none') {
132 if (empty($usewithoutform)) {
134 $url .= (strpos($url,
'?') ===
false ?
'?' :
'&').
'uploadform=1';
136 $out .=
'<form name="'.$htmlname.
'" id="'.$htmlname.
'" action="'.$url.
'" enctype="multipart/form-data" method="POST">'.
"\n";
138 if (empty($usewithoutform) || $usewithoutform == 2) {
139 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
140 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_dir" name="section_dir" value="'.$sectiondir.
'">'.
"\n";
141 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_id" name="section_id" value="'.$sectionid.
'">'.
"\n";
142 $out .=
'<input type="hidden" name="sortfield" value="'.GETPOST(
'sortfield',
'aZ09comma').
'">'.
"\n";
143 $out .=
'<input type="hidden" name="sortorder" value="'.GETPOST(
'sortorder',
'aZ09comma').
'">'.
"\n";
144 $out .=
'<input type="hidden" name="page_y" value="">'.
"\n";
147 $out .=
'<table class="nobordernopadding centpercent">';
150 if (!empty($options)) {
151 $out .=
'<td>'.$options.
'</td>';
154 $out .=
'<td class="valignmiddle nowrap">';
157 $max = $maxfilesizearray[
'max'];
158 $maxmin = $maxfilesizearray[
'maxmin'];
159 $maxphptoshow = $maxfilesizearray[
'maxphptoshow'];
160 $maxphptoshowparam = $maxfilesizearray[
'maxphptoshowparam'];
162 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
164 $out .=
'<input class="flat minwidth400 maxwidth200onsmartphone" type="file"';
165 $out .= ((
getDolGlobalString(
'MAIN_DISABLE_MULTIPLE_FILEUPLOAD') || $disablemulti) ?
' name="userfile"' :
' name="userfile[]" multiple');
167 $out .= (!empty($accept) ?
' accept="'.$accept.
'"' :
' accept=""');
168 $out .= (!empty($capture) ?
' capture="capture"' :
'');
172 $langs->load(
'link');
173 $out .=
'<span class="nowraponsmartphone"><input style="margin-right: 2px;" type="checkbox" id="overwritefile" name="overwritefile" value="1">';
174 $out .=
'<label for="overwritefile" class="opacitylow paddingright">'.$langs->trans(
"OverwriteIfExists").
'</label>';
177 $out .=
'<input type="submit" class="button small reposition" name="sendit" value="'.$langs->trans(
"Upload").
'"';
183 $out .=
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
188 $menudolibarrsetupmax = $langs->transnoentitiesnoconv(
"Home").
' - '.$langs->transnoentitiesnoconv(
"Setup").
' - '.$langs->transnoentitiesnoconv(
"Security");
189 $langs->load(
'other');
191 $out .=
info_admin($langs->trans(
"ThisLimitIsDefinedInSetupAt", $menudolibarrsetupmax, $max, $maxphptoshowparam, $maxphptoshow), 1, 0,
'1',
'classfortooltip');
194 $out .=
' ('.$langs->trans(
"UploadDisabled").
')';
196 $out .=
"</td></tr>";
198 if ($savingdocmask) {
200 $rename = (!
getDolGlobalString(
'MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT') ?
'checked' :
'');
203 if (!empty($options)) {
204 $out .=
'<td>'.$options.
'</td>';
206 $out .=
'<td valign="middle" class="nowrap">';
207 $out .=
'<input type="checkbox" '.$rename.
' class="savingdocmask" name="savingdocmask" id="savingdocmask" value="'.
dol_escape_js($savingdocmask).
'"> ';
208 $out .=
'<label class="opacitymedium small" for="savingdocmask">';
209 $out .= $langs->trans(
"SaveUploadedFileWithMask", preg_replace(
'/__file__/', $langs->transnoentitiesnoconv(
"OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv(
"OriginFileName"));
217 if (empty($usewithoutform)) {
219 if (empty($sectionid)) {
224 $parameters = array(
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url' => $url,
'perm' => $perm,
'options' => $options);
225 $res = $hookmanager->executeHooks(
'formattachOptionsUpload', $parameters,
$object);
227 $out =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').
'attacharea'.$htmlname)).
'">'.$out.
'</div>';
229 $out .= $hookmanager->resPrint;
231 $out .=
"\n</div><!-- End form class=formattachnewfile -->\n";
238 $out2 .=
"\n".
'<!-- Start form link new url --><div class="formlinknewurl">'.
"\n";
239 $langs->load(
'link');
241 if ($nooutput != 2) {
242 $title = $langs->trans(
"LinkANewFile");
246 if (empty($usewithoutform)) {
247 $out2 .=
'<form name="'.$htmlname.
'_link" id="'.$htmlname.
'_link" action="'.$url.
'" method="POST">'.
"\n";
248 $out2 .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
249 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_dir" name="link_section_dir" value="">'.
"\n";
250 $out2 .=
'<input type="hidden" id="'.$htmlname.
'_link_section_id" name="link_section_id" value="'.$sectionid.
'">'.
"\n";
251 $out2 .=
'<input type="hidden" name="page_y" value="">'.
"\n";
254 $out2 .=
'<div class="valignmiddle">';
255 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
257 $out2 .=
'<label for="link">'.$langs->trans(
"URLToLink").
':</label> ';
259 $out2 .=
'<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans(
"URLToLink")).
'">';
261 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
263 $out2 .=
'<label for="label">'.$langs->trans(
"Label").
':</label> ';
265 $out2 .=
'<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans(
"Label")).
'">';
266 $out2 .=
'<input type="hidden" name="objecttype" value="'.$object->element.
'">';
267 $out2 .=
'<input type="hidden" name="objectid" value="'.$object->id.
'">';
269 $out2 .=
'<div class="inline-block" style="padding-right: 10px;">';
270 $out2 .=
'<input type="submit" class="button small reposition" name="linkit" value="'.$langs->trans(
"ToLink").
'"';
275 if (empty($usewithoutform)) {
276 $out2 .=
'<div class="clearboth"></div>';
277 $out2 .=
'</form><br>';
280 $parameters = array(
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url' => $url,
'perm' => $perm,
'options' => $options);
281 $res = $hookmanager->executeHooks(
'formattachOptions', $parameters,
$object);
283 $out2 =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' : (($nooutput == 2 ?
'' :
'attacharea ').$htmlname)).
'">'.$out2.
'</div>';
285 $out2 .= $hookmanager->resPrint;
287 $out2 .=
"\n</div><!-- End form class=formlinknewurl -->\n";
291 if ($nooutput == 2) {
292 return array(
'formToUploadAFile' => $out,
'formToAddALink' => $out2);
293 } elseif ($nooutput) {
324 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 =
'')
327 $this->numoffiles = 0;
328 print $this->
showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
329 return $this->numoffiles;
359 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 =
'')
361 global $dolibarr_main_url_root;
364 if (!empty($iconPDF)) {
365 dol_syslog(__METHOD__.
": passing iconPDF parameter is deprecated", LOG_WARNING);
368 global $langs, $conf, $user, $hookmanager;
372 if (is_object($hookmanager)) {
374 'modulepart' => &$modulepart,
375 'modulesubdir' => &$modulesubdir,
376 'filedir' => &$filedir,
377 'urlsource' => &$urlsource,
378 'genallowed' => &$genallowed,
379 'delallowed' => &$delallowed,
380 'modelselected' => &$modelselected,
381 'allowgenifempty' => &$allowgenifempty,
382 'forcenomultilang' => &$forcenomultilang,
383 'noform' => &$noform,
386 'buttonlabel' => &$buttonlabel,
387 'codelang' => &$codelang,
388 'morepicto' => &$morepicto,
389 'hideifempty' => &$hideifempty,
390 'removeaction' => &$removeaction
392 $reshook = $hookmanager->executeHooks(
'showDocuments', $parameters,
$object);
400 return $hookmanager->resPrint;
403 if (!is_object($form)) {
404 $form =
new Form($this->db);
407 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
410 if (!empty($iconPDF)) {
415 if (!preg_match(
'/entity\=[0-9]+/', $param)) {
416 $param .= ($param ?
'&' :
'').
'entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity);
421 if (in_array($modulepart, array(
'contract',
'facture',
'supplier_proposal',
'propal',
'proposal',
'order',
'commande',
'expedition',
'commande_fournisseur',
'expensereport',
'delivery',
'ticket'))) {
422 $printer = ($user->hasRight(
'printing',
'read') && !empty($conf->printing->enabled));
425 $hookmanager->initHooks(array(
'formfile'));
428 $file_list = array();
429 if (!empty($filedir)) {
430 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
432 if ($hideifempty && empty($file_list)) {
437 $forname =
'builddoc';
442 $out .=
"\n".
'<!-- Start show_document -->'.
"\n";
445 if (preg_match(
'/massfilesarea_/', $modulepart)) {
446 $out .=
'<div id="show_files"><br></div>'.
"\n";
447 $title = $langs->trans(
"MassFilesArea").
' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans(
"Hide").
')</a>';
448 $title .=
'<script nonce="'.getNonce().
'">
449 jQuery(document).ready(function() {
450 jQuery(\'#togglemassfilesarea\').click(function() {
451 if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown")
453 jQuery(\'#'.$modulepart.
'_table\').hide();
454 jQuery(\'#togglemassfilesarea\').attr("ref", "hidden");
455 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Show")).
')");
459 jQuery(\'#'.$modulepart.
'_table\').show();
460 jQuery(\'#togglemassfilesarea\').attr("ref","shown");
461 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Hide")).
')");
469 $titletoshow = $langs->trans(
"Documents");
470 if (!empty($title)) {
471 $titletoshow = ($title ==
'none' ?
'' : $title);
474 $submodulepart = $modulepart;
477 $tmp = explode(
':', $modulepart);
478 if (!empty($tmp[1])) {
479 $modulepart = $tmp[0];
480 $submodulepart = $tmp[1];
483 $addcolumforpicto = ($delallowed || $printer || $morepicto);
484 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
489 $modellist = array();
491 if ($modulepart ==
'company') {
493 if (is_array($genallowed)) {
494 $modellist = $genallowed;
496 include_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
499 } elseif ($modulepart ==
'propal') {
500 if (is_array($genallowed)) {
501 $modellist = $genallowed;
503 include_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
506 } elseif ($modulepart ==
'supplier_proposal') {
507 if (is_array($genallowed)) {
508 $modellist = $genallowed;
510 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
513 } elseif ($modulepart ==
'commande') {
514 if (is_array($genallowed)) {
515 $modellist = $genallowed;
517 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
520 } elseif ($modulepart ==
'expedition') {
521 if (is_array($genallowed)) {
522 $modellist = $genallowed;
524 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
527 } elseif ($modulepart ==
'reception') {
528 if (is_array($genallowed)) {
529 $modellist = $genallowed;
531 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
534 } elseif ($modulepart ==
'delivery') {
535 if (is_array($genallowed)) {
536 $modellist = $genallowed;
538 include_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
541 } elseif ($modulepart ==
'ficheinter') {
542 if (is_array($genallowed)) {
543 $modellist = $genallowed;
545 include_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
548 } elseif ($modulepart ==
'facture') {
549 if (is_array($genallowed)) {
550 $modellist = $genallowed;
552 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
555 } elseif ($modulepart ==
'contract') {
557 if (is_array($genallowed)) {
558 $modellist = $genallowed;
560 include_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
563 } elseif ($modulepart ==
'project') {
564 if (is_array($genallowed)) {
565 $modellist = $genallowed;
567 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
570 } elseif ($modulepart ==
'project_task') {
571 if (is_array($genallowed)) {
572 $modellist = $genallowed;
574 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
577 } elseif ($modulepart ==
'product') {
578 if (is_array($genallowed)) {
579 $modellist = $genallowed;
581 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
584 } elseif ($modulepart ==
'product_batch') {
585 if (is_array($genallowed)) {
586 $modellist = $genallowed;
588 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product_batch/modules_product_batch.class.php';
591 } elseif ($modulepart ==
'stock') {
592 if (is_array($genallowed)) {
593 $modellist = $genallowed;
595 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_stock.php';
598 } elseif ($modulepart ==
'hrm') {
599 if (is_array($genallowed)) {
600 $modellist = $genallowed;
602 include_once DOL_DOCUMENT_ROOT.
'/core/modules/hrm/modules_evaluation.php';
605 } elseif ($modulepart ==
'movement') {
606 if (is_array($genallowed)) {
607 $modellist = $genallowed;
609 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_movement.php';
612 } elseif ($modulepart ==
'export') {
613 if (is_array($genallowed)) {
614 $modellist = $genallowed;
616 include_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
618 $modellist = array();
620 } elseif ($modulepart ==
'commande_fournisseur' || $modulepart ==
'supplier_order') {
621 if (is_array($genallowed)) {
622 $modellist = $genallowed;
624 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
627 } elseif ($modulepart ==
'facture_fournisseur' || $modulepart ==
'supplier_invoice') {
629 if (is_array($genallowed)) {
630 $modellist = $genallowed;
632 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
635 } elseif ($modulepart ==
'supplier_payment') {
636 if (is_array($genallowed)) {
637 $modellist = $genallowed;
639 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
642 } elseif ($modulepart ==
'remisecheque') {
643 if (is_array($genallowed)) {
644 $modellist = $genallowed;
646 include_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
649 } elseif ($modulepart ==
'donation') {
650 if (is_array($genallowed)) {
651 $modellist = $genallowed;
653 include_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
656 } elseif ($modulepart ==
'member') {
657 if (is_array($genallowed)) {
658 $modellist = $genallowed;
660 include_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
663 } elseif ($modulepart ==
'agenda' || $modulepart ==
'actions') {
664 if (is_array($genallowed)) {
665 $modellist = $genallowed;
667 include_once DOL_DOCUMENT_ROOT.
'/core/modules/action/modules_action.php';
670 } elseif ($modulepart ==
'expensereport') {
671 if (is_array($genallowed)) {
672 $modellist = $genallowed;
674 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
677 } elseif ($modulepart ==
'unpaid') {
679 } elseif ($modulepart ==
'user') {
680 if (is_array($genallowed)) {
681 $modellist = $genallowed;
683 include_once DOL_DOCUMENT_ROOT.
'/core/modules/user/modules_user.class.php';
686 } elseif ($modulepart ==
'usergroup') {
687 if (is_array($genallowed)) {
688 $modellist = $genallowed;
690 include_once DOL_DOCUMENT_ROOT.
'/core/modules/usergroup/modules_usergroup.class.php';
695 $file =
dol_buildpath(
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
696 if (file_exists($file)) {
697 $res = include_once $file;
700 $file =
dol_buildpath(
'/'.$modulepart.
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
701 $res = include_once $file;
704 $class =
'ModelePDF'.ucfirst($submodulepart);
706 if (class_exists($class)) {
707 $modellist = call_user_func($class.
'::liste_modeles', $this->db);
709 dol_print_error($this->db,
"Bad value for modulepart '".$modulepart.
"' in showdocuments (class ".$class.
" for Doc generation not found)");
717 if (empty($buttonlabel)) {
718 $buttonlabel = $langs->trans(
'Generate');
721 if ($conf->browser->layout ==
'phone') {
722 $urlsource .=
'#'.$forname.
'_form';
724 if (empty($noform)) {
725 $out .=
'<form action="'.$urlsource.
'" id="'.$forname.
'_form" method="post">';
727 $out .=
'<input type="hidden" name="action" value="builddoc">';
728 $out .=
'<input type="hidden" name="page_y" value="">';
729 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
732 $out .=
'<div class="div-table-responsive-no-min">';
733 $out .=
'<table class="liste formdoc noborder centpercent">';
735 $out .=
'<tr class="liste_titre">';
736 $addcolumforpicto = ($delallowed || $printer || $morepicto);
737 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
740 $out .=
'<th colspan="'.$colspan.
'" class="formdoc liste_titre maxwidthonsmartphone center">';
743 if (!empty($modellist)) {
745 $out .=
'<span class="hideonsmartphone">'.$langs->trans(
'Model').
' </span>';
746 if (is_array($modellist) && count($modellist) == 1) {
747 $arraykeys = array_keys($modellist);
748 $modelselected = $arraykeys[0];
750 $morecss =
'minwidth75 maxwidth200';
751 if ($conf->browser->layout ==
'phone') {
752 $morecss =
'maxwidth100';
754 $out .= $form->selectarray(
'model', $modellist, $modelselected, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss, 1,
'', 0, 0);
788 if ($conf->use_javascript_ajax) {
791 $out .= $form->textwithpicto(
'', $tooltipontemplatecombo, 1,
'help',
'marginrightonly', 0, 3,
'', 0);
793 $out .=
'<div class="float">'.$langs->trans(
"Files").
'</div>';
797 if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) &&
getDolGlobalInt(
'MAIN_MULTILANGS') && !$forcenomultilang && (!empty($modellist) || $showempty)) {
798 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
800 $defaultlang = ($codelang && $codelang !=
'auto') ? $codelang : $langs->getDefaultLang();
801 $morecss =
'maxwidth150';
802 if ($conf->browser->layout ==
'phone') {
803 $morecss =
'maxwidth100';
805 $out .= $formadmin->select_language($defaultlang,
'lang_id', 0, array(), 0, 0, 0, $morecss);
811 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
812 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
813 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
814 $genbutton .=
' disabled';
817 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
818 $langs->load(
"errors");
819 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
821 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
824 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
830 if (!empty($hookmanager->hooks[
'formfile'])) {
831 foreach ($hookmanager->hooks[
'formfile'] as $module) {
832 if (method_exists($module,
'formBuilddocLineOptions')) {
841 $parameters = array(
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart);
842 if (is_object($hookmanager)) {
843 $reshook = $hookmanager->executeHooks(
'formBuilddocOptions', $parameters, $GLOBALS[
'object']);
844 $out .= $hookmanager->resPrint;
849 if (!empty($filedir)) {
850 $link_list = array();
852 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
853 $link =
new Link($this->db);
854 $sortfield = $sortorder =
'';
855 $res = $link->fetchAll($link_list,
$object->element,
$object->id, $sortfield, $sortorder);
858 $out .=
'<!-- html.formfile::showdocuments -->'.
"\n";
861 if ((!empty($file_list) || !empty($link_list) || preg_match(
'/^massfilesarea/', $modulepart))
864 $out .=
'<div class="titre">'.$titletoshow.
'</div>'.
"\n";
865 $out .=
'<div class="div-table-responsive-no-min">';
866 $out .=
'<table class="noborder centpercent" id="'.$modulepart.
'_table">'.
"\n";
870 if (is_array($file_list)) {
871 '@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';
875 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
876 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
884 if (!empty($sortfield) && !empty($sortorder)) {
890 foreach ($file_list as $file) {
894 $relativepath = (string) $file[
"name"];
896 $relativepath = (string) $modulesubdir.
"/".$file[
"name"];
898 if ($modulepart ==
'export') {
899 $relativepath = (string) $file[
"name"];
902 $out .=
'<tr class="oddeven'.((!$genallowed && $i == 1) ?
' trfirstline' :
'').
'">';
904 $documenturl = DOL_URL_ROOT.
'/document.php';
905 if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
910 $imgpreview = $this->
showPreview($file, $modulepart, $relativepath, 0, $param);
912 $out .=
'<td class="minwidth200 tdoverflowmax300">';
914 $out .=
'<span class="spanoverflow widthcentpercentminusx valignmiddle">';
916 $out .=
'<span class="spanoverflow">';
918 $out .=
'<a class="documentdownload paddingright" ';
920 $out .=
'target="_blank" ';
922 $out .=
'href="'.$documenturl.
'?modulepart='.$modulepart.
'&file='.urlencode($relativepath).($param ?
'&'.$param :
'').
'"';
925 if (preg_match(
'/text/', $mime)) {
926 $out .=
' target="_blank" rel="noopener noreferrer"';
928 $out .=
' title="'.dol_escape_htmltag($file[
"name"]).
'"';
930 $out .=
img_mime($file[
"name"], $langs->trans(
"File").
': '.$file[
"name"]);
933 $out .=
'</span>'.
"\n";
938 $size = (!empty($file[
'size']) ? $file[
'size'] :
dol_filesize($filedir.
"/".$file[
"name"]));
939 $out .=
'<td class="nowraponall right" title="'.dolPrintHTML($size.
' '.$langs->trans(
"Bytes")).
'">'.
dol_print_size($size, 1, 1).
'</td>';
942 $date = (!empty($file[
'date']) ? $file[
'date'] :
dol_filemtime($filedir.
"/".$file[
"name"]));
943 $out .=
'<td class="nowrap right">'.dol_print_date($date,
'dayhour',
'tzuser').
'</td>';
946 $out .=
'<td class="nowraponall">';
947 if (!empty($file[
'share'])) {
949 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
950 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
956 if (!empty($file[
'share'])) {
957 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
959 if ($forcedownload) {
960 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
963 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
965 $out .=
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
966 $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).
'">';
974 if ($delallowed || $printer || $morepicto) {
975 $out .=
'<td class="right nowraponall">';
977 $tmpurlsource = preg_replace(
'/#[a-zA-Z0-9_]*$/',
'', $urlsource);
978 $out .=
'<a class="reposition" href="'.$tmpurlsource.((strpos($tmpurlsource,
'?') ===
false) ?
'?' :
'&').
'action='.urlencode($removeaction).
'&token='.
newToken().
'&file='.urlencode($relativepath);
979 $out .= ($param ?
'&'.$param :
'');
982 $out .=
'">'.img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
985 $out .=
'<a class="marginleftonly reposition" href="'.$urlsource.(strpos($urlsource,
'?') ?
'&' :
'?').
'action=print_file&token='.
newToken().
'&printer='.urlencode($modulepart).
'&file='.urlencode($relativepath);
986 $out .= ($param ?
'&'.$param :
'');
987 $out .=
'">'.img_picto($langs->trans(
"PrintFile", $relativepath),
'printer.png').
'</a>';
990 $morepicto = preg_replace(
'/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto);
996 if (is_object($hookmanager)) {
997 $addcolumforpicto = ($delallowed || $printer || $morepicto);
998 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
1000 $parameters = array(
'colspan' => ($colspan + $colspanmore),
'socid' => (isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id' => (isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart' => $modulepart,
'relativepath' => $relativepath);
1001 $res = $hookmanager->executeHooks(
'formBuilddocLineOptions', $parameters, $file);
1003 $out .= $hookmanager->resPrint;
1006 $out = $hookmanager->resPrint;
1011 $this->numoffiles++;
1014 if (is_array($link_list)) {
1017 foreach ($link_list as $file) {
1018 $out .=
'<tr class="oddeven">';
1019 $out .=
'<td colspan="'.$colspan.
'" class="maxwidhtonsmartphone">';
1020 $out .=
'<a data-ajax="false" href="'.$file->url.
'" target="_blank" rel="noopener noreferrer">';
1021 $out .= $file->label;
1024 $out .=
'<td class="right">';
1028 $out .=
'<td></td>';
1029 if ($delallowed || $printer || $morepicto) {
1030 $out .=
'<td></td>';
1032 $out .=
'</tr>'.
"\n";
1034 $this->numoffiles++;
1037 if (count($file_list) == 0 && count($link_list) == 0 && $headershown) {
1038 $out .=
'<tr><td colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>'.
"\n";
1044 $out .=
"</table>\n";
1047 if (empty($noform)) {
1048 $out .=
'</form>'.
"\n";
1052 $out .=
'<!-- End show_document -->'.
"\n";
1055 jQuery(document).ready(function() {
1056 var selectedValue = $(".selectformat").val();
1058 if (selectedValue === "excel2007" || selectedValue === "tsv") {
1059 $(".forhide").prop("disabled", true).hide();
1061 $(".forhide").prop("disabled", false).show();
1082 public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
'', $morecss =
'valignmiddle', $allfiles = 0)
1084 global $conf, $langs;
1086 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1089 $this->infofiles = array(
'nboffiles' => 0,
'extensions' => array(),
'files' => array());
1094 if (isModEnabled(
'multicompany')) {
1096 preg_match(
'/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,
'/').
'$/', $filedir, $regs);
1097 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
1102 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/');
1104 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/').
'\.';
1106 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
1110 $out .=
'<!-- html.formfile::getDocumentsLink -->'.
"\n";
1111 if (!empty($file_list)) {
1112 $out =
'<dl class="dropdown inline-block">
1113 <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto(
'',
'listlight',
'', 0, 0, 0,
'', $morecss).
'</a></dt>
1114 <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
1120 foreach ($file_list as $file) {
1122 if ($filter && !preg_match(
'/'.$filter.
'/i', $file[
"name"])) {
1128 $relativepath = $file[
"name"];
1129 if ($modulesubdir) {
1130 $relativepath = (string) $modulesubdir.
"/".$file[
"name"];
1133 if ($modulepart ==
'donation') {
1134 $relativepath = (string)
get_exdir($modulesubdir, 2, 0, 0,
null,
'donation').$file[
"name"];
1136 if ($modulepart ==
'export') {
1137 $relativepath = (string) $file[
"name"];
1140 $this->infofiles[
'nboffiles']++;
1141 $this->infofiles[
'files'][] = $file[
'fullname'];
1142 $ext = (string) pathinfo($file[
'name'], PATHINFO_EXTENSION);
1143 if (!array_key_exists($ext, $this->infofiles[
'extensions'])) {
1144 $this->infofiles[
'extensions'][$ext] = 1;
1146 $this->infofiles[
'extensions'][$ext]++;
1150 if (!empty($conf->use_javascript_ajax) && ($conf->browser->layout !=
'phone')) {
1152 if ($tmparray && $tmparray[
'url']) {
1153 $tmpout .=
'<li><a href="'.$tmparray[
'url'].
'"'.($tmparray[
'css'] ?
' class="'.$tmparray[
'css'].
'"' :
'').($tmparray[
'mime'] ?
' mime="'.$tmparray[
'mime'].
'"' :
'').($tmparray[
'target'] ?
' target="'.$tmparray[
'target'].
'"' :
'').
'>';
1155 $tmpout .=
'<i class="fa fa-search-plus paddingright" style="color: gray"></i>';
1156 $tmpout .= $langs->trans(
"Preview").
' '.$ext.
'</a></li>';
1161 $tmpout .=
'<li class="nowrap"><a class="pictopreview nowrap" ';
1163 $tmpout .=
'target="_blank" ';
1165 $tmpout .=
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($relativepath).
'"';
1167 if (preg_match(
'/text/', $mime)) {
1168 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
1171 $tmpout .=
img_mime($relativepath, $file[
"name"]);
1172 $tmpout .= $langs->trans(
"Download").
' '.$ext;
1173 $tmpout .=
'</a></li>'.
"\n";
1176 $out .=
'</ul></div></dd>
1225 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())
1228 global $user, $conf, $langs, $hookmanager, $form;
1229 global $sortfield, $sortorder;
1230 global $dolibarr_main_url_root;
1232 if ($disablecrop == -1) {
1235 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'))) {
1241 if (empty($relativepath)) {
1243 if (!empty(
$object->element) &&
$object->element ==
'invoice_supplier') {
1246 if (!empty(
$object->element) &&
$object->element ==
'project_task') {
1247 $relativepath =
'Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1251 if (
getDolGlobalInt(
'PRODUCT_USE_OLD_PATH_FOR_PHOTO') && isset($filearray[0]) && $filearray[0][
'level1name'] ==
'photos') {
1252 $relativepath = preg_replace(
'/^.*\/produit\//',
'', $filearray[0][
'path']).
'/';
1258 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $upload_dir);
1259 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1265 $hookmanager->initHooks(array(
'formfile'));
1266 $parameters = array(
1267 'filearray' => $filearray,
1268 'modulepart' => $modulepart,
1270 'forcedownload' => $forcedownload,
1271 'relativepath' => $relativepath,
1272 'relativedir' => $relativedir,
1273 'permtodelete' => $permonobject,
1274 'useinecm' => $useinecm,
1275 'textifempty' => $textifempty,
1276 'maxlength' => $maxlength,
1280 $reshook = $hookmanager->executeHooks(
'showFilesList', $parameters,
$object);
1282 if (!empty($reshook)) {
1285 if (!is_object($form)) {
1286 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1287 $form =
new Form($this->db);
1290 if (!preg_match(
'/&id=/', $param) && isset(
$object->id)) {
1291 $param .=
'&id='.$object->id;
1293 $relativepathwihtoutslashend = preg_replace(
'/\/$/',
'', $relativepath);
1294 if ($relativepathwihtoutslashend) {
1295 $param .=
'&file='.urlencode($relativepathwihtoutslashend);
1298 if ($permtoeditline < 0) {
1299 $permtoeditline = 0;
1300 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1302 $permtoeditline = 1;
1305 $permtoeditline = 1;
1310 $permtoeditline = 0;
1314 $url = $_SERVER[
"PHP_SELF"];
1319 $morehtmlright =
'';
1320 if (!empty($moreoptions[
'showhideaddbutton']) && $conf->use_javascript_ajax) {
1321 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
'javascript:console.log("open add file form");jQuery(".divattachnewfile").toggle(); if (!jQuery(".divattachnewfile").is(":hidden")) { jQuery("input[type=\'file\']").click(); }',
'', $permtoeditline);
1324 if ((empty($useinecm) || $useinecm == 3 || $useinecm == 6) && $title !=
'none') {
1325 print
load_fiche_titre($title ? $title : $langs->trans(
"AttachedFiles"), $morehtmlright,
'file-upload', 0,
'',
'table-list-of-attached-files');
1327 if (!empty($moreoptions) && $moreoptions[
'afteruploadtitle']) {
1328 print
'<div class="divattachnewfile'.((!empty($moreoptions[
'showhideaddbutton']) && $conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afteruploadtitle'].
'</div>';
1332 print
'<!-- html.formfile::list_of_documents -->'.
"\n";
1333 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1334 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?'.$param.
'" method="POST">';
1335 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1336 print
'<input type="hidden" name="action" value="renamefile">';
1337 print
'<input type="hidden" name="id" value="'.(is_object(
$object) ?
$object->id :
'').
'">';
1338 print
'<input type="hidden" name="modulepart" value="'.$modulepart.
'">';
1341 print
'<div class="div-table-responsive-no-min"'.($moreattrondiv ?
' '.$moreattrondiv :
'').
'>';
1342 print
'<table id="tablelines" class="centpercent liste noborder nobottom">'.
"\n";
1344 if (!empty($addfilterfields)) {
1345 print
'<tr class="liste_titre nodrag nodrop">';
1346 print
'<td><input type="search_doc_ref" value="'.dol_escape_htmltag(
GETPOST(
'search_doc_ref',
'alpha')).
'"></td>';
1349 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1354 if (empty($disablemove) && count($filearray) > 1) {
1365 if ($sortfield && $sortorder) {
1370 print
'<tr class="liste_titre nodrag nodrop">';
1375 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1382 if (empty($disablemove) && count($filearray) > 1) {
1387 $nboffiles = count($filearray);
1388 if ($nboffiles > 0) {
1389 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1395 $parametersByDefault = array(
1396 'modulepart' => $modulepart,
1397 'relativepath' => $relativepath,
1398 'permtoedit' => $permtoeditline,
1399 'permonobject' => $permonobject,
1401 foreach ($filearray as $key => $file) {
1402 if ($file[
'name'] !=
'.' && $file[
'name'] !=
'..' && !preg_match(
'/\.meta$/i', $file[
'name'])) {
1403 if (array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) {
1404 $lastrowid = $filearray[$key][
'rowid'];
1409 $modulepart = ($file[
'modulepart'] ?? $parametersByDefault[
'modulepart']);
1410 $relativepath = ($file[
'relativepath'] ?? $parametersByDefault[
'relativepath']);
1411 $permtoeditline = ($file[
'permtoedit'] ?? $parametersByDefault[
'permtoedit']);
1412 $permonobject = ($file[
'permonobject'] ?? $parametersByDefault[
'permonobject']);
1415 if (empty($relativepath) || empty($modulepart)) {
1416 $filepath = $file[
'level1name'].
'/'.$file[
'name'];
1418 $filepath = $relativepath.$file[
'name'];
1420 if (empty($modulepart)) {
1421 $modulepart = basename(dirname($file[
'path']));
1423 if (empty($relativepath)) {
1424 $relativepath = preg_replace(
'/\/(.+)/',
'', $filepath) .
'/';
1429 print
'<!-- Line list_of_documents '.$key.
' relativepath = '.$relativepath.
' -->'.
"\n";
1432 print
'<!-- In database: position='.(array_key_exists(
'position', $filearray[$key]) ? $filearray[$key][
'position'] : 0).
' -->'.
"\n";
1433 print
'<tr class="oddeven" id="row-'.((array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) ? $filearray[$key][
'rowid'] :
'AFTER'.$lastrowid.
'POS'.($i + 1)).
'">';
1437 print
'<td class="minwidth200 tdoverflowmax500" title="'.dolPrintHTMLForAttribute($file[
'name']).
'">';
1441 print
'<a class="paddingright valignmiddle" ';
1443 print
'target="_blank" ';
1445 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart;
1446 if ($forcedownload) {
1447 print
'&attachment=1';
1449 if (!empty(
$object->entity)) {
1450 print
'&entity='.$object->entity;
1452 print
'&file='.urlencode($filepath);
1454 print
img_mime($file[
'name'], $file[
'name'].
' ('.
dol_print_size($file[
'size'], 0, 0).
')',
'inline-block valignmiddle paddingright');
1455 if ($showrelpart == 1) {
1456 print $relativepath;
1462 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $file[
'name'] == basename(
GETPOST(
'urlfile',
'alpha')) && dirname($filepath) == dirname(
GETPOST(
'urlfile',
'alpha'))) {
1464 $section_dir = dirname(
GETPOST(
'urlfile',
'alpha'));
1465 if (!preg_match(
'/\/$/', $section_dir)) {
1466 $section_dir .=
'/';
1468 print
'<input type="hidden" name="section_dir" value="'.$section_dir.
'">';
1469 print
'<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file[
'name']).
'">';
1470 print
'<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file[
'name']).
'">';
1473 $filenametoshow = preg_replace(
'/\.noexe$/',
'', $file[
'name']);
1479 print $this->
showPreview($file, $modulepart, $filepath, 0,
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity));
1487 print
'<td class="right nowraponall">';
1488 if ($sizetoshow == $sizetoshowbytes) {
1491 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1496 print
'<td class="center nowraponall">'.dol_print_date($file[
'date'],
"dayhour",
"tzuser").
'</td>';
1499 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1500 $fileinfo = pathinfo($file[
'name']);
1501 print
'<td class="center">';
1503 if ($useinecm == 5 || $useinecm == 6) {
1517 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity));
1518 if (empty($urlforhref)) {
1519 $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']));
1520 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
1522 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
1524 print
'<img class="photo maxwidth200 shadow valignmiddle"';
1525 if ($useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1526 print
' height="20"';
1529 print
' style="max-height: 24px"';
1531 print
' src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.urlencode($modulepart).
'&entity='.(empty(
$object->entity) ? $conf->entity :
$object->entity).
'&file='.urlencode($relativepath.$smallfile);
1532 if (!empty($filearray[$key][
'date'])) {
1533 print
'&cache='.urlencode((
string) $filearray[$key][
'date']);
1535 print
'" title="">';
1542 print
'<td class="center">';
1543 if ($relativedir && $filearray[$key][
'rowid'] > 0) {
1545 print
'<label for="idshareenabled'.$key.
'">'.$langs->trans(
"FileSharedViaALink").
'</label> ';
1546 print
'<input class="inline-block" type="checkbox" id="idshareenabled'.$key.
'" name="shareenabled"'.($file[
'share'] ?
' checked="checked"' :
'').
' /> ';
1548 if ($file[
'share']) {
1550 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1551 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1557 if (!empty($file[
'share'])) {
1558 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
1560 if ($forcedownload) {
1561 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1564 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1566 print
'<a href="'.$fulllink.
'" target="_blank" rel="noopener">'.
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
'</a> ';
1567 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).
'">';
1579 print
'<td class="valignmiddle right actionbuttons nowraponall"><!-- action on files -->';
1580 if ($useinecm == 1 || $useinecm == 5) {
1582 $newparam = preg_replace(
'/&file=.*$/',
'', $param);
1583 $backtopage = DOL_URL_ROOT.
'/ecm/index.php?§ion_dir='.urlencode($relativepath).$newparam;
1584 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>';
1587 if (empty($useinecm) || $useinecm == 2 || $useinecm == 3 || $useinecm == 6) {
1588 $newmodulepart = $modulepart;
1589 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1590 $newmodulepart =
'produit|service';
1593 if ($permtoeditline) {
1594 $moreparaminurl =
'';
1596 $moreparaminurl .=
'&id='.$object->id;
1597 } elseif (
GETPOST(
'website',
'alpha')) {
1598 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1601 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1602 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1605 if (!preg_match(
'/\.webp$/i', $file[
'name'])) {
1606 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1607 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>';
1608 } elseif ($modulepart ==
'medias' &&
GETPOST(
'website')) {
1609 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>';
1615 if ($permtoeditline) {
1617 $moreparaminurl =
'';
1619 $moreparaminurl .=
'&id='.$object->id;
1620 } elseif (
GETPOST(
'website',
'alpha')) {
1621 $moreparaminurl .=
'&website='.GETPOST(
'website',
'alpha');
1624 if ($modulepart ==
'medias' && !
GETPOST(
'website')) {
1625 $moreparaminurl .=
'&backtourl='.urlencode(DOL_URL_ROOT.
'/ecm/index_medias.php?file_manager=1&modulepart='.$modulepart.
'§ion_dir='.$relativepath);
1628 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>';
1632 if ($permtoeditline) {
1633 $paramsectiondir = (in_array($modulepart, array(
'medias',
'ecm')) ?
'§ion_dir='.urlencode($relativepath) :
'');
1634 print
'<a class="editfielda reposition editfilelink" href="'.(($useinecm == 1 || $useinecm == 5) ?
'#' : ($url.
'?action=editfile&token='.
newToken().
'&urlfile='.urlencode($filepath).$paramsectiondir.$param)).
'" rel="'.$filepath.
'">'.
img_edit(
'default', 0,
'class="paddingrightonly"').
'</a>';
1638 if ($permonobject) {
1640 if (!empty($conf->dol_use_jmobile)) {
1643 if (empty($conf->use_javascript_ajax)) {
1649 print
'<a href="'.((($useinecm && $useinecm != 3 && $useinecm != 6) && $useajax) ?
'#' : ($url.
'?action=deletefile&token='.
newToken().
'&urlfile='.urlencode($filepath).$param)).
'" class="reposition deletefilelink" rel="'.$filepath.
'">'.
img_delete().
'</a>';
1653 if (empty($disablemove) && count($filearray) > 1) {
1654 if ($nboffiles > 1 && $conf->browser->layout !=
'phone') {
1655 print
'<td class="linecolmove tdlineupdown center">';
1657 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=up&rowid='.
$object->id.
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
1659 if ($i < ($nboffiles - 1)) {
1660 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=down&rowid='.
$object->id.
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
1664 print
'<td'.(($conf->browser->layout !=
'phone') ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'>';
1669 print
'<td class="right">';
1670 print
'<input type="hidden" name="ecmfileid" value="'.(empty($filearray[$key][
'rowid']) ?
'' : $filearray[$key][
'rowid']).
'">';
1671 print
'<input type="submit" class="button button-save smallpaddingimp" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
1672 print
'<input type="submit" class="button button-cancel smallpaddingimp" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
1674 if (empty($disablemove) && count($filearray) > 1) {
1675 print
'<td class="right"></td>';
1683 if ($nboffiles == 0) {
1685 if (empty($disablemove) && count($filearray) > 1) {
1688 print
'<tr class="oddeven"><td colspan="'.$colspan.
'">';
1689 if (empty($textifempty)) {
1690 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
1692 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
1700 if ($nboflines > 1 && is_object(
$object)) {
1701 if (!empty($conf->use_javascript_ajax) && $permtoeditline) {
1702 $table_element_line =
'ecm_files';
1703 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1709 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1737 public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath =
'', $permissiontodelete = 1, $useinecm = 0, $textifempty =
'', $maxlength = 0, $url =
'', $addfilterfields = 0)
1740 global $conf, $langs, $hookmanager, $form;
1741 global $sortfield, $sortorder;
1742 global $search_doc_ref;
1743 global $dolibarr_main_url_root;
1745 dol_syslog(get_class($this).
'::list_of_autoecmfiles upload_dir='.$upload_dir.
' modulepart='.$modulepart);
1748 if (empty($useinecm) || $useinecm == 6) {
1752 $url = $_SERVER[
"PHP_SELF"];
1755 if (!empty($addfilterfields)) {
1756 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'">';
1757 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1758 print
'<input type="hidden" name="module" value="'.$modulepart.
'">';
1761 print
'<div class="div-table-responsive-no-min">';
1762 print
'<table width="100%" class="noborder">'.
"\n";
1764 if (!empty($addfilterfields)) {
1765 print
'<tr class="liste_titre nodrag nodrop">';
1766 print
'<td class="liste_titre"></td>';
1767 print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1768 print
'<td class="liste_titre"></td>';
1769 print
'<td class="liste_titre"></td>';
1771 print
'<td class="liste_titre right">';
1772 $searchpicto = $form->showFilterButtons();
1778 print
'<tr class="liste_titre">';
1779 $sortref =
"fullname";
1780 if ($modulepart ==
'invoice_supplier') {
1781 $sortref =
'level1name';
1791 $object_instance =
null;
1792 if ($modulepart ==
'company') {
1793 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1794 $object_instance =
new Societe($this->db);
1795 } elseif ($modulepart ==
'invoice') {
1796 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1797 $object_instance =
new Facture($this->db);
1798 } elseif ($modulepart ==
'invoice_supplier') {
1799 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1801 } elseif ($modulepart ==
'propal') {
1802 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
1803 $object_instance =
new Propal($this->db);
1804 } elseif ($modulepart ==
'supplier_proposal') {
1805 include_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
1807 } elseif ($modulepart ==
'order') {
1808 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1809 $object_instance =
new Commande($this->db);
1810 } elseif ($modulepart ==
'order_supplier') {
1811 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1813 } elseif ($modulepart ==
'contract') {
1814 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1815 $object_instance =
new Contrat($this->db);
1816 } elseif ($modulepart ==
'product') {
1817 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1818 $object_instance =
new Product($this->db);
1819 } elseif ($modulepart ==
'tax') {
1820 include_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
1822 } elseif ($modulepart ==
'tax-vat') {
1823 include_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
1824 $object_instance =
new Tva($this->db);
1825 } elseif ($modulepart ==
'salaries') {
1826 include_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
1827 $object_instance =
new Salary($this->db);
1828 } elseif ($modulepart ==
'project') {
1829 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1830 $object_instance =
new Project($this->db);
1831 } elseif ($modulepart ==
'project_task') {
1832 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1833 $object_instance =
new Task($this->db);
1834 } elseif ($modulepart ==
'fichinter') {
1835 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
1836 $object_instance =
new Fichinter($this->db);
1837 } elseif ($modulepart ==
'user') {
1838 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1839 $object_instance =
new User($this->db);
1840 } elseif ($modulepart ==
'expensereport') {
1841 include_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1843 } elseif ($modulepart ==
'holiday') {
1844 include_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
1845 $object_instance =
new Holiday($this->db);
1846 } elseif ($modulepart ==
'recruitment-recruitmentcandidature') {
1847 include_once DOL_DOCUMENT_ROOT.
'/recruitment/class/recruitmentcandidature.class.php';
1849 } elseif ($modulepart ==
'banque') {
1850 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1851 $object_instance =
new Account($this->db);
1852 } elseif ($modulepart ==
'chequereceipt') {
1853 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
1855 } elseif ($modulepart ==
'mrp-mo') {
1856 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
1857 $object_instance =
new Mo($this->db);
1859 $parameters = array(
'modulepart' => $modulepart);
1860 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
1861 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
1862 if (array_key_exists(
'classpath', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classpath'])) {
1864 if (array_key_exists(
'classname', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classname'])) {
1865 if (class_exists($hookmanager->resArray[
'classname'])) {
1866 $tmpclassname = $hookmanager->resArray[
'classname'];
1867 $object_instance =
new $tmpclassname($this->db);
1878 $relativepathfromroot = preg_replace(
'/'.preg_quote(DOL_DATA_ROOT.
'/',
'/').
'/',
'', $upload_dir);
1879 if ($relativepathfromroot) {
1883 if ($sortfield && $sortorder) {
1884 $filearray =
dol_sort_array($filearray, $sortfield, $sortorder, 1);
1890 foreach ($filearray as $key => $file) {
1891 if (!is_dir($file[
'name'])
1892 && $file[
'name'] !=
'.'
1893 && $file[
'name'] !=
'..'
1894 && $file[
'name'] !=
'CVS'
1895 && !preg_match(
'/\.meta$/i', $file[
'name'])) {
1897 $relativefile = preg_replace(
'/'.preg_quote($upload_dir.
'/',
'/').
'/',
'', $file[
'fullname']);
1905 if ($modulepart ==
'company' || $modulepart ==
'tax' || $modulepart ==
'tax-vat' || $modulepart ==
'salaries') {
1906 preg_match(
'/(\d+)\/[^\/]+$/', $relativefile, $reg);
1907 $id = (isset($reg[1]) ? $reg[1] :
'');
1908 } elseif ($modulepart ==
'invoice_supplier') {
1909 preg_match(
'/([^\/]+)\/[^\/]+$/', $relativefile, $reg);
1910 $ref = (isset($reg[1]) ? $reg[1] :
'');
1911 if (is_numeric($ref)) {
1915 } elseif ($modulepart ==
'user') {
1917 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
1918 $id = (isset($reg[1]) ? $reg[1] :
'');
1919 } elseif ($modulepart ==
'project_task') {
1921 $reg = explode(
"/", $relativefile);
1922 $ref = (isset($reg[1]) ? $reg[1] :
'');
1923 } elseif (in_array($modulepart, array(
1926 'supplier_proposal',
1935 'recruitment-recruitmentcandidature',
1940 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
1941 $ref = (isset($reg[1]) ? $reg[1] :
'');
1943 $parameters = array(
'modulepart' => $modulepart,
'fileinfo' => $file);
1944 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
1945 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
1946 if (array_key_exists(
'ref', $hookmanager->resArray) && !empty($hookmanager->resArray[
'ref'])) {
1947 $ref = $hookmanager->resArray[
'ref'];
1949 if (array_key_exists(
'id', $hookmanager->resArray) && !empty($hookmanager->resArray[
'id'])) {
1950 $id = $hookmanager->resArray[
'id'];
1956 if (!
$id && !$ref) {
1961 if (!empty($conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
1967 if (is_object($object_instance)) {
1968 $object_instance->id = 0;
1969 $object_instance->ref =
'';
1971 $result = $object_instance->fetch(
$id);
1973 if (!($result = $object_instance->fetch(0, $ref))) {
1979 $result = $object_instance->fetchOneLike($ref);
1986 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] = clone $object_instance;
1990 $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref] =
'notfound';
1991 unset($filearray[$key]);
1995 if ($found <= 0 || !is_object($conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
1999 print
'<!-- Line list_of_autoecmfiles key='.$key.
' -->'.
"\n";
2000 print
'<tr class="oddeven">';
2002 if ($found > 0 && is_object($conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref])) {
2003 $tmpobject = $conf->cache[
'modulepartobject'][$modulepart.
'_'.
$id.
'_'.$ref];
2005 print $tmpobject->getNomUrl(1,
'document');
2010 print $langs->trans(
"ObjectDeleted", (
$id ?
$id : $ref));
2028 print
'target="_blank" ';
2030 print
'href="'.DOL_URL_ROOT.
'/document.php?modulepart='.urlencode($modulepart);
2031 if ($forcedownload) {
2032 print
'&attachment=1';
2034 print
'&file='.urlencode($relativefile).
'">';
2041 print $this->
showPreview($file, $modulepart, $file[
'relativename']);
2048 print
'<td class="right nowraponall">';
2049 if ($sizetoshow == $sizetoshowbytes) {
2052 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
2057 print
'<td class="center">'.dol_print_date($file[
'date'],
"dayhour").
'</td>';
2060 print
'<td class="right">';
2061 if (!empty($file[
'share'])) {
2063 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
2064 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
2070 if (!empty($file[
'share'])) {
2071 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
2073 if ($forcedownload) {
2074 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
2077 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
2079 print
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
2080 print
'<input type="text" class="quatrevingtpercent width100 nopadding nopadding small" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
2094 if (count($filearray) == 0) {
2095 print
'<tr class="oddeven"><td colspan="5">';
2096 if (empty($textifempty)) {
2097 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
2099 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
2106 if (!empty($addfilterfields)) {
2109 return count($filearray);
2125 public function listOfLinks(
$object, $permissiontodelete = 1, $action =
null, $selected =
null, $param =
'', $htmlname =
'formaddlink', $moreoptions = array())
2127 global $conf, $langs;
2128 global $sortfield, $sortorder;
2130 $langs->load(
"link");
2132 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
2133 $link =
new Link($this->db);
2135 if ($sortfield ==
"name") {
2136 $sortfield =
"label";
2137 } elseif ($sortfield ==
"date") {
2138 $sortfield =
"datea";
2142 $res = $link->fetchAll($links,
$object->element,
$object->id, $sortfield, $sortorder);
2143 $param .= (isset(
$object->id) ?
'&id='.$object->id :
'');
2145 $permissiontoedit = $permissiontodelete;
2147 print
'<!-- listOfLinks -->'.
"\n";
2149 $morehtmlright =
'';
2150 if (!empty($moreoptions[
'showhideaddbutton']) && $conf->use_javascript_ajax) {
2151 $morehtmlright .=
dolGetButtonTitle($langs->trans(
'New'),
'',
'fa fa-plus-circle',
'javascript:console.log("open addlink form"); jQuery(".divlinkfile").toggle();',
'', $permissiontoedit);
2155 print
load_fiche_titre($langs->trans(
"LinkedFiles"), $morehtmlright,
'link', 0,
'',
'table-list-of-links');
2157 if (!empty($moreoptions) && $moreoptions[
'afterlinktitle']) {
2158 print
'<div class="divlinkfile'.((!empty($moreoptions[
'showhideaddbutton']) && $conf->use_javascript_ajax) ?
' hidden' :
'').
'">'.$moreoptions[
'afterlinktitle'].
'</div>';
2161 print
'<form action="'.$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
'').
'" id="'.$htmlname.
'" method="POST">';
2162 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2164 print
'<table class="liste noborder nobottom centpercent">';
2165 print
'<tr class="liste_titre">';
2167 $langs->trans(
"Links"),
2168 $_SERVER[
'PHP_SELF'],
2189 $langs->trans(
"Date"),
2190 $_SERVER[
'PHP_SELF'],
2201 $_SERVER[
'PHP_SELF'],
2212 $nboflinks = count($links);
2213 if ($nboflinks > 0) {
2214 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2216 foreach ($links as $link) {
2217 print
'<tr class="oddeven">';
2219 if ($action ==
'update' && $selected === (
int) $link->id && $permissiontoedit) {
2221 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2222 print
'<input type="hidden" name="linkid" value="'.$link->id.
'">';
2223 print
'<input type="hidden" name="action" value="confirm_updateline">';
2224 print $langs->trans(
'Link').
': <input type="text" name="link" value="'.$link->url.
'">';
2227 print $langs->trans(
'Label').
': <input type="text" name="label" value="'.
dol_escape_htmltag($link->label).
'">';
2229 print
'<td class="center">'.dol_print_date(
dol_now(),
"dayhour",
"tzuser").
'</td>';
2230 print
'<td class="right"></td>';
2231 print
'<td class="right">';
2232 print
'<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2233 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2238 print
'<a data-ajax="false" href="'.$link->url.
'" target="_blank" rel="noopener noreferrer">';
2242 print
'<td class="right"></td>';
2243 print
'<td class="center">'.dol_print_date($link->datea,
"dayhour",
"tzuser").
'</td>';
2244 print
'<td class="center"></td>';
2245 print
'<td class="right">';
2246 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=update&linkid='.$link->id.$param.
'&token='.
newToken().
'" class="editfilelink editfielda reposition" >'.
img_edit().
'</a>';
2247 if ($permissiontodelete) {
2248 print
' <a class="deletefilelink reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=deletelink&token='.
newToken().
'&linkid='.((int) $link->id).$param.
'">'.
img_delete().
'</a>';
2256 if ($nboflinks == 0) {
2257 print
'<tr class="oddeven"><td colspan="5">';
2258 print
'<span class="opacitymedium">'.$langs->trans(
"NoLinkFound").
'</span>';
2279 public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0, $param =
'')
2281 global $langs, $conf;
2284 if ($conf->browser->layout !=
'phone' && !empty($conf->use_javascript_ajax)) {
2286 if (count($urladvancedpreview)) {
2287 $out .=
'<a class="pictopreview '.$urladvancedpreview[
'css'].
'" href="'.$urladvancedpreview[
'url'].
'"'.(empty($urladvancedpreview[
'mime']) ?
'' :
' mime="'.$urladvancedpreview[
'mime'].
'"').
' '.(empty($urladvancedpreview[
'target']) ?
'' :
' target="'.$urladvancedpreview[
'target'].
'"').
'>';
2289 if (empty($ruleforpicto)) {
2291 $out .=
'<span class="fa fa-search-plus pictofixedwidth" style="color: gray"></span>';
2293 $out .=
img_mime($relativepath, $langs->trans(
'Preview').
' '.$file[
'name'],
'pictofixedwidth');
2297 if ($ruleforpicto < 0) {
2298 $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 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...
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
getMaxFileSizeArray()
Return the max allowed for file upload.