57 $this->numoffiles = 0;
86 public function form_attach_new_file($url, $title =
'', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object =
'', $options =
'', $useajax = 1, $savingdocmask =
'', $linkfiles = 1, $htmlname =
'formuserfile', $accept =
'', $sectiondir =
'', $usewithoutform = 0, $capture = 0, $disablemulti = 0, $nooutput = 0)
89 global $conf, $langs, $hookmanager;
90 $hookmanager->initHooks(array(
'formfile'));
94 dol_syslog(__METHOD__.
": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
97 if (!empty($conf->browser->layout) && $conf->browser->layout !=
'classic') {
101 if ((!empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax == 2)) {
110 if (!$perm && !empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
118 $out =
"\n\n".
'<!-- Start form attach new file --><div class="formattachnewfile">'.
"\n";
121 $title = $langs->trans(
"AttachANewFile");
123 if ($title !=
'none') {
127 if (empty($usewithoutform)) {
129 $url .= (strpos($url,
'?') ===
false ?
'?' :
'&').
'uploadform=1';
131 $out .=
'<form name="'.$htmlname.
'" id="'.$htmlname.
'" action="'.$url.
'" enctype="multipart/form-data" method="POST">'.
"\n";
133 if (empty($usewithoutform) || $usewithoutform == 2) {
134 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
135 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_dir" name="section_dir" value="'.$sectiondir.
'">'.
"\n";
136 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_id" name="section_id" value="'.$sectionid.
'">'.
"\n";
137 $out .=
'<input type="hidden" name="sortfield" value="'.GETPOST(
'sortfield',
'aZ09comma').
'">'.
"\n";
138 $out .=
'<input type="hidden" name="sortorder" value="'.GETPOST(
'sortorder',
'aZ09comma').
'">'.
"\n";
139 $out .=
'<input type="hidden" name="page_y" value="">'.
"\n";
142 $out .=
'<table class="nobordernopadding centpercent">';
145 if (!empty($options)) {
146 $out .=
'<td>'.$options.
'</td>';
149 $out .=
'<td class="valignmiddle nowrap">';
152 $max = $maxfilesizearray[
'max'];
153 $maxmin = $maxfilesizearray[
'maxmin'];
154 $maxphptoshow = $maxfilesizearray[
'maxphptoshow'];
155 $maxphptoshowparam = $maxfilesizearray[
'maxphptoshowparam'];
157 $out .=
'<input type="hidden" name="MAX_FILE_SIZE" value="'.($maxmin * 1024).
'">';
159 $out .=
'<input class="flat minwidth400 maxwidth200onsmartphone" type="file"';
160 $out .= ((!empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $disablemulti) ?
' name="userfile"' :
' name="userfile[]" multiple');
161 $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ?
' disabled' :
'');
162 $out .= (!empty($accept) ?
' accept="'.$accept.
'"' :
' accept=""');
163 $out .= (!empty($capture) ?
' capture="capture"' :
'');
167 $langs->load(
'link');
168 $out .=
'<span class="nowraponsmartphone"><input style="margin-right: 2px;" type="checkbox" id="overwritefile" name="overwritefile" value="1"><label for="overwritefile">'.$langs->trans(
"OverwriteIfExists").
'</label></span>';
170 $out .=
'<input type="submit" class="button small reposition" name="sendit" value="'.$langs->trans(
"Upload").
'"';
171 $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ?
' disabled' :
'');
176 $out .=
'<input type="submit" class="button small button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
179 if (!empty($conf->global->MAIN_UPLOAD_DOC)) {
181 $menudolibarrsetupmax = $langs->transnoentitiesnoconv(
"Home").
'-'.$langs->transnoentitiesnoconv(
"Setup").
'-'.$langs->transnoentitiesnoconv(
"Security");
182 $langs->load(
'other');
184 $out .=
info_admin($langs->trans(
"ThisLimitIsDefinedInSetupAt", $menudolibarrsetupmax, $max, $maxphptoshowparam, $maxphptoshow), 1);
187 $out .=
' ('.$langs->trans(
"UploadDisabled").
')';
189 $out .=
"</td></tr>";
191 if ($savingdocmask) {
193 $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ?
'checked' :
'');
196 if (!empty($options)) {
197 $out .=
'<td>'.$options.
'</td>';
199 $out .=
'<td valign="middle" class="nowrap">';
200 $out .=
'<input type="checkbox" '.$rename.
' class="savingdocmask" name="savingdocmask" id="savingdocmask" value="'.
dol_escape_js($savingdocmask).
'"> ';
201 $out .=
'<label class="opacitymedium small" for="savingdocmask">';
202 $out .= $langs->trans(
"SaveUploadedFileWithMask", preg_replace(
'/__file__/', $langs->transnoentitiesnoconv(
"OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv(
"OriginFileName"));
210 if (empty($usewithoutform)) {
212 if (empty($sectionid)) {
217 $out .=
"\n</div><!-- End form attach new file -->\n";
220 $out .=
"\n".
'<!-- Start form link new url --><div class="formlinknewurl">'.
"\n";
221 $langs->load(
'link');
222 $title = $langs->trans(
"LinkANewFile");
225 if (empty($usewithoutform)) {
226 $out .=
'<form name="'.$htmlname.
'_link" id="'.$htmlname.
'_link" action="'.$url.
'" method="POST">'.
"\n";
227 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
228 $out .=
'<input type="hidden" id="'.$htmlname.
'_link_section_dir" name="link_section_dir" value="">'.
"\n";
229 $out .=
'<input type="hidden" id="'.$htmlname.
'_link_section_id" name="link_section_id" value="'.$sectionid.
'">'.
"\n";
230 $out .=
'<input type="hidden" name="page_y" value="">'.
"\n";
233 $out .=
'<div class="valignmiddle">';
234 $out .=
'<div class="inline-block" style="padding-right: 10px;">';
235 if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) {
236 $out .=
'<label for="link">'.$langs->trans(
"URLToLink").
':</label> ';
238 $out .=
'<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans(
"URLToLink")).
'">';
240 $out .=
'<div class="inline-block" style="padding-right: 10px;">';
241 if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) {
242 $out .=
'<label for="label">'.$langs->trans(
"Label").
':</label> ';
244 $out .=
'<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans(
"Label")).
'">';
245 $out .=
'<input type="hidden" name="objecttype" value="'.$object->element.
'">';
246 $out .=
'<input type="hidden" name="objectid" value="'.$object->id.
'">';
248 $out .=
'<div class="inline-block" style="padding-right: 10px;">';
249 $out .=
'<input type="submit" class="button small reposition" name="linkit" value="'.$langs->trans(
"ToLink").
'"';
250 $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ?
' disabled' :
'');
254 if (empty($usewithoutform)) {
255 $out .=
'<div class="clearboth"></div>';
256 $out .=
'</form><br>';
259 $out .=
"\n</div><!-- End form link new url -->\n";
262 $parameters = array(
'socid'=>(isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id'=>(isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url'=>$url,
'perm'=>$perm,
'options'=>$options);
263 $res = $hookmanager->executeHooks(
'formattachOptions', $parameters, $object);
265 $out =
'<div class="'.($usewithoutform ?
'inline-block valignmiddle' :
'attacharea attacharea'.$htmlname).
'">'.$out.
'</div>';
267 $out .= $hookmanager->resPrint;
301 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 =
'')
304 $this->numoffiles = 0;
305 print $this->
showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
306 return $this->numoffiles;
336 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 =
'')
338 global $dolibarr_main_url_root;
341 if (!empty($iconPDF)) {
342 dol_syslog(__METHOD__.
": passing iconPDF parameter is deprecated", LOG_WARNING);
345 global $langs, $conf, $user, $hookmanager;
349 if (is_object($hookmanager)) {
351 'modulepart'=>&$modulepart,
352 'modulesubdir'=>&$modulesubdir,
353 'filedir'=>&$filedir,
354 'urlsource'=>&$urlsource,
355 'genallowed'=>&$genallowed,
356 'delallowed'=>&$delallowed,
357 'modelselected'=>&$modelselected,
358 'allowgenifempty'=>&$allowgenifempty,
359 'forcenomultilang'=>&$forcenomultilang,
363 'buttonlabel'=>&$buttonlabel,
364 'codelang'=>&$codelang,
365 'morepicto'=>&$morepicto,
366 'hideifempty'=>&$hideifempty,
367 'removeaction'=>&$removeaction
369 $reshook = $hookmanager->executeHooks(
'showDocuments', $parameters, $object);
377 return $hookmanager->resPrint;
380 if (!is_object(
$form)) {
384 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
387 if (!empty($iconPDF)) {
392 if (!preg_match(
'/entity\=[0-9]+/', $param)) {
393 $param .= ($param ?
'&' :
'').
'entity='.(!empty($object->entity) ? $object->entity : $conf->entity);
398 if (in_array($modulepart, array(
'contract',
'facture',
'supplier_proposal',
'propal',
'proposal',
'order',
'commande',
'expedition',
'commande_fournisseur',
'expensereport',
'delivery',
'ticket'))) {
399 $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ?
true:
false;
402 $hookmanager->initHooks(array(
'formfile'));
406 if (!empty($filedir)) {
407 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
409 if ($hideifempty && empty($file_list)) {
414 $forname =
'builddoc';
419 $out .=
"\n".
'<!-- Start show_document -->'.
"\n";
422 if (preg_match(
'/massfilesarea_/', $modulepart)) {
423 $out .=
'<div id="show_files"><br></div>'.
"\n";
424 $title = $langs->trans(
"MassFilesArea").
' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans(
"Hide").
')</a>';
426 jQuery(document).ready(function() {
427 jQuery(\'#togglemassfilesarea\').click(function() {
428 if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown")
430 jQuery(\'#'.$modulepart.
'_table\').hide();
431 jQuery(\'#togglemassfilesarea\').attr("ref", "hidden");
432 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Show")).
')");
436 jQuery(\'#'.$modulepart.
'_table\').show();
437 jQuery(\'#togglemassfilesarea\').attr("ref","shown");
438 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Hide")).
')");
446 $titletoshow = $langs->trans(
"Documents");
447 if (!empty($title)) {
448 $titletoshow = ($title ==
'none' ?
'' : $title);
453 $modellist = array();
455 if ($modulepart ==
'company') {
457 if (is_array($genallowed)) {
458 $modellist = $genallowed;
460 include_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
463 } elseif ($modulepart ==
'propal') {
464 if (is_array($genallowed)) {
465 $modellist = $genallowed;
467 include_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
470 } elseif ($modulepart ==
'supplier_proposal') {
471 if (is_array($genallowed)) {
472 $modellist = $genallowed;
474 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
477 } elseif ($modulepart ==
'commande') {
478 if (is_array($genallowed)) {
479 $modellist = $genallowed;
481 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
484 } elseif ($modulepart ==
'expedition') {
485 if (is_array($genallowed)) {
486 $modellist = $genallowed;
488 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
489 $modellist = ModelePDFExpedition::liste_modeles($this->
db);
491 } elseif ($modulepart ==
'reception') {
492 if (is_array($genallowed)) {
493 $modellist = $genallowed;
495 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
498 } elseif ($modulepart ==
'delivery') {
499 if (is_array($genallowed)) {
500 $modellist = $genallowed;
502 include_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
505 } elseif ($modulepart ==
'ficheinter') {
506 if (is_array($genallowed)) {
507 $modellist = $genallowed;
509 include_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
512 } elseif ($modulepart ==
'facture') {
513 if (is_array($genallowed)) {
514 $modellist = $genallowed;
516 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
519 } elseif ($modulepart ==
'contract') {
521 if (is_array($genallowed)) {
522 $modellist = $genallowed;
524 include_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
527 } elseif ($modulepart ==
'project') {
528 if (is_array($genallowed)) {
529 $modellist = $genallowed;
531 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
534 } elseif ($modulepart ==
'project_task') {
535 if (is_array($genallowed)) {
536 $modellist = $genallowed;
538 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
541 } elseif ($modulepart ==
'product') {
542 if (is_array($genallowed)) {
543 $modellist = $genallowed;
545 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
548 } elseif ($modulepart ==
'product_batch') {
549 if (is_array($genallowed)) {
550 $modellist = $genallowed;
552 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product_batch/modules_product_batch.class.php';
555 } elseif ($modulepart ==
'stock') {
556 if (is_array($genallowed)) {
557 $modellist = $genallowed;
559 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_stock.php';
562 } elseif ($modulepart ==
'movement') {
563 if (is_array($genallowed)) {
564 $modellist = $genallowed;
566 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_movement.php';
569 } elseif ($modulepart ==
'export') {
570 if (is_array($genallowed)) {
571 $modellist = $genallowed;
573 include_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
576 } elseif ($modulepart ==
'commande_fournisseur' || $modulepart ==
'supplier_order') {
577 if (is_array($genallowed)) {
578 $modellist = $genallowed;
580 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
583 } elseif ($modulepart ==
'facture_fournisseur' || $modulepart ==
'supplier_invoice') {
585 if (is_array($genallowed)) {
586 $modellist = $genallowed;
588 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
591 } elseif ($modulepart ==
'supplier_payment') {
592 if (is_array($genallowed)) {
593 $modellist = $genallowed;
595 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
598 } elseif ($modulepart ==
'remisecheque') {
599 if (is_array($genallowed)) {
600 $modellist = $genallowed;
602 include_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
605 } elseif ($modulepart ==
'donation') {
606 if (is_array($genallowed)) {
607 $modellist = $genallowed;
609 include_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
612 } elseif ($modulepart ==
'member') {
613 if (is_array($genallowed)) {
614 $modellist = $genallowed;
616 include_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
619 } elseif ($modulepart ==
'agenda' || $modulepart ==
'actions') {
620 if (is_array($genallowed)) {
621 $modellist = $genallowed;
623 include_once DOL_DOCUMENT_ROOT.
'/core/modules/action/modules_action.php';
626 } elseif ($modulepart ==
'expensereport') {
627 if (is_array($genallowed)) {
628 $modellist = $genallowed;
630 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
633 } elseif ($modulepart ==
'unpaid') {
635 } elseif ($modulepart ==
'user') {
636 if (is_array($genallowed)) {
637 $modellist = $genallowed;
639 include_once DOL_DOCUMENT_ROOT.
'/core/modules/user/modules_user.class.php';
642 } elseif ($modulepart ==
'usergroup') {
643 if (is_array($genallowed)) {
644 $modellist = $genallowed;
646 include_once DOL_DOCUMENT_ROOT.
'/core/modules/usergroup/modules_usergroup.class.php';
650 $submodulepart = $modulepart;
653 $tmp = explode(
':', $modulepart);
654 if (!empty($tmp[1])) {
655 $modulepart = $tmp[0];
656 $submodulepart = $tmp[1];
660 $file =
dol_buildpath(
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
661 if (file_exists($file)) {
662 $res = include_once $file;
665 $file =
dol_buildpath(
'/'.$modulepart.
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
666 $res = include_once $file;
669 $class =
'ModelePDF'.ucfirst($submodulepart);
671 if (class_exists($class)) {
672 $modellist = call_user_func($class.
'::liste_modeles', $this->db);
674 dol_print_error($this->
db,
"Bad value for modulepart '".$modulepart.
"' in showdocuments (class ".$class.
" for Doc generation not found)");
682 if (empty($buttonlabel)) {
683 $buttonlabel = $langs->trans(
'Generate');
686 if ($conf->browser->layout ==
'phone') {
687 $urlsource .=
'#'.$forname.
'_form';
689 if (empty($noform)) {
690 $out .=
'<form action="'.$urlsource.
'" id="'.$forname.
'_form" method="post">';
692 $out .=
'<input type="hidden" name="action" value="builddoc">';
693 $out .=
'<input type="hidden" name="page_y" value="">';
694 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
697 $out .=
'<div class="div-table-responsive-no-min">';
698 $out .=
'<table class="liste formdoc noborder centpercent">';
700 $out .=
'<tr class="liste_titre">';
702 $addcolumforpicto = ($delallowed || $printer || $morepicto);
703 $colspan = (4 + ($addcolumforpicto ? 1 : 0));
706 $out .=
'<th colspan="'.$colspan.
'" class="formdoc liste_titre maxwidthonsmartphone center">';
709 if (!empty($modellist)) {
711 $out .=
'<span class="hideonsmartphone">'.$langs->trans(
'Model').
' </span>';
712 if (is_array($modellist) && count($modellist) == 1) {
713 $arraykeys = array_keys($modellist);
714 $modelselected = $arraykeys[0];
716 $morecss =
'minwidth75 maxwidth200';
717 if ($conf->browser->layout ==
'phone') {
718 $morecss =
'maxwidth100';
720 $out .=
$form->selectarray(
'model', $modellist, $modelselected, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss);
721 if ($conf->use_javascript_ajax) {
724 $out .=
$form->textwithpicto(
'', $tooltipontemplatecombo, 1,
'help',
'marginrightonly', 0, 3,
'', 0);
726 $out .=
'<div class="float">'.$langs->trans(
"Files").
'</div>';
730 if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && !empty($conf->global->MAIN_MULTILANGS) && !$forcenomultilang && (!empty($modellist) || $showempty)) {
731 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
733 $defaultlang = ($codelang && $codelang !=
'auto') ? $codelang : $langs->getDefaultLang();
734 $morecss =
'maxwidth150';
735 if ($conf->browser->layout ==
'phone') {
736 $morecss =
'maxwidth100';
738 $out .= $formadmin->select_language($defaultlang,
'lang_id', 0,
null, 0, 0, 0, $morecss);
744 $genbutton =
'<input class="button buttongen reposition nomargintop nomarginbottom" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
745 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
746 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) {
747 $genbutton .=
' disabled';
750 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
751 $langs->load(
"errors");
752 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
754 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') {
757 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') {
763 if (!empty($hookmanager->hooks[
'formfile'])) {
764 foreach ($hookmanager->hooks[
'formfile'] as $module) {
765 if (method_exists($module,
'formBuilddocLineOptions')) {
774 $parameters = array(
'colspan'=>($colspan + $colspanmore),
'socid'=>(isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id'=>(isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart'=>$modulepart);
775 if (is_object($hookmanager)) {
776 $reshook = $hookmanager->executeHooks(
'formBuilddocOptions', $parameters, $GLOBALS[
'object']);
777 $out .= $hookmanager->resPrint;
782 if (!empty($filedir)) {
783 $link_list = array();
784 if (is_object($object)) {
785 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
786 $link =
new Link($this->
db);
787 $sortfield = $sortorder =
null;
788 $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder);
791 $out .=
'<!-- html.formfile::showdocuments -->'.
"\n";
794 if ((!empty($file_list) || !empty($link_list) || preg_match(
'/^massfilesarea/', $modulepart))
797 $out .=
'<div class="titre">'.$titletoshow.
'</div>'.
"\n";
798 $out .=
'<div class="div-table-responsive-no-min">';
799 $out .=
'<table class="noborder centpercent" id="'.$modulepart.
'_table">'.
"\n";
803 if (is_array($file_list)) {
807 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $filedir);
808 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
816 if (!empty($sortfield) && !empty($sortorder)) {
821 foreach ($file_list as $file) {
823 $relativepath = $file[
"name"];
825 $relativepath = $modulesubdir.
"/".$file[
"name"];
827 if ($modulepart ==
'export') {
828 $relativepath = $file[
"name"];
831 $out .=
'<tr class="oddeven">';
833 $documenturl = DOL_URL_ROOT.
'/document.php';
834 if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) {
835 $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP;
839 $out .=
'<td class="minwidth200 tdoverflowmax300">';
840 $out .=
'<a class="documentdownload paddingright" href="'.$documenturl.
'?modulepart='.$modulepart.
'&file='.urlencode($relativepath).($param ?
'&'.$param :
'').
'"';
843 if (preg_match(
'/text/', $mime)) {
844 $out .=
' target="_blank" rel="noopener noreferrer"';
847 $out .=
img_mime($file[
"name"], $langs->trans(
"File").
': '.$file[
"name"]);
850 $out .= $this->
showPreview($file, $modulepart, $relativepath, 0, $param);
854 $size = (!empty($file[
'size']) ? $file[
'size'] :
dol_filesize($filedir.
"/".$file[
"name"]));
855 $out .=
'<td class="nowraponall right">'.dol_print_size($size, 1, 1).
'</td>';
858 $date = (!empty($file[
'date']) ? $file[
'date'] :
dol_filemtime($filedir.
"/".$file[
"name"]));
859 $out .=
'<td class="nowrap right">'.dol_print_date($date,
'dayhour',
'tzuser').
'</td>';
862 $out .=
'<td class="nowraponall">';
863 if (!empty($file[
'share'])) {
865 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
866 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
872 if (!empty($file[
'share'])) {
873 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
875 if ($forcedownload) {
876 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
879 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
881 $out .=
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
882 $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).
'">';
890 if ($delallowed || $printer || $morepicto) {
891 $out .=
'<td class="right nowraponall">';
893 $tmpurlsource = preg_replace(
'/#[a-zA-Z0-9_]*$/',
'', $urlsource);
894 $out .=
'<a class="reposition" href="'.$tmpurlsource.((strpos($tmpurlsource,
'?') ===
false) ?
'?' :
'&').
'action='.urlencode($removeaction).
'&token='.
newToken().
'&file='.urlencode($relativepath);
895 $out .= ($param ?
'&'.$param :
'');
898 $out .=
'">'.img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
901 $out .=
'<a class="marginleftonly reposition" href="'.$urlsource.(strpos($urlsource,
'?') ?
'&' :
'?').
'action=print_file&token='.
newToken().
'&printer='.urlencode($modulepart).
'&file='.urlencode($relativepath);
902 $out .= ($param ?
'&'.$param :
'');
903 $out .=
'">'.img_picto($langs->trans(
"PrintFile", $relativepath),
'printer.png').
'</a>';
906 $morepicto = preg_replace(
'/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto);
912 if (is_object($hookmanager)) {
913 $parameters = array(
'colspan'=>($colspan + $colspanmore),
'socid'=>(isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id'=>(isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart'=>$modulepart,
'relativepath'=>$relativepath);
914 $res = $hookmanager->executeHooks(
'formBuilddocLineOptions', $parameters, $file);
916 $out .= $hookmanager->resPrint;
919 $out = $hookmanager->resPrint;
927 if (is_array($link_list)) {
930 foreach ($link_list as $file) {
931 $out .=
'<tr class="oddeven">';
932 $out .=
'<td colspan="'.$colspan.
'" class="maxwidhtonsmartphone">';
933 $out .=
'<a data-ajax="false" href="'.$file->url.
'" target="_blank" rel="noopener noreferrer">';
934 $out .= $file->label;
937 $out .=
'<td class="right">';
942 if ($delallowed || $printer || $morepicto) {
945 $out .=
'</tr>'.
"\n";
950 if (count($file_list) == 0 && count($link_list) == 0 && $headershown) {
951 $out .=
'<tr><td colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>'.
"\n";
957 $out .=
"</table>\n";
960 if (empty($noform)) {
961 $out .=
'</form>'.
"\n";
965 $out .=
'<!-- End show_document -->'.
"\n";
983 public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter =
'', $morecss =
'valignmiddle', $allfiles = 0)
985 global $conf, $langs;
987 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
990 $this->infofiles = array(
'nboffiles'=>0,
'extensions'=>array(),
'files'=>array());
995 if (!empty($conf->multicompany->enabled)) {
997 preg_match(
'/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,
'/').
'$/', $filedir, $regs);
998 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
1002 if ($allfiles || !empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) {
1003 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/');
1005 $filterforfilesearch =
'^'.preg_quote(basename($modulesubdir),
'/').
'\.';
1007 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
1011 $out .=
'<!-- html.formfile::getDocumentsLink -->'.
"\n";
1012 if (!empty($file_list)) {
1013 $out =
'<dl class="dropdown inline-block">
1014 <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto(
'',
'listlight',
'', 0, 0, 0,
'', $morecss).
'</a></dt>
1015 <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
1021 foreach ($file_list as $file) {
1023 if ($filter && !preg_match(
'/'.$filter.
'/i', $file[
"name"])) {
1029 $relativepath = $file[
"name"];
1030 if ($modulesubdir) {
1031 $relativepath = $modulesubdir.
"/".$file[
"name"];
1034 if ($modulepart ==
'donation') {
1035 $relativepath =
get_exdir($modulesubdir, 2, 0, 0,
null,
'donation').$file[
"name"];
1037 if ($modulepart ==
'export') {
1038 $relativepath = $file[
"name"];
1041 $this->infofiles[
'nboffiles']++;
1042 $this->infofiles[
'files'][] = $file[
'fullname'];
1043 $ext = pathinfo($file[
"name"], PATHINFO_EXTENSION);
1044 if (empty($this->infofiles[$ext])) {
1045 $this->infofiles[
'extensions'][$ext] = 1;
1047 $this->infofiles[
'extensions'][$ext]++;
1051 if (!empty($conf->use_javascript_ajax) && ($conf->browser->layout !=
'phone')) {
1053 if ($tmparray && $tmparray[
'url']) {
1054 $tmpout .=
'<li><a href="'.$tmparray[
'url'].
'"'.($tmparray[
'css'] ?
' class="'.$tmparray[
'css'].
'"' :
'').($tmparray[
'mime'] ?
' mime="'.$tmparray[
'mime'].
'"' :
'').($tmparray[
'target'] ?
' target="'.$tmparray[
'target'].
'"' :
'').
'>';
1056 $tmpout .=
'<i class="fa fa-search-plus paddingright" style="color: gray"></i>';
1057 $tmpout .= $langs->trans(
"Preview").
' '.$ext.
'</a></li>';
1062 $tmpout .=
'<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($relativepath).
'"';
1064 if (preg_match(
'/text/', $mime)) {
1065 $tmpout .=
' target="_blank" rel="noopener noreferrer"';
1068 $tmpout .=
img_mime($relativepath, $file[
"name"]);
1069 $tmpout .= $langs->trans(
"Download").
' '.$ext;
1070 $tmpout .=
'</a></li>'.
"\n";
1073 $out .=
'</ul></div></dd>
1122 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 =
'')
1125 global $user, $conf, $langs, $hookmanager,
$form;
1126 global $sortfield, $sortorder, $maxheightmini;
1127 global $dolibarr_main_url_root;
1129 if ($disablecrop == -1) {
1132 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'))) {
1138 if (empty($relativepath)) {
1140 if (!empty($object->element) && $object->element ==
'invoice_supplier') {
1141 $relativepath =
get_exdir($object->id, 2, 0, 0, $object,
'invoice_supplier').$relativepath;
1143 if (!empty($object->element) && $object->element ==
'project_task') {
1144 $relativepath =
'Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1148 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0][
'level1name'] ==
'photos') {
1149 $relativepath = preg_replace(
'/^.*\/produit\//',
'', $filearray[0][
'path']).
'/';
1155 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $upload_dir);
1156 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1161 $hookmanager->initHooks(array(
'formfile'));
1162 $parameters = array(
1163 'filearray' => $filearray,
1164 'modulepart'=> $modulepart,
1166 'forcedownload' => $forcedownload,
1167 'relativepath' => $relativepath,
1168 'relativedir' => $relativedir,
1169 'permtodelete' => $permonobject,
1170 'useinecm' => $useinecm,
1171 'textifempty' => $textifempty,
1172 'maxlength' => $maxlength,
1176 $reshook = $hookmanager->executeHooks(
'showFilesList', $parameters, $object);
1178 if (!empty($reshook)) {
1181 if (!is_object(
$form)) {
1182 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1186 if (!preg_match(
'/&id=/', $param) && isset($object->id)) {
1187 $param .=
'&id='.$object->id;
1189 $relativepathwihtoutslashend = preg_replace(
'/\/$/',
'', $relativepath);
1190 if ($relativepathwihtoutslashend) {
1191 $param .=
'&file='.urlencode($relativepathwihtoutslashend);
1194 if ($permtoeditline < 0) {
1195 $permtoeditline = 0;
1196 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1198 $permtoeditline = 1;
1201 $permtoeditline = 1;
1205 if (empty($conf->global->MAIN_UPLOAD_DOC)) {
1206 $permtoeditline = 0;
1211 if ((empty($useinecm) || $useinecm == 6) && $title !=
'none') {
1212 print
load_fiche_titre($title ? $title : $langs->trans(
"AttachedFiles"),
'',
'file-upload', 0,
'',
'table-list-of-attached-files');
1215 $url = $_SERVER[
"PHP_SELF"];
1218 print
'<!-- html.formfile::list_of_documents -->'.
"\n";
1219 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1220 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?'.$param.
'" method="POST">';
1221 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1222 print
'<input type="hidden" name="action" value="renamefile">';
1223 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1224 print
'<input type="hidden" name="modulepart" value="'.$modulepart.
'">';
1227 print
'<div class="div-table-responsive-no-min"'.($moreattrondiv ?
' '.$moreattrondiv :
'').
'>';
1228 print
'<table id="tablelines" class="centpercent liste noborder nobottom">'.
"\n";
1230 if (!empty($addfilterfields)) {
1231 print
'<tr class="liste_titre nodrag nodrop">';
1232 print
'<td><input type="search_doc_ref" value="'.dol_escape_htmltag(
GETPOST(
'search_doc_ref',
'alpha')).
'"></td>';
1235 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1240 if (empty($disablemove) && count($filearray) > 1) {
1251 if ($sortfield && $sortorder) {
1256 print
'<tr class="liste_titre nodrag nodrop">';
1261 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1268 if (empty($disablemove) && count($filearray) > 1) {
1273 $nboffiles = count($filearray);
1274 if ($nboffiles > 0) {
1275 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1281 foreach ($filearray as $key => $file) {
1282 if ($file[
'name'] !=
'.'
1283 && $file[
'name'] !=
'..'
1284 && !preg_match(
'/\.meta$/i', $file[
'name'])) {
1285 if (array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) {
1286 $lastrowid = $filearray[$key][
'rowid'];
1288 $filepath = $relativepath.$file[
'name'];
1292 print
'<!-- Line list_of_documents '.$key.
' relativepath = '.$relativepath.
' -->'.
"\n";
1294 print
'<!-- In database: position='.(array_key_exists(
'position', $filearray[$key]) ? $filearray[$key][
'position'] : 0).
' -->'.
"\n";
1295 print
'<tr class="oddeven" id="row-'.((array_key_exists(
'rowid', $filearray[$key]) && $filearray[$key][
'rowid'] > 0) ? $filearray[$key][
'rowid'] :
'AFTER'.$lastrowid.
'POS'.($i + 1)).
'">';
1299 print
'<td class="minwith200 tdoverflowmax500">';
1303 print
'<a class="paddingright valignmiddle" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart;
1304 if ($forcedownload) {
1305 print
'&attachment=1';
1307 if (!empty($object->entity)) {
1308 print
'&entity='.$object->entity;
1310 print
'&file='.urlencode($filepath);
1312 print
img_mime($file[
'name'], $file[
'name'].
' ('.
dol_print_size($file[
'size'], 0, 0).
')',
'inline-block valignmiddle paddingright');
1313 if ($showrelpart == 1) {
1314 print $relativepath;
1317 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $file[
'name'] == basename(
GETPOST(
'urlfile',
'alpha'))) {
1319 $section_dir = dirname(
GETPOST(
'urlfile',
'alpha'));
1320 if (!preg_match(
'/\/$/', $section_dir)) {
1321 $section_dir .=
'/';
1323 print
'<input type="hidden" name="section_dir" value="'.$section_dir.
'">';
1324 print
'<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file[
'name']).
'">';
1325 print
'<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file[
'name']).
'">';
1328 $filenametoshow = preg_replace(
'/\.noexe$/',
'', $file[
'name']);
1334 print $this->
showPreview($file, $modulepart, $filepath, 0,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
1342 print
'<td class="right nowraponall">';
1343 if ($sizetoshow == $sizetoshowbytes) {
1346 print
$form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1351 print
'<td class="center nowraponall">'.dol_print_date($file[
'date'],
"dayhour",
"tzuser").
'</td>';
1354 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6) {
1355 $fileinfo = pathinfo($file[
'name']);
1356 print
'<td class="center">';
1358 if ($useinecm == 5 || $useinecm == 6) {
1368 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
1369 if (empty($urlforhref)) {
1370 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
1371 print
'<a href="'.$urlforhref.
'" class="aphoto" target="_blank" rel="noopener noreferrer">';
1373 print
'<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
1375 print
'<img class="photo maxwidth200 shadow valignmiddle" height="'.(($useinecm == 4 || $useinecm == 5 || $useinecm == 6) ?
'20' : $maxheightmini).
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$smallfile).
'" title="">';
1384 print
'<td class="center">';
1385 if ($relativedir && $filearray[$key][
'rowid'] > 0) {
1387 print
'<label for="idshareenabled'.$key.
'">'.$langs->trans(
"FileSharedViaALink").
'</label> ';
1388 print
'<input class="inline-block" type="checkbox" id="idshareenabled'.$key.
'" name="shareenabled"'.($file[
'share'] ?
' checked="checked"' :
'').
' /> ';
1390 if ($file[
'share']) {
1392 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1393 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1399 if (!empty($file[
'share'])) {
1400 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
1402 if ($forcedownload) {
1403 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1406 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1408 print
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
1409 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).
'">';
1421 print
'<td class="valignmiddle right actionbuttons nowraponall"><!-- action on files -->';
1422 if ($useinecm == 1 || $useinecm == 5) {
1424 $newparam = preg_replace(
'/&file=.*$/',
'', $param);
1425 $backtopage = DOL_URL_ROOT.
'/ecm/index.php?§ion_dir='.urlencode($relativepath).$newparam;
1426 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>';
1429 if (empty($useinecm) || $useinecm == 2 || $useinecm == 6) {
1430 $newmodulepart = $modulepart;
1431 if (in_array($modulepart, array(
'product',
'produit',
'service'))) {
1432 $newmodulepart =
'produit|service';
1436 if ($permtoeditline) {
1438 $moreparaminurl =
'';
1439 if ($object->id > 0) {
1440 $moreparaminurl =
'&id='.$object->id;
1441 } elseif (
GETPOST(
'website',
'alpha')) {
1442 $moreparaminurl =
'&website='.GETPOST(
'website',
'alpha');
1444 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>';
1448 if ($permtoeditline) {
1449 $paramsectiondir = (in_array($modulepart, array(
'medias',
'ecm')) ?
'§ion_dir='.urlencode($relativepath) :
'');
1450 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>';
1453 if ($permonobject) {
1455 if (!empty($conf->dol_use_jmobile)) {
1458 if (empty($conf->use_javascript_ajax)) {
1461 if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) {
1464 print
'<a href="'.((($useinecm && $useinecm != 6) && $useajax) ?
'#' : ($url.
'?action=deletefile&token='.
newToken().
'&urlfile='.urlencode($filepath).$param)).
'" class="reposition deletefilelink" rel="'.$filepath.
'">'.
img_delete().
'</a>';
1468 if (empty($disablemove) && count($filearray) > 1) {
1469 if ($nboffiles > 1 && $conf->browser->layout !=
'phone') {
1470 print
'<td class="linecolmove tdlineupdown center">';
1472 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=up&rowid='.$line->id.
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
1474 if ($i < ($nboffiles - 1)) {
1475 print
'<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=down&rowid='.$line->id.
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
1479 print
'<td'.(($conf->browser->layout !=
'phone') ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'>';
1484 print
'<td class="right">';
1485 print
'<input type="hidden" name="ecmfileid" value="'.$filearray[$key][
'rowid'].
'">';
1486 print
'<input type="submit" class="button button-save" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
1487 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
1489 if (empty($disablemove) && count($filearray) > 1) {
1490 print
'<td class="right"></td>';
1498 if ($nboffiles == 0) {
1500 if (empty($disablemove) && count($filearray) > 1) {
1503 print
'<tr class="oddeven"><td colspan="'.$colspan.
'">';
1504 if (empty($textifempty)) {
1505 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
1507 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
1515 if ($nboflines > 1 && is_object($object)) {
1516 if (!empty($conf->use_javascript_ajax) && $permtoeditline) {
1517 $table_element_line =
'ecm_files';
1518 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1524 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline) {
1552 public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath =
'', $permissiontodelete = 1, $useinecm = 0, $textifempty =
'', $maxlength = 0, $url =
'', $addfilterfields = 0)
1555 global $user, $conf, $langs, $hookmanager,
$form;
1556 global $sortfield, $sortorder;
1557 global $search_doc_ref;
1558 global $dolibarr_main_url_root;
1560 dol_syslog(get_class($this).
'::list_of_autoecmfiles upload_dir='.$upload_dir.
' modulepart='.$modulepart);
1563 if (empty($useinecm) || $useinecm == 6) {
1567 $url = $_SERVER[
"PHP_SELF"];
1570 if (!empty($addfilterfields)) {
1571 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'">';
1572 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1573 print
'<input type="hidden" name="module" value="'.$modulepart.
'">';
1576 print
'<div class="div-table-responsive-no-min">';
1577 print
'<table width="100%" class="noborder">'.
"\n";
1579 if (!empty($addfilterfields)) {
1580 print
'<tr class="liste_titre nodrag nodrop">';
1581 print
'<td class="liste_titre"></td>';
1582 print
'<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1583 print
'<td class="liste_titre"></td>';
1584 print
'<td class="liste_titre"></td>';
1586 print
'<td class="liste_titre right">';
1587 $searchpicto =
$form->showFilterButtons();
1593 print
'<tr class="liste_titre">';
1594 $sortref =
"fullname";
1595 if ($modulepart ==
'invoice_supplier') {
1596 $sortref =
'level1name';
1606 $object_instance =
null;
1607 if ($modulepart ==
'company') {
1608 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1609 $object_instance =
new Societe($this->
db);
1610 } elseif ($modulepart ==
'invoice') {
1611 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1612 $object_instance =
new Facture($this->
db);
1613 } elseif ($modulepart ==
'invoice_supplier') {
1614 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1616 } elseif ($modulepart ==
'propal') {
1617 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
1618 $object_instance =
new Propal($this->
db);
1619 } elseif ($modulepart ==
'supplier_proposal') {
1620 include_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
1622 } elseif ($modulepart ==
'order') {
1623 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1625 } elseif ($modulepart ==
'order_supplier') {
1626 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1628 } elseif ($modulepart ==
'contract') {
1629 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1630 $object_instance =
new Contrat($this->
db);
1631 } elseif ($modulepart ==
'product') {
1632 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1633 $object_instance =
new Product($this->
db);
1634 } elseif ($modulepart ==
'tax') {
1635 include_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
1637 } elseif ($modulepart ==
'tax-vat') {
1638 include_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
1639 $object_instance =
new Tva($this->
db);
1640 } elseif ($modulepart ==
'salaries') {
1641 include_once DOL_DOCUMENT_ROOT.
'/salaries/class/salary.class.php';
1642 $object_instance =
new Salary($this->
db);
1643 } elseif ($modulepart ==
'project') {
1644 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1645 $object_instance =
new Project($this->
db);
1646 } elseif ($modulepart ==
'project_task') {
1647 include_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
1648 $object_instance =
new Task($this->
db);
1649 } elseif ($modulepart ==
'fichinter') {
1650 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
1652 } elseif ($modulepart ==
'user') {
1653 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1654 $object_instance =
new User($this->
db);
1655 } elseif ($modulepart ==
'expensereport') {
1656 include_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1658 } elseif ($modulepart ==
'holiday') {
1659 include_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
1660 $object_instance =
new Holiday($this->
db);
1661 } elseif ($modulepart ==
'recruitment-recruitmentcandidature') {
1662 include_once DOL_DOCUMENT_ROOT.
'/recruitment/class/recruitmentcandidature.class.php';
1664 } elseif ($modulepart ==
'banque') {
1665 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1666 $object_instance =
new Account($this->
db);
1667 } elseif ($modulepart ==
'chequereceipt') {
1668 include_once DOL_DOCUMENT_ROOT.
'/compta/paiement/cheque/class/remisecheque.class.php';
1670 } elseif ($modulepart ==
'mrp-mo') {
1671 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
1672 $object_instance =
new Mo($this->
db);
1674 $parameters = array(
'modulepart'=>$modulepart);
1675 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
1676 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
1677 if (array_key_exists(
'classpath', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classpath'])) {
1679 if (array_key_exists(
'classname', $hookmanager->resArray) && !empty($hookmanager->resArray[
'classname'])) {
1680 if (class_exists($hookmanager->resArray[
'classname'])) {
1681 $tmpclassname = $hookmanager->resArray[
'classname'];
1682 $object_instance =
new $tmpclassname($this->
db);
1693 $relativepathfromroot = preg_replace(
'/'.preg_quote(DOL_DATA_ROOT.
'/',
'/').
'/',
'', $upload_dir);
1694 if ($relativepathfromroot) {
1698 if ($sortfield && $sortorder) {
1699 $filearray =
dol_sort_array($filearray, $sortfield, $sortorder, 1);
1705 foreach ($filearray as $key => $file) {
1706 if (!is_dir($file[
'name'])
1707 && $file[
'name'] !=
'.'
1708 && $file[
'name'] !=
'..'
1709 && $file[
'name'] !=
'CVS'
1710 && !preg_match(
'/\.meta$/i', $file[
'name'])) {
1712 $relativefile = preg_replace(
'/'.preg_quote($upload_dir.
'/',
'/').
'/',
'', $file[
'fullname']);
1720 if ($modulepart ==
'company' || $modulepart ==
'tax' || $modulepart ==
'tax-vat' || $modulepart ==
'salaries') {
1721 preg_match(
'/(\d+)\/[^\/]+$/', $relativefile, $reg);
1722 $id = (isset($reg[1]) ? $reg[1] :
'');
1723 } elseif ($modulepart ==
'invoice_supplier') {
1724 preg_match(
'/([^\/]+)\/[^\/]+$/', $relativefile, $reg);
1725 $ref = (isset($reg[1]) ? $reg[1] :
'');
1726 if (is_numeric($ref)) {
1730 } elseif ($modulepart ==
'user') {
1732 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
1733 $id = (isset($reg[1]) ? $reg[1] :
'');
1734 } elseif ($modulepart ==
'project_task') {
1736 $reg = explode(
"/", $relativefile);
1737 $ref = (isset($reg[1]) ? $reg[1] :
'');
1738 } elseif (in_array($modulepart, array(
1741 'supplier_proposal',
1750 'recruitment-recruitmentcandidature',
1755 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg);
1756 $ref = (isset($reg[1]) ? $reg[1] :
'');
1758 $parameters = array(
'modulepart'=>$modulepart,
'fileinfo'=>$file);
1759 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
1760 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
1761 if (array_key_exists(
'ref', $hookmanager->resArray) && !empty($hookmanager->resArray[
'ref'])) {
1762 $ref = $hookmanager->resArray[
'ref'];
1764 if (array_key_exists(
'id', $hookmanager->resArray) && !empty($hookmanager->resArray[
'id'])) {
1765 $id = $hookmanager->resArray[
'id'];
1771 if (!$id && !$ref) {
1776 if (!empty($this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref])) {
1782 if (is_object($object_instance)) {
1784 $result = $object_instance->fetch($id);
1786 if (!($result = $object_instance->fetch(
'', $ref))) {
1792 $result = $object_instance->fetchOneLike($ref);
1799 $this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref] = clone $object_instance;
1803 $this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref] =
'notfound';
1804 unset($filearray[$key]);
1808 if ($found <= 0 || !is_object($this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref])) {
1812 print
'<!-- Line list_of_autoecmfiles key='.$key.
' -->'.
"\n";
1813 print
'<tr class="oddeven">';
1815 if ($found > 0 && is_object($this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref])) {
1816 $tmpobject = $this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref];
1818 print $tmpobject->getNomUrl(1,
'document');
1823 print $langs->trans(
"ObjectDeleted", ($id ? $id : $ref));
1839 print
'<a href="'.DOL_URL_ROOT.
'/document.php?modulepart='.urlencode($modulepart);
1840 if ($forcedownload) {
1841 print
'&attachment=1';
1843 print
'&file='.urlencode($relativefile).
'">';
1845 print
dol_trunc($file[
'name'], $maxlength,
'middle');
1850 print $this->
showPreview($file, $modulepart, $file[
'relativename']);
1857 print
'<td class="right nowraponall">';
1858 if ($sizetoshow == $sizetoshowbytes) {
1861 print
$form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1866 print
'<td class="center">'.dol_print_date($file[
'date'],
"dayhour").
'</td>';
1869 print
'<td class="right">';
1870 if (!empty($file[
'share'])) {
1872 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1873 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1879 if (!empty($file[
'share'])) {
1880 $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
1882 if ($forcedownload) {
1883 $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1886 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1888 print
img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
1889 print
'<input type="text" class="quatrevingtpercent width100 nopadding nopadding small" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
1903 if (count($filearray) == 0) {
1904 print
'<tr class="oddeven"><td colspan="5">';
1905 if (empty($textifempty)) {
1906 print
'<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
1908 print
'<span class="opacitymedium">'.$textifempty.
'</span>';
1915 if (!empty($addfilterfields)) {
1930 global $langs, $conf;
1933 $post_max_size = ini_get(
'post_max_size');
1934 $mul_post_max_size = substr($post_max_size, -1);
1935 $mul_post_max_size = ($mul_post_max_size ==
'M' ? 1048576 : ($mul_post_max_size ==
'K' ? 1024 : ($mul_post_max_size ==
'G' ? 1073741824 : 1)));
1936 $post_max_size = $mul_post_max_size * (int) $post_max_size;
1938 $upload_max_filesize = ini_get(
'upload_max_filesize');
1939 $mul_upload_max_filesize = substr($upload_max_filesize, -1);
1940 $mul_upload_max_filesize = ($mul_upload_max_filesize ==
'M' ? 1048576 : ($mul_upload_max_filesize ==
'K' ? 1024 : ($mul_upload_max_filesize ==
'G' ? 1073741824 : 1)));
1941 $upload_max_filesize = $mul_upload_max_filesize * (int) $upload_max_filesize;
1943 $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize);
1946 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajax/fileupload_main.tpl.php';
1949 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajax/fileupload_view.tpl.php';
1962 public function listOfLinks($object, $permissiontodelete = 1, $action =
null, $selected =
null, $param =
'')
1964 global $user, $conf, $langs, $user;
1965 global $sortfield, $sortorder;
1967 $langs->load(
"link");
1969 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
1970 $link =
new Link($this->
db);
1972 if ($sortfield ==
"name") {
1973 $sortfield =
"label";
1974 } elseif ($sortfield ==
"date") {
1975 $sortfield =
"datea";
1979 $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder);
1980 $param .= (isset($object->id) ?
'&id='.$object->id :
'');
1982 print
'<!-- listOfLinks -->'.
"\n";
1985 print
load_fiche_titre($langs->trans(
"LinkedFiles"),
'',
'link', 0,
'',
'table-list-of-links');
1987 print
'<form action="'.$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
'').
'" method="POST">';
1988 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1990 print
'<table class="liste noborder nobottom centpercent">';
1991 print
'<tr class="liste_titre">';
1993 $langs->trans(
"Links"),
1994 $_SERVER[
'PHP_SELF'],
2015 $langs->trans(
"Date"),
2016 $_SERVER[
'PHP_SELF'],
2027 $_SERVER[
'PHP_SELF'],
2038 $nboflinks = count($links);
2039 if ($nboflinks > 0) {
2040 include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
2043 foreach ($links as $link) {
2044 print
'<tr class="oddeven">';
2046 if ($action ==
'update' && $selected === $link->id) {
2048 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2049 print
'<input type="hidden" name="linkid" value="'.$link->id.
'">';
2050 print
'<input type="hidden" name="action" value="confirm_updateline">';
2051 print $langs->trans(
'Link').
': <input type="text" name="link" value="'.$link->url.
'">';
2054 print $langs->trans(
'Label').
': <input type="text" name="label" value="'.
dol_escape_htmltag($link->label).
'">';
2056 print
'<td class="center">'.dol_print_date(
dol_now(),
"dayhour",
"tzuser").
'</td>';
2057 print
'<td class="right"></td>';
2058 print
'<td class="right">';
2059 print
'<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2060 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2065 print
'<a data-ajax="false" href="'.$link->url.
'" target="_blank" rel="noopener noreferrer">';
2069 print
'<td class="right"></td>';
2070 print
'<td class="center">'.dol_print_date($link->datea,
"dayhour",
"tzuser").
'</td>';
2071 print
'<td class="center"></td>';
2072 print
'<td class="right">';
2073 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?action=update&linkid='.$link->id.$param.
'&token='.
newToken().
'" class="editfilelink editfielda reposition" >'.
img_edit().
'</a>';
2074 if ($permissiontodelete) {
2075 print
' <a class="deletefilelink reposition" href="'.$_SERVER[
'PHP_SELF'].
'?action=deletelink&token='.
newToken().
'&linkid='.((int) $link->id).$param.
'">'.
img_delete().
'</a>';
2083 if ($nboflinks == 0) {
2084 print
'<tr class="oddeven"><td colspan="5">';
2085 print
'<span class="opacitymedium">'.$langs->trans(
"NoLinkFound").
'</span>';
2106 public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0, $param =
'')
2108 global $langs, $conf;
2111 if ($conf->browser->layout !=
'phone' && !empty($conf->use_javascript_ajax)) {
2113 if (count($urladvancedpreview)) {
2114 $out .=
'<a class="pictopreview '.$urladvancedpreview[
'css'].
'" href="'.$urladvancedpreview[
'url'].
'"'.(empty($urladvancedpreview[
'mime']) ?
'' :
' mime="'.$urladvancedpreview[
'mime'].
'"').
' '.(empty($urladvancedpreview[
'target']) ?
'' :
' target="'.$urladvancedpreview[
'target'].
'"').
'>';
2116 if (empty($ruleforpicto)) {
2118 $out .=
'<span class="fa fa-search-plus pictofixedwidth" style="color: gray"></span>';
2120 $out .=
img_mime($relativepath, $langs->trans(
'Preview').
' '.$file[
'name'],
'pictofixedwidth');
2124 if ($ruleforpicto < 0) {
2125 $out .=
img_picto(
'',
'generic',
'',
false, 0, 0,
'',
'paddingright pictofixedwidth');