dolibarr 25.0.0-alpha
index_auto.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2008-2010 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
5 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2025 Joachim Kueter <git-jk@bloxera.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
46
47// Get parameters
48$socid = GETPOSTINT('socid');
49$action = GETPOST('action', 'aZ09');
50$section = GETPOSTINT('section') ? GETPOSTINT('section') : GETPOSTINT('section_id');
51$module = GETPOST('module', 'aZ09arobase');
52if (!$section) {
53 $section = 0;
54}
55$section_dir = GETPOST('section_dir', 'alpha');
56
57$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
58$search_doc_date_start = '';
59$search_doc_date_end = '';
60if (GETPOSTISSET('search_doc_date_start') || GETPOSTISSET('search_doc_date_startday') || GETPOSTISSET('search_doc_date_startmonth') || GETPOSTISSET('search_doc_date_startyear')) {
61 $search_doc_date_start = GETPOSTDATE('search_doc_date_start');
62}
63if (GETPOSTISSET('search_doc_date_end') || GETPOSTISSET('search_doc_date_endday') || GETPOSTISSET('search_doc_date_endmonth') || GETPOSTISSET('search_doc_date_endyear')) {
64 $search_doc_date_end = GETPOSTDATE('search_doc_date_end', 'end');
65}
66
67$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
68$sortfield = GETPOST('sortfield', 'aZ09comma');
69$sortorder = GETPOST('sortorder', 'aZ09comma');
70$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
71if (empty($page) || $page == -1) {
72 $page = 0;
73} // If $page is not defined, or '' or -1
74$offset = $limit * $page;
75$pageprev = $page - 1;
76$pagenext = $page + 1;
77if (!$sortorder) {
78 $sortorder = "ASC";
79}
80if (!$sortfield) {
81 $sortfield = "fullname";
82}
83if ($module == 'invoice_supplier' && $sortfield == "fullname") {
84 $sortfield = "level1name";
85}
86
87$ecmdir = new EcmDirectory($db);
88if ($section) {
89 $result = $ecmdir->fetch($section);
90 if (!($result > 0)) {
91 dol_print_error($db, $ecmdir->error);
92 exit;
93 }
94}
95
96$form = new Form($db);
97$ecmdirstatic = new EcmDirectory($db);
98$userstatic = new User($db);
99
100$error = 0;
101
102// Security check
103if ($user->socid) {
104 $socid = $user->socid;
105}
106
107// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
108$hookmanager->initHooks(array('ecmautocard', 'globalcard'));
109
110$result = restrictedArea($user, 'ecm', 0);
111
112
113/*
114 * Actions
115 */
116
117// Purge search criteria
118if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
119 $search_doc_ref = '';
120 $search_doc_date_start = '';
121 $search_doc_date_end = '';
122}
123
124// Add directory
125if ($action == 'add' && $user->hasRight('ecm', 'setup')) {
126 $ecmdir->ref = 'NOTUSEDYET';
127 $ecmdir->label = GETPOST("label");
128 $ecmdir->description = GETPOST("desc");
129
130 $id = $ecmdir->create($user);
131 if ($id > 0) {
132 header("Location: ".$_SERVER["PHP_SELF"]);
133 exit;
134 } else {
135 setEventMessages('Error '.$langs->trans($ecmdir->error), null, 'errors');
136 $action = "create";
137 }
138
139 clearstatcache();
140}
141
142// Remove file
143if ($action == 'confirm_deletefile' && $user->hasRight('ecm', 'upload')) {
144 if (GETPOST('confirm') == 'yes') {
145 $langs->load("other");
146 if ($section) {
147 $result = $ecmdir->fetch($section);
148 if (!($result > 0)) {
149 dol_print_error($db, $ecmdir->error);
150 exit;
151 }
152 $relativepath = $ecmdir->getRelativePath();
153 } else {
154 $relativepath = '';
155 }
156 $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : '');
157 $file = $upload_dir."/".GETPOST('urlfile');
158
159 $ret = dol_delete_file($file, 1);
160 if ($ret) {
161 setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
162 } else {
163 setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
164 }
165
166 $result = $ecmdir->changeNbOfFiles('-');
167
168 clearstatcache();
169 }
170 $action = 'file_manager';
171}
172
173// Remove directory
174if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes' && $user->hasRight('ecm', 'setup')) {
175 $result = $ecmdir->delete($user);
176 setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
177
178 clearstatcache();
179}
180
181// Refresh directory view
182// This refresh list of dirs, not list of files (for performance reason). List of files is refresh only if dir was not synchronized.
183// To refresh content of dir with cache, just open the dir in edit mode.
184if ($action == 'refreshmanual' && $user->hasRight('ecm', 'read')) {
185 $ecmdirtmp = new EcmDirectory($db);
186
187 // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
188 clearstatcache();
189
190 $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output);
191 $diroutputslash .= '/';
192
193 // Scan directory tree on disk
194 $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', 0, 0);
195
196 // Scan directory tree in database
197 $treesqldir = $ecmdirstatic->get_full_arbo(0);
198
199 $adirwascreated = 0;
200
201 // Now we compare both trees to complete missing trees into database
202 //var_dump($disktree);
203 //var_dump($treesqldir);
204 foreach ($disktree as $dirdesc) { // Loop on tree onto disk
205 $dirisindatabase = 0;
206 foreach ($treesqldir as $dirsqldesc) {
207 if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
208 $dirisindatabase = 1;
209 break;
210 }
211 }
212
213 if (!$dirisindatabase) {
214 $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
215 dol_syslog($txt);
216 //print $txt."<br>\n";
217
218 // We must first find the fk_parent of directory to create $dirdesc['fullname']
219 $fk_parent = -1;
220 $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']);
221 $relativepathtosearchparent = $relativepathmissing;
222 //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
223 if (preg_match('/\//', $relativepathtosearchparent)) {
224 //while (preg_match('/\//',$relativepathtosearchparent))
225 $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent);
226 $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
227 dol_syslog($txt);
228 //print $txt." -> ";
229 $parentdirisindatabase = 0;
230 foreach ($treesqldir as $dirsqldesc) {
231 if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) {
232 $parentdirisindatabase = $dirsqldesc['id'];
233 break;
234 }
235 }
236 if ($parentdirisindatabase > 0) {
237 dol_syslog("Yes with id ".$parentdirisindatabase);
238 //print "Yes with id ".$parentdirisindatabase."<br>\n";
239 $fk_parent = $parentdirisindatabase;
240 //break; // We found parent, we can stop the while loop
241 } else {
242 dol_syslog("No");
243 //print "No<br>\n";
244 }
245 } else {
246 dol_syslog("Parent is root");
247 $fk_parent = 0; // Parent is root
248 }
249
250 if ($fk_parent >= 0) {
251 $ecmdirtmp->ref = 'NOTUSEDYET';
252 $ecmdirtmp->label = dol_basename($dirdesc['fullname']);
253 $ecmdirtmp->description = '';
254 $ecmdirtmp->fk_parent = $fk_parent;
255
256 $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent;
257 dol_syslog($txt);
258 //print $ecmdirtmp->cachenbofdoc."<br>\n";exit;
259 $id = $ecmdirtmp->create($user);
260 if ($id > 0) {
261 $newsqldir = array('id' => $id,
262 'id_mere' => $ecmdirtmp->fk_parent,
263 'label' => $ecmdirtmp->label,
264 'description' => $ecmdirtmp->description,
265 'fullrelativename' => $relativepathmissing);
266 $treesqldir[] = $newsqldir; // We complete fulltree for following loops
267 //var_dump($treesqldir);
268 $adirwascreated = 1;
269 } else {
270 dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
271 }
272 } else {
273 $txt = "Parent of ".$dirdesc['fullname']." not found";
274 dol_syslog($txt);
275 //print $txt."<br>\n";
276 }
277 }
278 }
279
280 // Loop now on each sql tree to check if dir exists
281 foreach ($treesqldir as $dirdesc) { // Loop on each treesqldir to check dir is on disk
282 $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
283 if (!dol_is_dir($dirtotest)) {
284 $ecmdirtmp->id = $dirdesc['id'];
285 $ecmdirtmp->delete($user, 'databaseonly');
286 //exit;
287 }
288 }
289
290 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cache counting, we set to value -1 = "unknown"
291 dol_syslog("sql = ".$sql);
292 $db->query($sql);
293
294 // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean
295 // it to be sure that fulltree array is not used without reloading it.
296 if ($adirwascreated) {
297 $treesqldir = null;
298 }
299}
300
301// Download selected automatic ECM files for supplier invoices
302if ($action == 'download_selected' && $module == 'invoice_supplier' && !$user->hasRight('fournisseur', 'facture', 'lire')) {
304}
305if ($action == 'download_selected' && $module == 'invoice_supplier' && $user->hasRight('fournisseur', 'facture', 'lire')) {
306 $langs->loadLangs(array("errors", "accountancy"));
307
308 $selectedfiles = GETPOST('selectedfiles', 'array');
309 $selectedfiles = is_array($selectedfiles) ? $selectedfiles : array();
310 $maxformassaction = getDolGlobalInt('MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
311
312 if (count($selectedfiles) < 1) {
313 setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
314 } elseif (count($selectedfiles) > $maxformassaction) {
315 setEventMessages($langs->trans("TooManyRecordForMassAction", $maxformassaction), null, 'errors');
316 } elseif (!class_exists('ZipArchive')) {
317 setEventMessages('ZipArchive PHP extension is not available', null, 'errors');
318 } else {
319 include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
320
321 $upload_dir = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
322 $basepath = realpath($upload_dir);
323 $basepathwithslash = ($basepath ? rtrim($basepath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : '');
324 $filestoarchive = array();
325 $invoicecache = array();
326
327 foreach ($selectedfiles as $selectedfile) {
328 if (!is_scalar($selectedfile)) {
329 continue;
330 }
331
332 $relativefile = str_replace('\\', '/', (string) $selectedfile);
333 $relativefile = preg_replace('/\/+/', '/', $relativefile);
334 $relativefile = ltrim($relativefile, '/');
335
336 if ($relativefile == ''
337 || preg_match('/(^|\/)\.\.(\/|$)/', $relativefile)
338 || preg_match('/[<>|\x00-\x1F]/', $relativefile)
339 || preg_match('/(^|\/)(temp|thumbs|CVS|payments)(\/|$)/i', $relativefile)
340 || preg_match('/(\.meta|_preview.*\.png)$/i', $relativefile)
341 ) {
342 continue;
343 }
344
345 $reg = array();
346 preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg);
347 $ref = (isset($reg[1]) ? $reg[1] : '');
348 $id = 0;
349 if ($ref === '') {
350 continue;
351 }
352 if (is_numeric($ref)) {
353 $id = (int) $ref;
354 $ref = '';
355 }
356
357 $cachekey = $id.'_'.$ref;
358 if (!array_key_exists($cachekey, $invoicecache)) {
359 $invoicecache[$cachekey] = false;
360 $objecttmp = new FactureFournisseur($db);
361 $result = 0;
362 if ($id > 0) {
363 $result = $objecttmp->fetch($id);
364 } else {
365 if (!($result = $objecttmp->fetch(0, $ref))) {
366 $result = $objecttmp->fetchOneLike($ref);
367 }
368 }
369 if ($result > 0 && (int) $objecttmp->entity === (int) $conf->entity) {
370 $invoicecache[$cachekey] = true;
371 }
372 }
373 if (empty($invoicecache[$cachekey])) {
374 continue;
375 }
376
377 $fullpath = realpath($upload_dir.'/'.$relativefile);
378 if (empty($basepath) || empty($fullpath) || strpos($fullpath, $basepathwithslash) !== 0 || !is_file($fullpath)) {
379 continue;
380 }
381
382 $filestoarchive[$relativefile] = $fullpath;
383 }
384
385 if (count($filestoarchive) < 1) {
386 setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
387 } else {
388 $tmpdir = DOL_DATA_ROOT.'/ecm/temp';
389 dol_mkdir($tmpdir);
390
391 if (!is_writable($tmpdir)) {
392 setEventMessages($langs->trans("ErrorFailedToWriteInDir", $tmpdir), null, 'errors');
393 } else {
394 $zipfilename = 'supplier_invoice_documents_'.dol_print_date(dol_now(), 'dayhourlog').'.zip';
395 $zipfullpath = $tmpdir.'/'.$zipfilename;
396
397 $zip = new ZipArchive();
398 $result = $zip->open($zipfullpath, ZipArchive::CREATE | ZipArchive::OVERWRITE);
399 if ($result !== true) {
400 setEventMessages($langs->trans("ErrorFailedToBuildArchive", $zipfullpath), null, 'errors');
401 } else {
402 $errorarchive = 0;
403 foreach ($filestoarchive as $relativefile => $fullpath) {
404 $result = $zip->addFile($fullpath, $relativefile);
405 if (!$result) {
406 $errorarchive++;
407 setEventMessages($langs->trans("ErrorArchiveAddFile", $relativefile), null, 'errors');
408 break;
409 }
410 }
411 $closeok = $zip->close();
412
413 if ($errorarchive || !$closeok || !is_file($zipfullpath)) {
414 if (!$errorarchive) {
415 setEventMessages($langs->trans("ErrorFailedToBuildArchive", $zipfullpath), null, 'errors');
416 }
417 dol_delete_file($zipfullpath, 1, 0, 1, null, false, 0, 1);
418 } else {
419 top_httphead('application/zip');
420 header('Content-Disposition: attachment; filename="'.$zipfilename.'"');
421 header('Content-Length: '.filesize($zipfullpath));
422 readfile($zipfullpath);
423 dol_delete_file($zipfullpath, 1, 0, 1, null, false, 0, 1);
424 $db->close();
425 exit;
426 }
427 }
428 }
429 }
430 }
431
432 $action = '';
433}
434
435
436
437/*
438 * View
439 */
440
441// Define height of file area (depends on $_SESSION["dol_screenheight"])
442//print $_SESSION["dol_screenheight"];
443$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466) ? ($_SESSION["dol_screenheight"] - 136) : 660; // Also into index.php file
444
445$moreheadcss = '';
446$moreheadjs = '';
447
448$morejs=array();
449if (!getDolGlobalString('MAIN_ECM_DISABLE_JS')) {
450 $morejs[] = "public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
451}
452
453llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', '', 'mod-ecm page-index_auto');
454
455
456// Add sections to manage
457$rowspan = 0;
458$sectionauto = array();
459if (!getDolGlobalString('ECM_AUTO_TREE_HIDEN')) {
460 if (isModEnabled("product") || isModEnabled("service")) {
461 $langs->load("products");
462 $rowspan++;
463 $sectionauto[] = array('position' => 10, 'level' => 1, 'module' => 'product', 'test' => $user->hasRight('produit', 'lire'), 'label' => $langs->trans("ProductsAndServices"), 'desc' => $langs->trans("ECMDocsByProducts"));
464 }
465 if (isModEnabled("societe")) {
466 $rowspan++;
467 $sectionauto[] = array('position' => 20, 'level' => 1, 'module' => 'company', 'test' => $user->hasRight('societe', 'lire'), 'label' => $langs->trans("ThirdParties"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
468 }
469 if (isModEnabled("propal")) {
470 $rowspan++;
471 $sectionauto[] = array('position' => 30, 'level' => 1, 'module' => 'propal', 'test' => $user->hasRight('propale', 'lire'), 'label' => $langs->trans("Proposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
472 }
473 if (isModEnabled('contract')) {
474 $rowspan++;
475 $sectionauto[] = array('position' => 40, 'level' => 1, 'module' => 'contract', 'test' => $user->hasRight('contrat', 'lire'), 'label' => $langs->trans("Contracts"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
476 }
477 if (isModEnabled('order')) {
478 $rowspan++;
479 $sectionauto[] = array('position' => 50, 'level' => 1, 'module' => 'order', 'test' => $user->hasRight('commande', 'lire'), 'label' => $langs->trans("CustomersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
480 }
481 if (isModEnabled('invoice')) {
482 $rowspan++;
483 $sectionauto[] = array('position' => 60, 'level' => 1, 'module' => 'invoice', 'test' => $user->hasRight('facture', 'lire'), 'label' => $langs->trans("CustomersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
484 }
485 if (isModEnabled('supplier_proposal')) {
486 $langs->load("supplier_proposal");
487 $rowspan++;
488 $sectionauto[] = array('position' => 70, 'level' => 1, 'module' => 'supplier_proposal', 'test' => $user->hasRight('supplier_proposal', 'lire'), 'label' => $langs->trans("SupplierProposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
489 }
490 if (isModEnabled("supplier_order")) {
491 $rowspan++;
492 $sectionauto[] = array('position' => 80, 'level' => 1, 'module' => 'order_supplier', 'test' => $user->hasRight('fournisseur', 'commande', 'lire'), 'label' => $langs->trans("SuppliersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SuppliersOrders")));
493 }
494 if (isModEnabled("supplier_invoice")) {
495 $rowspan++;
496 $sectionauto[] = array('position' => 90, 'level' => 1, 'module' => 'invoice_supplier', 'test' => $user->hasRight('fournisseur', 'facture', 'lire'), 'label' => $langs->trans("SuppliersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
497 }
498 if (isModEnabled('tax')) {
499 $langs->load("compta");
500 $rowspan++;
501 $sectionauto[] = array('position' => 100, 'level' => 1, 'module' => 'tax', 'test' => $user->hasRight('tax', 'charges', 'lire'), 'label' => $langs->trans("SocialContributions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
502 $rowspan++;
503 $sectionauto[] = array('position' => 110, 'level' => 1, 'module' => 'tax-vat', 'test' => $user->hasRight('tax', 'charges', 'lire'), 'label' => $langs->trans("VAT"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT")));
504 }
505 if (isModEnabled('salaries')) {
506 $langs->load("compta");
507 $rowspan++;
508 $sectionauto[] = array('position' => 120, 'level' => 1, 'module' => 'salaries', 'test' => $user->hasRight('salaries', 'read'), 'label' => $langs->trans("Salaries"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries")));
509 }
510 if (isModEnabled('project')) {
511 $rowspan++;
512 $sectionauto[] = array('position' => 130, 'level' => 1, 'module' => 'project', 'test' => 1, 'label' => $langs->trans("Projects"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
513 $rowspan++;
514 $sectionauto[] = array('position' => 140, 'level' => 1, 'module' => 'project_task', 'test' => 1, 'label' => $langs->trans("Tasks"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks")));
515 }
516 if (isModEnabled('intervention')) {
517 $langs->load("interventions");
518 $rowspan++;
519 $sectionauto[] = array('position' => 150, 'level' => 1, 'module' => 'fichinter', 'test' => $user->hasRight('ficheinter', 'lire'), 'label' => $langs->trans("Interventions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
520 }
521 if (isModEnabled('expensereport')) {
522 $langs->load("trips");
523 $rowspan++;
524 $sectionauto[] = array('position' => 160, 'level' => 1, 'module' => 'expensereport', 'test' => $user->hasRight('expensereport', 'lire'), 'label' => $langs->trans("ExpenseReports"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
525 }
526 if (isModEnabled('holiday')) {
527 $langs->load("holiday");
528 $rowspan++;
529 $sectionauto[] = array('position' => 170, 'level' => 1, 'module' => 'holiday', 'test' => $user->hasRight('holiday', 'read'), 'label' => $langs->trans("Holidays"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
530 }
531 if (isModEnabled("bank")) {
532 $langs->load("banks");
533 $rowspan++;
534 $sectionauto[] = array('position' => 180, 'level' => 1, 'module' => 'banque', 'test' => $user->hasRight('banque', 'lire'), 'label' => $langs->trans("BankAccount"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
535 // TODO Enable this
536 //$rowspan++;
537 //$sectionauto[] = array('position' => 182, 'level' => 1, 'module' => 'bank-statement', 'test' => $user->hasRight('banque', 'lire'), 'label' => $langs->trans("BankAccount").' - '.$langs->trans("Statement"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount").' - '.$langs->transnoentitiesnoconv("Statement")));
538 $rowspan++;
539 $sectionauto[] = array('position' => 190, 'level' => 1, 'module' => 'chequereceipt', 'test' => $user->hasRight('banque', 'lire'), 'label' => $langs->trans("CheckReceipt"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
540 }
541 if (isModEnabled('mrp')) {
542 $langs->load("mrp");
543 $rowspan++;
544 $sectionauto[] = array('position' => 200, 'level' => 1, 'module' => 'mrp-mo', 'test' => $user->hasRight('mrp', 'read'), 'label' => $langs->trans("MOs"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
545 }
546 if (isModEnabled('recruitment')) {
547 $langs->load("recruitment");
548 $rowspan++;
549 $sectionauto[] = array('position' => 210, 'level' => 1, 'module' => 'recruitment-recruitmentcandidature', 'test' => $user->hasRight('recruitment', 'read'), 'label' => $langs->trans("Candidatures"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
550 }
551 $rowspan++;
552 $sectionauto[] = array('position' => 220, 'level' => 1, 'module' => 'user', 'test' => 1, 'label' => $langs->trans("Users"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
553
554 $parameters = array();
555 $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
556 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
557 $res = $hookmanager->resArray[0];
558 if (is_array($hookmanager->resArray[0])) {
559 $sectionauto = array_merge($sectionauto, $hookmanager->resArray);
560 $rowspan += count($hookmanager->resArray);
561 } else {
562 $sectionauto[] = $hookmanager->resArray;
563 $rowspan++;
564 }
565 }
566}
567
569print dol_get_fiche_head($head, 'index_auto', '', -1, '');
570
571
572
573// Confirm remove file (for non javascript users)
574if ($action == 'deletefile' && empty($conf->use_javascript_ajax)) {
575 print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], array('section' => $section, 'urlfile' => GETPOST("urlfile"))), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
576}
577
578// Start container of all panels
579?>
580<!-- Begin div id="containerlayout" -->
581<div id="containerlayout">
582<div id="ecm-layout-north" class="toolbar largebutton">
583<?php
584
585// Start top panel, toolbar
586print '<div class="inline-block toolbarbutton centpercent">';
587
588// Toolbar
589if (!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS')) {
590 $url = '#';
591} else {
592 $paramsrefresh = array('action' => 'refreshmanual');
593 if ($module) {
594 $paramsrefresh['module'] = $module;
595 }
596 if ($section) {
597 $paramsrefresh['section'] = $section;
598 }
599 $url = dolBuildUrl($_SERVER["PHP_SELF"], $paramsrefresh);
600}
601print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
602print img_picto('', 'refresh', 'id="refreshbutton"', 0, 0, 0, '', 'size15x marginrightonly');
603print '</a>';
604
605print '</div>';
606// End top panel, toolbar
607
608?>
609</div>
610<div id="ecm-layout-west" class="inline-block">
611<?php
612// Start left area
613
614
615// Generate form to confirm the deletion of a category line
616if ($action == 'delete_section') {
617 print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], array('section' => $section)), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1);
618}
619// End confirm
620
621
622if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'deletefile') {
623 print '<table class="liste centpercent noborder">'."\n";
624
625 print '<!-- Title for auto directories -->'."\n";
626 print '<tr class="liste_titre">'."\n";
627 print '<th class="liste_titre" align="left" colspan="6">';
628 print '&nbsp;'.$langs->trans("ECMSections");
629 print '</th></tr>';
630
631 $showonrightsize = '';
632
633 // Auto section
634 if (count($sectionauto)) {
635 $htmltooltip = $langs->trans("ECMAreaDesc2");
636 $htmltooltip .= '<br>'.$langs->trans("ECMAreaDesc2b");
637
638 $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', 1, 0);
639
640 print '<tr>';
641 print '<td colspan="6">';
642 print '<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
643
644 $arrayofmodulesforexternalusers = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
645
646 $nbofentries = 0;
647 $oldvallevel = 0;
648 foreach ($sectionauto as $key => $val) {
649 if (empty($val['test'])) {
650 continue; // If condition to show the ECM auto directory is ok
651 }
652
653 // External users are not allowed to see manual directories so we quit.
654 if ($user->socid > 0) {
655 // Check if dir is allowed to external users
656 //var_dump($conf->global->MAIN_MODULES_FOR_EXTERNAL);
657 if (! in_array($val['module'], $arrayofmodulesforexternalusers)) {
658 // Discard this entry
659 continue;
660 }
661 }
662
663 print '<li class="directory collapsed">';
664 print '<a class="fmdirlia jqft ecmjqft" href="'.dolBuildUrl($_SERVER["PHP_SELF"], array('module' => $val['module'])).'">';
665 print dolPrintLabel($val['label']);
666 print '</a>';
667
668 print '<div class="ecmjqft">';
669 // Info
670 $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
671 $htmltooltip .= '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionAuto").'<br>';
672 $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto").'<br>';
673 $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['desc'];
674 print $form->textwithpicto('', $htmltooltip, 1, 'info');
675 print '</div>';
676
677 print '</li>';
678
679 $nbofentries++;
680 }
681
682 print '</ul></div></td></tr>';
683 }
684
685 print "</table>";
686}
687
688
689// End left panel
690?>
691</div>
692<div id="ecm-layout-center" class="inline-block">
693<div class="pane-in ecm-in-layout-center">
694<div id="ecmfileview" class="ecmfileview">
695<?php
696// Start right panel
697
698$mode = 'noajax';
699$url = DOL_URL_ROOT.'/ecm/index_auto.php';
700include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
701
702
703// End right panel
704?>
705</div>
706</div>
707
708</div>
709</div> <!-- End div id="containerlayout" -->
710<?php
711// End of page
712
713if (!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS')) {
714 include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
715}
716
717
718print dol_get_fiche_end();
719
720llxFooter();
721
722$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage ECM directories.
Class to manage suppliers invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
ecm_prepare_dasboard_head()
Prepare array with list of different ecm main dashboard.
Definition ecm.lib.php:33
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_basename($pathfile)
Make a basename working with all page code (default PHP basenamed fails with cyrillic).
Definition files.lib.php:40
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1, $nolog=0)
Remove a file or several files with a mask.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:65
dol_is_dir($folder)
Test if filename is a directory.
dol_now($mode='gmt')
Return date for now.
GETPOSTDATE($prefix, $hourTime='', $gm='auto', $saverestore='')
Helper function that combines values of a dolibarr DatePicker (such as Form\selectDate) for year,...
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
Definition html.lib.php:519
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:717
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
Definition html.lib.php:44
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
Definition html.lib.php:172
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.