57 $this->numoffiles = 0;
85 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)
88 global $conf, $langs, $hookmanager;
89 $hookmanager->initHooks(array(
'formfile'));
93 dol_syslog(__METHOD__.
": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
96 if (!empty($conf->browser->layout) && $conf->browser->layout !=
'classic') $useajax = 0;
98 if ((!empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) && $useajax) || ($useajax == 2))
107 if (!$perm && !empty($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) {
111 $out =
"\n\n".
'<!-- Start form attach new file --><div class="formattachnewfile">'.
"\n";
113 if (empty($title)) $title = $langs->trans(
"AttachANewFile");
116 if (empty($usewithoutform))
119 $url .= (strpos($url,
'?') ===
false ?
'?' :
'&').
'uploadform=1';
121 $out .=
'<form name="'.$htmlname.
'" id="'.$htmlname.
'" action="'.$url.
'" enctype="multipart/form-data" method="POST">';
122 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
123 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_dir" name="section_dir" value="'.$sectiondir.
'">';
124 $out .=
'<input type="hidden" id="'.$htmlname.
'_section_id" name="section_id" value="'.$sectionid.
'">';
125 $out .=
'<input type="hidden" name="sortfield" value="'.GETPOST(
'sortfield',
'aZ09comma').
'">';
126 $out .=
'<input type="hidden" name="sortorder" value="'.GETPOST(
'sortorder',
'aZ09').
'">';
129 $out .=
'<table class="nobordernopadding centpercent">';
132 if (!empty($options)) $out .=
'<td>'.$options.
'</td>';
134 $out .=
'<td class="valignmiddle nowrap">';
136 $max = $conf->global->MAIN_UPLOAD_DOC;
137 $maxphp = @ini_get(
'upload_max_filesize');
138 if (preg_match(
'/k$/i', $maxphp)) $maxphp = $maxphp * 1;
139 if (preg_match(
'/m$/i', $maxphp)) $maxphp = $maxphp * 1024;
140 if (preg_match(
'/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024;
141 if (preg_match(
'/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024;
142 $maxphp2 = @ini_get(
'post_max_size');
143 if (preg_match(
'/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1;
144 if (preg_match(
'/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024;
145 if (preg_match(
'/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024;
146 if (preg_match(
'/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
149 $maxphptoshow = $maxphptoshowparam =
'';
152 $maxmin = min($max, $maxphp);
153 $maxphptoshow = $maxphp;
154 $maxphptoshowparam =
'upload_max_filesize';
158 $maxmin = min($max, $maxphp2);
159 if ($maxphp2 < $maxphp)
161 $maxphptoshow = $maxphp2;
162 $maxphptoshowparam =
'post_max_size';
169 $out .=
'<input type="hidden" name="max_file_size" value="'.($maxmin * 1024).
'">';
172 $out .=
'<input class="flat minwidth400 maxwidth200onsmartphone" type="file"';
174 $out .= ((!empty($conf->global->MAIN_DISABLE_MULTIPLE_FILEUPLOAD) || $disablemulti) ?
' name="userfile"' :
' name="userfile[]" multiple');
175 $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ?
' disabled' :
'');
176 $out .= (!empty($accept) ?
' accept="'.$accept.
'"' :
' accept=""');
177 $out .= (!empty($capture) ?
' capture="capture"' :
'');
181 $langs->load(
'link');
182 $out .=
'<input style="margin-right: 2px;" type="checkbox" id="overwritefile" name="overwritefile" value="1"><label for="overwritefile">'.$langs->trans(
"OverwriteIfExists").
'</label>';
184 $out .=
'<input type="submit" class="button reposition" name="sendit" value="'.$langs->trans(
"Upload").
'"';
185 $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ?
' disabled' :
'');
191 $out .=
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
194 if (!empty($conf->global->MAIN_UPLOAD_DOC))
198 $langs->load(
'other');
200 $out .=
info_admin($langs->trans(
"ThisLimitIsDefinedInSetup", $max, $maxphptoshow), 1);
203 $out .=
' ('.$langs->trans(
"UploadDisabled").
')';
205 $out .=
"</td></tr>";
210 $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ?
'checked' :
'');
213 if (!empty($options)) $out .=
'<td>'.$options.
'</td>';
214 $out .=
'<td valign="middle" class="nowrap">';
215 $out .=
'<input type="checkbox" '.$rename.
' class="savingdocmask" name="savingdocmask" value="'.
dol_escape_js($savingdocmask).
'"> ';
216 $out .=
'<span class="opacitymedium">';
217 $out .= $langs->trans(
"SaveUploadedFileWithMask", preg_replace(
'/__file__/', $langs->transnoentitiesnoconv(
"OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv(
"OriginFileName"));
225 if (empty($usewithoutform))
228 if (empty($sectionid)) $out .=
'<br>';
231 $out .=
"\n</div><!-- End form attach new file -->\n";
235 $out .=
"\n".
'<!-- Start form link new url --><div class="formlinknewurl">'.
"\n";
236 $langs->load(
'link');
237 $title = $langs->trans(
"LinkANewFile");
240 if (empty($usewithoutform))
242 $out .=
'<form name="'.$htmlname.
'_link" id="'.$htmlname.
'_link" action="'.$url.
'" method="POST">'.
"\n";
243 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">'.
"\n";
244 $out .=
'<input type="hidden" id="'.$htmlname.
'_link_section_dir" name="link_section_dir" value="">'.
"\n";
245 $out .=
'<input type="hidden" id="'.$htmlname.
'_link_section_id" name="link_section_id" value="'.$sectionid.
'">'.
"\n";
248 $out .=
'<div class="valignmiddle">';
249 $out .=
'<div class="inline-block" style="padding-right: 10px;">';
250 if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .=
'<label for="link">'.$langs->trans(
"URLToLink").
':</label> ';
251 $out .=
'<input type="text" name="link" class="flat minwidth400imp" id="link" placeholder="'.dol_escape_htmltag($langs->trans(
"URLToLink")).
'">';
253 $out .=
'<div class="inline-block" style="padding-right: 10px;">';
254 if (!empty($conf->global->OPTIMIZEFORTEXTBROWSER)) $out .=
'<label for="label">'.$langs->trans(
"Label").
':</label> ';
255 $out .=
'<input type="text" class="flat" name="label" id="label" placeholder="'.dol_escape_htmltag($langs->trans(
"Label")).
'">';
256 $out .=
'<input type="hidden" name="objecttype" value="'.$object->element.
'">';
257 $out .=
'<input type="hidden" name="objectid" value="'.$object->id.
'">';
259 $out .=
'<div class="inline-block" style="padding-right: 10px;">';
260 $out .=
'<input type="submit" class="button" name="linkit" value="'.$langs->trans(
"ToLink").
'"';
261 $out .= (empty($conf->global->MAIN_UPLOAD_DOC) || empty($perm) ?
' disabled' :
'');
265 if (empty($usewithoutform))
267 $out .=
'<div class="clearboth"></div>';
268 $out .=
'</form><br>';
271 $out .=
"\n</div><!-- End form link new url -->\n";
274 $parameters = array(
'socid'=>(isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id'=>(isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'url'=>$url,
'perm'=>$perm);
275 $res = $hookmanager->executeHooks(
'formattachOptions', $parameters, $object);
278 print '<div class="'.($usewithoutform ?
'inline-block valignmiddle' :
'attacharea attacharea'.$htmlname).
'">';
282 print $hookmanager->resPrint;
311 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 =
'')
314 $this->numoffiles = 0;
315 print $this->
showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
316 return $this->numoffiles;
345 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')
348 if (!empty($iconPDF)) {
349 dol_syslog(__METHOD__.
": passing iconPDF parameter is deprecated", LOG_WARNING);
352 global $langs, $conf, $user, $hookmanager;
355 if (!is_object($form)) $form =
new Form($this->
db);
357 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
360 if (!empty($iconPDF)) {
365 if (!preg_match(
'/entity\=[0-9]+/', $param)) {
366 $param .= ($param ?
'&' :
'').
'entity='.(!empty($object->entity) ? $object->entity : $conf->entity);
370 if (in_array($modulepart, array(
'facture',
'supplier_proposal',
'propal',
'proposal',
'order',
'commande',
'expedition',
'commande_fournisseur',
'expensereport',
'delivery',
'ticket')))
372 $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ?
true:
false;
375 $hookmanager->initHooks(array(
'formfile'));
379 if (!empty($filedir))
381 $file_list =
dol_dir_list($filedir,
'files', 0,
'',
'(\.meta|_preview.*.*\.png)$',
'date', SORT_DESC);
383 if ($hideifempty && empty($file_list))
return '';
386 $forname =
'builddoc';
391 $out .=
"\n".
'<!-- Start show_document -->'.
"\n";
394 if (preg_match(
'/massfilesarea_/', $modulepart))
396 $out .=
'<div id="show_files"><br></div>'.
"\n";
397 $title = $langs->trans(
"MassFilesArea").
' <a href="" id="togglemassfilesarea" ref="shown">('.$langs->trans(
"Hide").
')</a>';
399 jQuery(document).ready(function() {
400 jQuery(\'#togglemassfilesarea\').click(function() {
401 if (jQuery(\'#togglemassfilesarea\').attr(\'ref\') == "shown")
403 jQuery(\'#'.$modulepart.
'_table\').hide();
404 jQuery(\'#togglemassfilesarea\').attr("ref", "hidden");
405 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Show")).
')");
409 jQuery(\'#'.$modulepart.
'_table\').show();
410 jQuery(\'#togglemassfilesarea\').attr("ref","shown");
411 jQuery(\'#togglemassfilesarea\').text("('.
dol_escape_js($langs->trans(
"Hide")).
')");
419 $titletoshow = $langs->trans(
"Documents");
420 if (!empty($title)) $titletoshow = ($title ==
'none' ?
'' : $title);
425 $modellist = array();
427 if ($modulepart ==
'company')
430 if (is_array($genallowed)) $modellist = $genallowed;
432 include_once DOL_DOCUMENT_ROOT.
'/core/modules/societe/modules_societe.class.php';
435 } elseif ($modulepart ==
'propal')
437 if (is_array($genallowed)) $modellist = $genallowed;
439 include_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
442 } elseif ($modulepart ==
'supplier_proposal')
444 if (is_array($genallowed)) $modellist = $genallowed;
446 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
449 } elseif ($modulepart ==
'commande')
451 if (is_array($genallowed)) $modellist = $genallowed;
453 include_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
456 } elseif ($modulepart ==
'expedition')
458 if (is_array($genallowed)) $modellist = $genallowed;
460 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expedition/modules_expedition.php';
461 $modellist = ModelePDFExpedition::liste_modeles($this->
db);
463 } elseif ($modulepart ==
'reception')
465 if (is_array($genallowed)) $modellist = $genallowed;
467 include_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
470 } elseif ($modulepart ==
'delivery')
472 if (is_array($genallowed)) $modellist = $genallowed;
474 include_once DOL_DOCUMENT_ROOT.
'/core/modules/delivery/modules_delivery.php';
477 } elseif ($modulepart ==
'ficheinter')
479 if (is_array($genallowed)) $modellist = $genallowed;
481 include_once DOL_DOCUMENT_ROOT.
'/core/modules/fichinter/modules_fichinter.php';
484 } elseif ($modulepart ==
'facture')
486 if (is_array($genallowed)) $modellist = $genallowed;
488 include_once DOL_DOCUMENT_ROOT.
'/core/modules/facture/modules_facture.php';
491 } elseif ($modulepart ==
'contract')
494 if (is_array($genallowed)) $modellist = $genallowed;
496 include_once DOL_DOCUMENT_ROOT.
'/core/modules/contract/modules_contract.php';
499 } elseif ($modulepart ==
'project')
501 if (is_array($genallowed)) $modellist = $genallowed;
503 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
506 } elseif ($modulepart ==
'project_task')
508 if (is_array($genallowed)) $modellist = $genallowed;
510 include_once DOL_DOCUMENT_ROOT.
'/core/modules/project/task/modules_task.php';
513 } elseif ($modulepart ==
'product')
515 if (is_array($genallowed)) $modellist = $genallowed;
517 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
520 } elseif ($modulepart ==
'product_batch')
522 if (is_array($genallowed)) $modellist = $genallowed;
524 include_once DOL_DOCUMENT_ROOT.
'/core/modules/product_batch/modules_product_batch.class.php';
527 } elseif ($modulepart ==
'stock')
529 if (is_array($genallowed)) $modellist = $genallowed;
531 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_stock.php';
534 } elseif ($modulepart ==
'movement')
536 if (is_array($genallowed)) $modellist = $genallowed;
538 include_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_movement.php';
541 } elseif ($modulepart ==
'export')
543 if (is_array($genallowed)) $modellist = $genallowed;
545 include_once DOL_DOCUMENT_ROOT.
'/core/modules/export/modules_export.php';
548 } elseif ($modulepart ==
'commande_fournisseur' || $modulepart ==
'supplier_order')
550 if (is_array($genallowed)) $modellist = $genallowed;
552 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_order/modules_commandefournisseur.php';
555 } elseif ($modulepart ==
'facture_fournisseur' || $modulepart ==
'supplier_invoice')
558 if (is_array($genallowed)) $modellist = $genallowed;
560 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_invoice/modules_facturefournisseur.php';
563 } elseif ($modulepart ==
'supplier_payment')
565 if (is_array($genallowed)) $modellist = $genallowed;
567 include_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_payment/modules_supplier_payment.php';
570 } elseif ($modulepart ==
'remisecheque')
572 if (is_array($genallowed)) $modellist = $genallowed;
574 include_once DOL_DOCUMENT_ROOT.
'/core/modules/cheque/modules_chequereceipts.php';
577 } elseif ($modulepart ==
'donation')
579 if (is_array($genallowed)) $modellist = $genallowed;
581 include_once DOL_DOCUMENT_ROOT.
'/core/modules/dons/modules_don.php';
584 } elseif ($modulepart ==
'member')
586 if (is_array($genallowed)) $modellist = $genallowed;
588 include_once DOL_DOCUMENT_ROOT.
'/core/modules/member/modules_cards.php';
591 } elseif ($modulepart ==
'agenda' || $modulepart ==
'actions')
593 if (is_array($genallowed)) $modellist = $genallowed;
595 include_once DOL_DOCUMENT_ROOT.
'/core/modules/action/modules_action.php';
598 } elseif ($modulepart ==
'expensereport')
600 if (is_array($genallowed)) $modellist = $genallowed;
602 include_once DOL_DOCUMENT_ROOT.
'/core/modules/expensereport/modules_expensereport.php';
605 } elseif ($modulepart ==
'unpaid')
608 } elseif ($modulepart ==
'user')
610 if (is_array($genallowed)) $modellist = $genallowed;
612 include_once DOL_DOCUMENT_ROOT.
'/core/modules/user/modules_user.class.php';
615 } elseif ($modulepart ==
'usergroup')
617 if (is_array($genallowed)) $modellist = $genallowed;
619 include_once DOL_DOCUMENT_ROOT.
'/core/modules/usergroup/modules_usergroup.class.php';
623 $submodulepart = $modulepart;
626 $tmp = explode(
':', $modulepart);
627 if (!empty($tmp[1])) {
628 $modulepart = $tmp[0];
629 $submodulepart = $tmp[1];
633 $file =
dol_buildpath(
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
634 if (file_exists($file))
636 $res = include_once $file;
640 $file =
dol_buildpath(
'/'.$modulepart.
'/core/modules/'.$modulepart.
'/modules_'.strtolower($submodulepart).
'.php', 0);
641 $res = include_once $file;
644 $class =
'ModelePDF'.$submodulepart;
646 if (class_exists($class))
648 $modellist = call_user_func($class.
'::liste_modeles', $this->db);
650 dol_print_error($this->
db,
"Bad value for modulepart '".$modulepart.
"' in showdocuments");
658 if (empty($buttonlabel)) $buttonlabel = $langs->trans(
'Generate');
660 if ($conf->browser->layout ==
'phone') $urlsource .=
'#'.$forname.
'_form';
661 if (empty($noform)) $out .=
'<form action="'.$urlsource.(empty($conf->global->MAIN_JUMP_TAG) ?
'' :
'#builddoc').
'" id="'.$forname.
'_form" method="post">';
662 $out .=
'<input type="hidden" name="action" value="builddoc">';
663 $out .=
'<input type="hidden" name="token" value="'.newToken().
'">';
666 $out .=
'<div class="div-table-responsive-no-min">';
667 $out .=
'<table class="liste formdoc noborder centpercent">';
669 $out .=
'<tr class="liste_titre">';
671 $addcolumforpicto = ($delallowed || $printer || $morepicto);
672 $colspan = (3 + ($addcolumforpicto ? 1 : 0)); $colspanmore = 0;
674 $out .=
'<th colspan="'.$colspan.
'" class="formdoc liste_titre maxwidthonsmartphone center">';
677 if (!empty($modellist))
680 $out .=
'<span class="hideonsmartphone">'.$langs->trans(
'Model').
' </span>';
681 if (is_array($modellist) && count($modellist) == 1)
683 $arraykeys = array_keys($modellist);
684 $modelselected = $arraykeys[0];
686 $morecss =
'maxwidth200';
687 if ($conf->browser->layout ==
'phone') $morecss =
'maxwidth100';
688 $out .= $form->selectarray(
'model', $modellist, $modelselected, $showempty, 0, 0,
'', 0, 0, 0,
'', $morecss);
689 if ($conf->use_javascript_ajax)
694 $out .=
'<div class="float">'.$langs->trans(
"Files").
'</div>';
698 if (($allowgenifempty || (is_array($modellist) && count($modellist) > 0)) && $conf->global->MAIN_MULTILANGS && !$forcenomultilang && (!empty($modellist) || $showempty))
700 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
702 $defaultlang = $codelang ? $codelang : $langs->getDefaultLang();
703 $morecss =
'maxwidth150';
704 if ($conf->browser->layout ==
'phone') $morecss =
'maxwidth100';
705 $out .= $formadmin->select_language($defaultlang,
'lang_id', 0, null, 0, 0, 0, $morecss);
711 $genbutton =
'<input class="button buttongen" id="'.$forname.
'_generatebutton" name="'.$forname.
'_generatebutton"';
712 $genbutton .=
' type="submit" value="'.$buttonlabel.
'"';
713 if (!$allowgenifempty && !is_array($modellist) && empty($modellist)) $genbutton .=
' disabled';
715 if ($allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid')
717 $langs->load(
"errors");
718 $genbutton .=
' '.img_warning($langs->transnoentitiesnoconv(
"WarningNoDocumentModelActivated"));
720 if (!$allowgenifempty && !is_array($modellist) && empty($modellist) && empty($conf->dol_no_mouse_hover) && $modulepart !=
'unpaid') $genbutton =
'';
721 if (empty($modellist) && !$showempty && $modulepart !=
'unpaid') $genbutton =
'';
725 if (!empty($hookmanager->hooks[
'formfile']))
727 foreach ($hookmanager->hooks[
'formfile'] as $module)
729 if (method_exists($module,
'formBuilddocLineOptions'))
739 $parameters = array(
'colspan'=>($colspan + $colspanmore),
'socid'=>(isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id'=>(isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart'=>$modulepart);
740 if (is_object($hookmanager))
742 $reshook = $hookmanager->executeHooks(
'formBuilddocOptions', $parameters, $GLOBALS[
'object']);
743 $out .= $hookmanager->resPrint;
748 if (!empty($filedir))
750 $link_list = array();
751 if (is_object($object))
753 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
754 $link =
new Link($this->
db);
755 $sortfield = $sortorder = null;
756 $res = $link->fetchAll($link_list, $object->element, $object->id, $sortfield, $sortorder);
759 $out .=
'<!-- html.formfile::showdocuments -->'.
"\n";
762 if ((!empty($file_list) || !empty($link_list) || preg_match(
'/^massfilesarea/', $modulepart))
766 $out .=
'<div class="titre">'.$titletoshow.
'</div>'.
"\n";
767 $out .=
'<div class="div-table-responsive-no-min">';
768 $out .=
'<table class="noborder centpercent" id="'.$modulepart.
'_table">'.
"\n";
772 if (is_array($file_list))
774 foreach ($file_list as $file)
777 $relativepath = $file[
"name"];
778 if ($modulesubdir) $relativepath = $modulesubdir.
"/".$file[
"name"];
779 if ($modulepart ==
'export') $relativepath = $file[
"name"];
781 $out .=
'<tr class="oddeven">';
783 $documenturl = DOL_URL_ROOT.
'/document.php';
784 if (isset($conf->global->DOL_URL_ROOT_DOCUMENT_PHP)) $documenturl = $conf->global->DOL_URL_ROOT_DOCUMENT_PHP;
787 $out .=
'<td class="minwidth200">';
788 $out .=
'<a class="documentdownload paddingright" href="'.$documenturl.
'?modulepart='.$modulepart.
'&file='.urlencode($relativepath).($param ?
'&'.$param :
'').
'"';
791 if (preg_match(
'/text/', $mime)) $out .=
' target="_blank"';
793 $out .=
img_mime($file[
"name"], $langs->trans(
"File").
': '.$file[
"name"]);
796 $out .= $this->
showPreview($file, $modulepart, $relativepath, 0, $param);
800 $size = (!empty($file[
'size']) ? $file[
'size'] :
dol_filesize($filedir.
"/".$file[
"name"]));
801 $out .=
'<td class="nowrap right">'.dol_print_size($size, 1, 1).
'</td>';
804 $date = (!empty($file[
'date']) ? $file[
'date'] :
dol_filemtime($filedir.
"/".$file[
"name"]));
805 $out .=
'<td class="nowrap right">'.dol_print_date($date,
'dayhour',
'tzuser').
'</td>';
807 if ($delallowed || $printer || $morepicto)
809 $out .=
'<td class="right nowraponall">';
812 $tmpurlsource = preg_replace(
'/#[a-zA-Z0-9_]*$/',
'', $urlsource);
813 $out .=
'<a href="'.$tmpurlsource.((strpos($tmpurlsource,
'?') ===
false) ?
'?' :
'&').
'action='.$removeaction.
'&file='.urlencode($relativepath);
814 $out .= ($param ?
'&'.$param :
'');
817 $out .=
'">'.img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
822 $out .=
'<a class="marginleftonly" href="'.$urlsource.(strpos($urlsource,
'?') ?
'&' :
'?').
'action=print_file&printer='.$modulepart.
'&file='.urlencode($relativepath);
823 $out .= ($param ?
'&'.$param :
'');
824 $out .=
'">'.img_picto($langs->trans(
"PrintFile", $relativepath),
'printer.png').
'</a>';
828 $morepicto = preg_replace(
'/__FILENAMEURLENCODED__/', urlencode($relativepath), $morepicto);
834 if (is_object($hookmanager))
836 $parameters = array(
'colspan'=>($colspan + $colspanmore),
'socid'=>(isset($GLOBALS[
'socid']) ? $GLOBALS[
'socid'] :
''),
'id'=>(isset($GLOBALS[
'id']) ? $GLOBALS[
'id'] :
''),
'modulepart'=>$modulepart,
'relativepath'=>$relativepath);
837 $res = $hookmanager->executeHooks(
'formBuilddocLineOptions', $parameters, $file);
840 $out .= $hookmanager->resPrint;
843 $out = $hookmanager->resPrint;
851 if (is_array($link_list))
855 foreach ($link_list as $file)
857 $out .=
'<tr class="oddeven">';
858 $out .=
'<td colspan="'.$colspan.
'" class="maxwidhtonsmartphone">';
859 $out .=
'<a data-ajax="false" href="'.$file->url.
'" target="_blank">';
860 $out .= $file->label;
863 $out .=
'<td class="right">';
866 if ($delallowed || $printer || $morepicto) $out .=
'<td></td>';
867 $out .=
'</tr>'.
"\n";
872 if (count($file_list) == 0 && count($link_list) == 0 && $headershown)
874 $out .=
'<tr><td colspan="'.(3 + ($addcolumforpicto ? 1 : 0)).
'" class="opacitymedium">'.$langs->trans(
"None").
'</td></tr>'.
"\n";
881 $out .=
"</table>\n";
885 if (empty($noform)) $out .=
'</form>'.
"\n";
888 $out .=
'<!-- End show_document -->'.
"\n";
906 global $conf, $langs;
908 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
911 $this->infofiles = array(
'nboffiles'=>0,
'extensions'=>array(),
'files'=>array());
916 if (!empty($conf->multicompany->enabled))
919 preg_match(
'/\/([0-9]+)\/[^\/]+\/'.preg_quote($modulesubdir,
'/').
'$/', $filedir, $regs);
920 $entity = ((!empty($regs[1]) && $regs[1] > 1) ? $regs[1] : 1);
925 if (!empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP))
927 $filterforfilesearch = preg_quote(basename($modulesubdir),
'/');
929 $filterforfilesearch = preg_quote(basename($modulesubdir),
'/').
'[^\-]+';
931 $file_list =
dol_dir_list($filedir,
'files', 0, $filterforfilesearch,
'\.meta$|\.png$');
935 $out .=
'<!-- html.formfile::getDocumentsLink -->'.
"\n";
936 if (!empty($file_list))
938 $out =
'<dl class="dropdown inline-block">
939 <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto(
'',
'listlight',
'', 0, 0, 0,
'',
'valignmiddle').
'</a></dt>
940 <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
945 foreach ($file_list as $file)
948 if ($filter && !preg_match(
'/'.$filter.
'/i', $file[
"name"]))
continue;
952 $relativepath = $file[
"name"];
953 if ($modulesubdir) $relativepath = $modulesubdir.
"/".$file[
"name"];
955 if ($modulepart ==
'donation') {
956 $relativepath =
get_exdir($modulesubdir, 2, 0, 0, null,
'donation').$file[
"name"];
958 if ($modulepart ==
'export') {
959 $relativepath = $file[
"name"];
962 $this->infofiles[
'nboffiles']++;
963 $this->infofiles[
'files'][] = $file[
'fullname'];
964 $ext = pathinfo($file[
"name"], PATHINFO_EXTENSION);
965 if (empty($this->infofiles[$ext])) $this->infofiles[
'extensions'][$ext] = 1;
966 else $this->infofiles[
'extensions'][$ext]++;
969 if (!empty($conf->use_javascript_ajax) && ($conf->browser->layout !=
'phone'))
972 if ($tmparray && $tmparray[
'url'])
974 $tmpout .=
'<li><a href="'.$tmparray[
'url'].
'"'.($tmparray[
'css'] ?
' class="'.$tmparray[
'css'].
'"' :
'').($tmparray[
'mime'] ?
' mime="'.$tmparray[
'mime'].
'"' :
'').($tmparray[
'target'] ?
' target="'.$tmparray[
'target'].
'"' :
'').
'>';
976 $tmpout .=
'<i class="fa fa-search-plus paddingright" style="color: gray"></i>';
977 $tmpout .= $langs->trans(
"Preview").
' '.$ext.
'</a></li>';
982 $tmpout .=
'<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart.
'&entity='.$entity.
'&file='.urlencode($relativepath).
'"';
984 if (preg_match(
'/text/', $mime)) $tmpout .=
' target="_blank"';
986 $tmpout .=
img_mime($relativepath, $file[
"name"]);
987 $tmpout .= $langs->trans(
"Download").
' '.$ext;
988 $tmpout .=
'</a></li>'.
"\n";
991 $out .=
'</ul></div></dd>
994 if (!$found) $out =
'';
1037 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)
1040 global $user, $conf, $langs, $hookmanager, $form;
1041 global $sortfield, $sortorder, $maxheightmini;
1042 global $dolibarr_main_url_root;
1044 if ($disablecrop == -1)
1048 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'))) $disablecrop = 0;
1052 if (empty($relativepath))
1055 if ($object->element ==
'invoice_supplier') $relativepath =
get_exdir($object->id, 2, 0, 0, $object,
'invoice_supplier').$relativepath;
1056 if ($object->element ==
'project_task') $relativepath =
'Call_not_supported_._Call_function_using_a_defined_relative_path_.';
1059 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0][
'level1name'] ==
'photos')
1061 $relativepath = preg_replace(
'/^.*\/produit\//',
'', $filearray[0][
'path']).
'/';
1067 $relativedir = preg_replace(
'/^'.preg_quote(DOL_DATA_ROOT,
'/').
'/',
'', $upload_dir);
1068 $relativedir = preg_replace(
'/^[\\/]/',
'', $relativedir);
1073 $hookmanager->initHooks(array(
'formfile'));
1074 $parameters = array(
1075 'filearray' => $filearray,
1076 'modulepart'=> $modulepart,
1078 'forcedownload' => $forcedownload,
1079 'relativepath' => $relativepath,
1080 'relativedir' => $relativedir,
1081 'permtodelete' => $permonobject,
1082 'useinecm' => $useinecm,
1083 'textifempty' => $textifempty,
1084 'maxlength' => $maxlength,
1088 $reshook = $hookmanager->executeHooks(
'showFilesList', $parameters, $object);
1090 if (isset($reshook) && $reshook !=
'')
1094 if (!is_object($form))
1096 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
1097 $form =
new Form($this->
db);
1100 if (!preg_match(
'/&id=/', $param) && isset($object->id)) $param .=
'&id='.$object->id;
1101 $relativepathwihtoutslashend = preg_replace(
'/\/$/',
'', $relativepath);
1102 if ($relativepathwihtoutslashend) $param .=
'&file='.urlencode($relativepathwihtoutslashend);
1104 if ($permtoeditline < 0)
1106 $permtoeditline = 0;
1107 if (in_array($modulepart, array(
'product',
'produit',
'service')))
1113 if (empty($conf->global->MAIN_UPLOAD_DOC))
1115 $permtoeditline = 0;
1120 if ((empty($useinecm) || $useinecm == 6) && $title !=
'none')
print load_fiche_titre($title ? $title : $langs->trans(
"AttachedFiles"),
'',
'file-upload', 0,
'',
'table-list-of-attached-files');
1121 if (empty($url)) $url =
$_SERVER[
"PHP_SELF"];
1123 print '<!-- html.formfile::list_of_documents -->'.
"\n";
1124 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline)
1126 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?'.$param.
'" method="POST">';
1127 print '<input type="hidden" name="token" value="'.newToken().
'">';
1128 print '<input type="hidden" name="action" value="renamefile">';
1129 print '<input type="hidden" name="id" value="'.$object->id.
'">';
1130 print '<input type="hidden" name="modulepart" value="'.$modulepart.
'">';
1133 print '<div class="div-table-responsive-no-min">';
1134 print '<table width="100%" id="tablelines" class="liste noborder nobottom">'.
"\n";
1136 if (!empty($addfilterfields))
1138 print '<tr class="liste_titre nodrag nodrop">';
1139 print '<td><input type="search_doc_ref" value="'.dol_escape_htmltag(
GETPOST(
'search_doc_ref',
'alpha')).
'"></td>';
1142 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6)
print '<td></td>';
1145 if (!$disablemove)
print '<td></td>';
1149 print '<tr class="liste_titre nodrag nodrop">';
1154 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6)
print_liste_field_titre(
'', $url,
"",
"", $param,
'', $sortfield, $sortorder,
'center ');
1166 if ($sortfield && $sortorder)
1172 $nboffiles = count($filearray);
1173 if ($nboffiles > 0) include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1175 $i = 0; $nboflines = 0; $lastrowid = 0;
1176 foreach ($filearray as $key => $file)
1178 if ($file[
'name'] !=
'.'
1179 && $file[
'name'] !=
'..'
1180 && !preg_match(
'/\.meta$/i', $file[
'name']))
1182 if ($filearray[$key][
'rowid'] > 0) $lastrowid = $filearray[$key][
'rowid'];
1183 $filepath = $relativepath.$file[
'name'];
1187 print '<!-- Line list_of_documents '.$key.
' relativepath = '.$relativepath.
' -->'.
"\n";
1189 print '<!-- In database: position='.$filearray[$key][
'position'].
' -->'.
"\n";
1190 print '<tr class="oddeven" id="row-'.($filearray[$key][
'rowid'] > 0 ? $filearray[$key][
'rowid'] :
'AFTER'.$lastrowid.
'POS'.($i + 1)).
'">';
1193 print '<td class="minwith200">';
1197 print '<a class="paddingright" href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart;
1198 if ($forcedownload)
print '&attachment=1';
1199 if (!empty($object->entity))
print '&entity='.$object->entity;
1200 print '&file='.urlencode($filepath);
1202 print img_mime($file[
'name'], $file[
'name'].
' ('.
dol_print_size($file[
'size'], 0, 0).
')',
'inline-block valignbottom paddingright');
1203 if ($showrelpart == 1)
print $relativepath;
1205 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $file[
'name'] == basename(
GETPOST(
'urlfile',
'alpha')))
1208 $section_dir = dirname(
GETPOST(
'urlfile',
'alpha'));
1209 if (!preg_match(
'/\/$/', $section_dir)) $section_dir .=
'/';
1210 print '<input type="hidden" name="section_dir" value="'.$section_dir.
'">';
1211 print '<input type="hidden" name="renamefilefrom" value="'.dol_escape_htmltag($file[
'name']).
'">';
1212 print '<input type="text" name="renamefileto" class="quatrevingtpercent" value="'.dol_escape_htmltag($file[
'name']).
'">';
1215 $filenametoshow = preg_replace(
'/\.noexe$/',
'', $file[
'name']);
1220 if (!$editline)
print $this->
showPreview($file, $modulepart, $filepath, 0,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
1227 print '<td class="right nowraponall">';
1228 if ($sizetoshow == $sizetoshowbytes)
print $sizetoshow;
1230 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1235 print '<td class="center" style="width: 140px">'.dol_print_date($file[
'date'],
"dayhour",
"tzuser").
'</td>';
1238 if (empty($useinecm) || $useinecm == 4 || $useinecm == 5 || $useinecm == 6)
1240 $fileinfo = pathinfo($file[
'name']);
1241 print '<td class="center">';
1244 if ($useinecm == 5 || $useinecm == 6)
1253 $urlforhref =
getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']), 1,
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
1254 if (empty($urlforhref)) {
1255 $urlforhref = DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$fileinfo[
'filename'].
'.'.strtolower($fileinfo[
'extension']));
1256 print '<a href="'.$urlforhref.
'" class="aphoto" target="_blank">';
1258 print '<a href="'.$urlforhref[
'url'].
'" class="'.$urlforhref[
'css'].
'" target="'.$urlforhref[
'target'].
'" mime="'.$urlforhref[
'mime'].
'">';
1260 print '<img class="photo maxwidth200 shadow valignmiddle" height="'.(($useinecm == 4 || $useinecm == 5 || $useinecm == 6) ?
'12' : $maxheightmini).
'" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$modulepart.
'&entity='.(!empty($object->entity) ? $object->entity : $conf->entity).
'&file='.urlencode($relativepath.$smallfile).
'" title="">';
1262 }
else print ' ';
1267 print '<td class="center">';
1268 if ($relativedir && $filearray[$key][
'rowid'] > 0)
1272 print $langs->trans(
"FileSharedViaALink").
' ';
1273 print '<input class="inline-block" type="checkbox" name="shareenabled"'.($file[
'share'] ?
' checked="checked"' :
'').
' /> ';
1278 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1279 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1285 if (!empty($file[
'share'])) $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
1286 if ($forcedownload) $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1288 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1290 print img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
1291 print '<input type="text" class="quatrevingtpercent minwidth200imp" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
1304 print '<td class="valignmiddle right actionbuttons nowraponall"><!-- action on files -->';
1305 if ($useinecm == 1 || $useinecm == 5)
1308 $newparam .= preg_replace(
'/&file=.*$/',
'', $param);
1309 $backtopage = DOL_URL_ROOT.
'/ecm/index.php?§ion_dir='.urlencode($relativepath).$newparam;
1310 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>';
1313 if (empty($useinecm) || $useinecm == 2 || $useinecm == 6)
1315 $newmodulepart = $modulepart;
1316 if (in_array($modulepart, array(
'product',
'produit',
'service'))) $newmodulepart =
'produit|service';
1320 if ($permtoeditline)
1323 $moreparaminurl =
'';
1324 if ($object->id > 0) {
1325 $moreparaminurl =
'&id='.$object->id;
1326 } elseif (
GETPOST(
'website',
'alpha')) {
1327 $moreparaminurl =
'&website='.GETPOST(
'website',
'alpha');
1329 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>';
1333 if ($permtoeditline)
1335 $paramsectiondir = (in_array($modulepart, array(
'medias',
'ecm')) ?
'§ion_dir='.urlencode($relativepath) :
'');
1336 print '<a class="editfielda reposition editfilelink" href="'.(($useinecm == 1 || $useinecm == 5) ?
'#' : ($url.
'?action=editfile&urlfile='.urlencode($filepath).$paramsectiondir.$param)).
'" rel="'.$filepath.
'">'.
img_edit(
'default', 0,
'class="paddingrightonly"').
'</a>';
1342 if (!empty($conf->dol_use_jmobile)) $useajax = 0;
1343 if (empty($conf->use_javascript_ajax)) $useajax = 0;
1344 if (!empty($conf->global->MAIN_ECM_DISABLE_JS)) $useajax = 0;
1345 print '<a href="'.((($useinecm && $useinecm != 6) && $useajax) ?
'#' : ($url.
'?action=delete&token='.
newToken().
'&urlfile='.urlencode($filepath).$param)).
'" class="reposition deletefilelink" rel="'.$filepath.
'">'.
img_delete().
'</a>';
1349 if (empty($disablemove))
1351 if ($nboffiles > 1 && $conf->browser->layout !=
'phone') {
1352 print '<td class="linecolmove tdlineupdown center">';
1354 print '<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=up&rowid='.$line->id.
'">'.
img_up(
'default', 0,
'imgupforline').
'</a>';
1356 if ($i < $nboffiles - 1) {
1357 print '<a class="lineupdown" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$this->
id.
'&action=down&rowid='.$line->id.
'">'.
img_down(
'default', 0,
'imgdownforline').
'</a>';
1361 print '<td'.(($conf->browser->layout !=
'phone' && empty($disablemove)) ?
' class="linecolmove tdlineupdown center"' :
' class="linecolmove center"').
'>';
1366 print '<td class="right">';
1367 print '<input type="hidden" name="ecmfileid" value="'.$filearray[$key][
'rowid'].
'">';
1368 print '<input type="submit" class="button button-save" name="renamefilesave" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
1369 print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
1371 if (empty($disablemove))
print '<td class="right"></td>';
1378 if ($nboffiles == 0)
1381 if (empty($disablemove)) $colspan++;
1382 print '<tr class="oddeven"><td colspan="'.$colspan.
'" class="opacitymedium">';
1383 if (empty($textifempty))
print $langs->trans(
"NoFileFound");
1384 else print $textifempty;
1390 if ($nboflines > 1 && is_object($object)) {
1391 if (!empty($conf->use_javascript_ajax) && $permtoeditline) {
1392 $table_element_line =
'ecm_files';
1393 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
1399 if (
GETPOST(
'action',
'aZ09') ==
'editfile' && $permtoeditline)
1428 public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath =
'', $permissiontodelete = 1, $useinecm = 0, $textifempty =
'', $maxlength = 0, $url =
'', $addfilterfields = 0)
1431 global $user, $conf, $langs, $hookmanager, $form;
1432 global $sortfield, $sortorder;
1433 global $search_doc_ref;
1434 global $dolibarr_main_url_root;
1436 dol_syslog(get_class($this).
'::list_of_autoecmfiles upload_dir='.$upload_dir.
' modulepart='.$modulepart);
1440 if (empty($url)) $url =
$_SERVER[
"PHP_SELF"];
1442 if (!empty($addfilterfields))
1444 print '<form action="'.$_SERVER[
'PHP_SELF'].
'">';
1445 print '<input type="hidden" name="token" value="'.newToken().
'">';
1446 print '<input type="hidden" name="module" value="'.$modulepart.
'">';
1449 print '<div class="div-table-responsive-no-min">';
1450 print '<table width="100%" class="noborder">'.
"\n";
1452 if (!empty($addfilterfields))
1454 print '<tr class="liste_titre nodrag nodrop">';
1455 print '<td class="liste_titre"></td>';
1456 print '<td class="liste_titre"><input type="text" class="maxwidth100onsmartphone" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).
'"></td>';
1457 print '<td class="liste_titre"></td>';
1458 print '<td class="liste_titre"></td>';
1460 print '<td class="liste_titre center">';
1461 $searchpicto = $form->showFilterButtons();
1467 print '<tr class="liste_titre">';
1468 $sortref =
"fullname";
1469 if ($modulepart ==
'invoice_supplier') $sortref =
'level1name';
1478 if ($modulepart ==
'company')
1480 include_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
1481 $object_instance =
new Societe($this->
db);
1482 } elseif ($modulepart ==
'invoice')
1484 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1485 $object_instance =
new Facture($this->
db);
1486 } elseif ($modulepart ==
'invoice_supplier')
1488 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
1490 } elseif ($modulepart ==
'propal')
1492 include_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
1493 $object_instance =
new Propal($this->
db);
1494 } elseif ($modulepart ==
'supplier_proposal')
1496 include_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
1498 } elseif ($modulepart ==
'order')
1500 include_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
1502 } elseif ($modulepart ==
'order_supplier')
1504 include_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
1506 } elseif ($modulepart ==
'contract')
1508 include_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
1509 $object_instance =
new Contrat($this->
db);
1510 } elseif ($modulepart ==
'product')
1512 include_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
1513 $object_instance =
new Product($this->
db);
1514 } elseif ($modulepart ==
'tax')
1516 include_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
1518 } elseif ($modulepart ==
'project')
1520 include_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
1521 $object_instance =
new Project($this->
db);
1522 } elseif ($modulepart ==
'fichinter')
1524 include_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
1526 } elseif ($modulepart ==
'user')
1528 include_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
1529 $object_instance =
new User($this->
db);
1530 } elseif ($modulepart ==
'expensereport')
1532 include_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
1534 } elseif ($modulepart ==
'holiday')
1536 include_once DOL_DOCUMENT_ROOT.
'/holiday/class/holiday.class.php';
1537 $object_instance =
new Holiday($this->
db);
1538 } elseif ($modulepart ==
'recruitment-recruitmentcandidature')
1540 include_once DOL_DOCUMENT_ROOT.
'/recruitment/class/recruitmentcandidature.class.php';
1542 } elseif ($modulepart ==
'banque')
1544 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
1545 $object_instance =
new Account($this->
db);
1546 } elseif ($modulepart ==
'mrp-mo')
1548 include_once DOL_DOCUMENT_ROOT.
'/mrp/class/mo.class.php';
1549 $object_instance =
new Mo($this->
db);
1555 $relativepathfromroot = preg_replace(
'/'.preg_quote(DOL_DATA_ROOT.
'/',
'/').
'/',
'', $upload_dir);
1556 if ($relativepathfromroot)
1561 if ($sortfield && $sortorder)
1569 foreach ($filearray as $key => $file)
1571 if (!is_dir($file[
'name'])
1572 && $file[
'name'] !=
'.'
1573 && $file[
'name'] !=
'..'
1574 && $file[
'name'] !=
'CVS'
1575 && !preg_match(
'/\.meta$/i', $file[
'name']))
1578 $relativefile = preg_replace(
'/'.preg_quote($upload_dir.
'/',
'/').
'/',
'', $file[
'fullname']);
1584 if ($modulepart ==
'company' || $modulepart ==
'tax') { preg_match(
'/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] :
''); }
1585 elseif ($modulepart ==
'invoice_supplier') { preg_match(
'/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] :
'');
if (is_numeric($ref)) { $id = $ref; $ref =
''; } }
1586 elseif ($modulepart ==
'user' || $modulepart ==
'holiday') { preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] :
''); }
1587 elseif (in_array($modulepart, array(
1590 'supplier_proposal',
1598 'recruitment-recruitmentcandidature',
1601 preg_match(
'/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] :
'');
1606 if (!$id && !$ref)
continue;
1608 if (!empty($this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref]))
1615 $result = $object_instance->fetch($id);
1621 if (!$result = $object_instance->fetch(
'', $ref)) {
1622 $result = $object_instance->fetchOneLike($ref);
1627 $found = 1; $this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref] = clone $object_instance;
1629 if ($result == 0) { $found = 1; $this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref] =
'notfound'; unset($filearray[$key]); }
1632 if (!$found > 0 || !is_object($this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref]))
continue;
1634 print '<!-- Line list_of_autoecmfiles '.$key.
' -->'.
"\n";
1635 print '<tr class="oddeven">';
1637 if ($found > 0 && is_object($this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref]))
print $this->cache_objects[$modulepart.
'_'.$id.
'_'.$ref]->getNomUrl(1,
'document');
1638 else print $langs->trans(
"ObjectDeleted", ($id ? $id : $ref));
1652 print '<a href="'.DOL_URL_ROOT.
'/document.php?modulepart='.$modulepart;
1653 if ($forcedownload)
print '&attachment=1';
1654 print '&file='.urlencode($relativefile).
'">';
1668 print '<td class="right nowraponall">';
1669 if ($sizetoshow == $sizetoshowbytes)
print $sizetoshow;
1671 print $form->textwithpicto($sizetoshow, $sizetoshowbytes, -1);
1676 print '<td class="center">'.dol_print_date($file[
'date'],
"dayhour").
'</td>';
1679 print '<td class="right">';
1680 if ($file[
'share']) {
1682 $urlwithouturlroot = preg_replace(
'/'.preg_quote(DOL_URL_ROOT,
'/').
'$/i',
'', trim($dolibarr_main_url_root));
1683 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT;
1689 if (!empty($file[
'share'])) $paramlink .= ($paramlink ?
'&' :
'').
'hashp='.$file[
'share'];
1690 if ($forcedownload) $paramlink .= ($paramlink ?
'&' :
'').
'attachment=1';
1692 $fulllink = $urlwithroot.
'/document.php'.($paramlink ?
'?'.$paramlink :
'');
1694 print img_picto($langs->trans(
"FileSharedViaALink"),
'globe').
' ';
1695 print '<input type="text" class="quatrevingtpercent width100 nopadding" id="downloadlink" name="downloadexternallink" value="'.dol_escape_htmltag($fulllink).
'">';
1703 print "</td></tr>\n";
1707 if (count($filearray) == 0)
1709 print '<tr class="oddeven"><td colspan="5">';
1710 if (empty($textifempty))
print '<span class="opacitymedium">'.$langs->trans(
"NoFileFound").
'</span>';
1711 else print '<span class="opacitymedium">'.$textifempty.
'</span>';
1717 if (!empty($addfilterfields))
print '</form>';
1730 global $langs, $conf;
1733 $post_max_size = ini_get(
'post_max_size');
1734 $mul_post_max_size = substr($post_max_size, -1);
1735 $mul_post_max_size = ($mul_post_max_size ==
'M' ? 1048576 : ($mul_post_max_size ==
'K' ? 1024 : ($mul_post_max_size ==
'G' ? 1073741824 : 1)));
1736 $post_max_size = $mul_post_max_size * (int) $post_max_size;
1738 $upload_max_filesize = ini_get(
'upload_max_filesize');
1739 $mul_upload_max_filesize = substr($upload_max_filesize, -1);
1740 $mul_upload_max_filesize = ($mul_upload_max_filesize ==
'M' ? 1048576 : ($mul_upload_max_filesize ==
'K' ? 1024 : ($mul_upload_max_filesize ==
'G' ? 1073741824 : 1)));
1741 $upload_max_filesize = $mul_upload_max_filesize * (int) $upload_max_filesize;
1743 $max_file_size = (($post_max_size < $upload_max_filesize) ? $post_max_size : $upload_max_filesize);
1746 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajax/fileupload_main.tpl.php';
1749 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajax/fileupload_view.tpl.php';
1762 public function listOfLinks($object, $permissiontodelete = 1, $action = null, $selected = null, $param =
'')
1764 global $user, $conf, $langs, $user;
1765 global $sortfield, $sortorder;
1767 $langs->load(
"link");
1769 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
1770 $link =
new Link($this->
db);
1772 if ($sortfield ==
"name") {
1773 $sortfield =
"label";
1774 } elseif ($sortfield ==
"date") {
1775 $sortfield =
"datea";
1779 $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder);
1780 $param .= (isset($object->id) ?
'&id='.$object->id :
'');
1782 print '<!-- listOfLinks -->'.
"\n";
1787 print '<form action="'.$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
'').
'" method="POST">';
1788 print '<input type="hidden" name="token" value="'.newToken().
'">';
1790 print '<table width="100%" class="liste noborder nobottom">';
1791 print '<tr class="liste_titre">';
1793 $langs->trans(
"Links"),
1815 $langs->trans(
"Date"),
1838 $nboflinks = count($links);
1839 if ($nboflinks > 0) include_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
1841 foreach ($links as $link)
1843 print '<tr class="oddeven">';
1845 if ($action ==
'update' && $selected === $link->id)
1848 print '<input type="hidden" name="id" value="'.$object->id.
'">';
1849 print '<input type="hidden" name="linkid" value="'.$link->id.
'">';
1850 print '<input type="hidden" name="action" value="confirm_updateline">';
1851 print $langs->trans(
'Link').
': <input type="text" name="link" value="'.$link->url.
'">';
1854 print $langs->trans(
'Label').
': <input type="text" name="label" value="'.
dol_escape_htmltag($link->label).
'">';
1856 print '<td class="center">'.dol_print_date(
dol_now(),
"dayhour",
"tzuser").
'</td>';
1857 print '<td class="right"></td>';
1858 print '<td class="right">';
1859 print '<input type="submit" name="save" class="button button-save" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
1860 print '<input type="submit" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
1865 print '<a data-ajax="false" href="'.$link->url.
'" target="_blank">';
1869 print '<td class="right"></td>';
1870 print '<td class="center">'.dol_print_date($link->datea,
"dayhour",
"tzuser").
'</td>';
1871 print '<td class="center"></td>';
1872 print '<td class="right">';
1873 print '<a href="'.$_SERVER[
'PHP_SELF'].
'?action=update&linkid='.$link->id.$param.
'" class="editfilelink editfielda reposition" >'.
img_edit().
'</a>';
1874 if ($permissiontodelete) {
1875 print ' <a class="deletefilelink" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&linkid='.$link->id.$param.
'">'.
img_delete().
'</a>';
1883 if ($nboflinks == 0)
1885 print '<tr class="oddeven"><td colspan="5" class="opacitymedium">';
1886 print $langs->trans(
"NoLinkFound");
1907 public function showPreview($file, $modulepart, $relativepath, $ruleforpicto = 0, $param =
'')
1909 global $langs, $conf;
1912 if ($conf->browser->layout !=
'phone' && !empty($conf->use_javascript_ajax))
1915 if (count($urladvancedpreview))
1917 $out .=
'<a class="pictopreview '.$urladvancedpreview[
'css'].
'" href="'.$urladvancedpreview[
'url'].
'"'.(empty($urladvancedpreview[
'mime']) ?
'' :
' mime="'.$urladvancedpreview[
'mime'].
'"').
' '.(empty($urladvancedpreview[
'target']) ?
'' :
' target="'.$urladvancedpreview[
'target'].
'"').
'>';
1919 if (empty($ruleforpicto)) {
1921 $out .=
'<span class="fa fa-search-plus" style="color: gray"></span>';
1923 $out .=
img_mime($relativepath, $langs->trans(
'Preview').
' '.$file[
'name']);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class of the module paid holiday.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active models generation.
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.
completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
Complete $filearray with data from database.
Class to manage products or services.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage interventions.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
dol_now($mode= 'auto')
Return date for now.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage Dolibarr users.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage contracts.
dol_filesize($pathoffile)
Return size of a file.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
const TYPE_SERVICE
Service.
Class to manage suppliers invoices.
const TYPE_PRODUCT
Regular product.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_mime($file, $titlealt= '', $morecss= '')
Show MIME img of a file.
$conf db
API class for accounts.
Class to manage bank accounts.
image_format_supported($file, $acceptsvg=0)
Return if a filename is file name of a supported image format.
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.
getImageFileNameForSize($file, $extName, $extImgTarget= '')
Return the filename of file to get the thumbs.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
img_down($titlealt= 'default', $selected=0, $moreclass= '')
Show down arrow logo.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage projects.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_up($titlealt= 'default', $selected=0, $moreclass= '')
Show top arrow logo.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage customers orders.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Class to manage Trips and Expenses.
Class to manage predefined suppliers products.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
dol_is_file($pathoffile)
Return if path is a file.
ajax_autoselect($htmlname, $addlink= '')
Make content of an input box selected when we click into input field.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation models.
print $_SERVER["PHP_SELF"]
Edit parameters.
Class for RecruitmentCandidature.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
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.
print
Draft customers invoices.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_filemtime($pathoffile)
Return time of a file.
Class to manage price ask supplier.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
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.
Class to manage invoices.
liste_modeles($db, $maxfilenamelength=0)
Load into memory list of available export format.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param= '')
Return URL we can use for advanced preview links.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
Class to manage proposals.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...