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 if ($result > 0) {
177 setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
178 } else {
179 setEventMessages($ecmdir->error, $ecmdir->errors, 'errors');
180 }
181
182 clearstatcache();
183}
184
185// Refresh directory view
186// This refresh list of dirs, not list of files (for performance reason). List of files is refresh only if dir was not synchronized.
187// To refresh content of dir with cache, just open the dir in edit mode.
188if ($action == 'refreshmanual' && $user->hasRight('ecm', 'read')) {
189 $ecmdirtmp = new EcmDirectory($db);
190
191 // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
192 clearstatcache();
193
194 $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output);
195 $diroutputslash .= '/';
196
197 // Scan directory tree on disk
198 $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', 0, 0);
199
200 // Scan directory tree in database
201 $treesqldir = $ecmdirstatic->get_full_arbo(0);
202
203 $adirwascreated = 0;
204
205 // Now we compare both trees to complete missing trees into database
206 //var_dump($disktree);
207 //var_dump($treesqldir);
208 foreach ($disktree as $dirdesc) { // Loop on tree onto disk
209 $dirisindatabase = 0;
210 foreach ($treesqldir as $dirsqldesc) {
211 if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
212 $dirisindatabase = 1;
213 break;
214 }
215 }
216
217 if (!$dirisindatabase) {
218 $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
219 dol_syslog($txt);
220 //print $txt."<br>\n";
221
222 // We must first find the fk_parent of directory to create $dirdesc['fullname']
223 $fk_parent = -1;
224 $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']);
225 $relativepathtosearchparent = $relativepathmissing;
226 //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
227 if (preg_match('/\//', $relativepathtosearchparent)) {
228 //while (preg_match('/\//',$relativepathtosearchparent))
229 $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent);
230 $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
231 dol_syslog($txt);
232 //print $txt." -> ";
233 $parentdirisindatabase = 0;
234 foreach ($treesqldir as $dirsqldesc) {
235 if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) {
236 $parentdirisindatabase = $dirsqldesc['id'];
237 break;
238 }
239 }
240 if ($parentdirisindatabase > 0) {
241 dol_syslog("Yes with id ".$parentdirisindatabase);
242 //print "Yes with id ".$parentdirisindatabase."<br>\n";
243 $fk_parent = $parentdirisindatabase;
244 //break; // We found parent, we can stop the while loop
245 } else {
246 dol_syslog("No");
247 //print "No<br>\n";
248 }
249 } else {
250 dol_syslog("Parent is root");
251 $fk_parent = 0; // Parent is root
252 }
253
254 if ($fk_parent >= 0) {
255 $ecmdirtmp->ref = 'NOTUSEDYET';
256 $ecmdirtmp->label = dol_basename($dirdesc['fullname']);
257 $ecmdirtmp->description = '';
258 $ecmdirtmp->fk_parent = $fk_parent;
259
260 $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent;
261 dol_syslog($txt);
262 //print $ecmdirtmp->cachenbofdoc."<br>\n";exit;
263 $id = $ecmdirtmp->create($user);
264 if ($id > 0) {
265 $newsqldir = array('id' => $id,
266 'id_mere' => $ecmdirtmp->fk_parent,
267 'label' => $ecmdirtmp->label,
268 'description' => $ecmdirtmp->description,
269 'fullrelativename' => $relativepathmissing);
270 $treesqldir[] = $newsqldir; // We complete fulltree for following loops
271 //var_dump($treesqldir);
272 $adirwascreated = 1;
273 } else {
274 dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
275 }
276 } else {
277 $txt = "Parent of ".$dirdesc['fullname']." not found";
278 dol_syslog($txt);
279 //print $txt."<br>\n";
280 }
281 }
282 }
283
284 // Loop now on each sql tree to check if dir exists
285 foreach ($treesqldir as $dirdesc) { // Loop on each treesqldir to check dir is on disk
286 $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
287 if (!dol_is_dir($dirtotest)) {
288 $ecmdirtmp->id = $dirdesc['id'];
289 $ecmdirtmp->delete($user, 'databaseonly');
290 //exit;
291 }
292 }
293
294 $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cache counting, we set to value -1 = "unknown"
295 dol_syslog("sql = ".$sql);
296 $db->query($sql);
297
298 // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean
299 // it to be sure that fulltree array is not used without reloading it.
300 if ($adirwascreated) {
301 $treesqldir = null;
302 }
303}
304
305// Download selected automatic ECM files for supplier invoices
306if ($action == 'download_selected' && $module == 'invoice_supplier' && !$user->hasRight('fournisseur', 'facture', 'lire')) {
308}
309if ($action == 'download_selected' && $module == 'invoice_supplier' && $user->hasRight('fournisseur', 'facture', 'lire')) {
310 $langs->loadLangs(array("errors", "accountancy"));
311
312 $selectedfiles = GETPOST('selectedfiles', 'array');
313 $selectedfiles = is_array($selectedfiles) ? $selectedfiles : array();
314 $maxformassaction = getDolGlobalInt('MAIN_LIMIT_FOR_MASS_ACTIONS', 1000);
315
316 if (count($selectedfiles) < 1) {
317 setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
318 } elseif (count($selectedfiles) > $maxformassaction) {
319 setEventMessages($langs->trans("TooManyRecordForMassAction", $maxformassaction), null, 'errors');
320 } elseif (!class_exists('ZipArchive')) {
321 setEventMessages('ZipArchive PHP extension is not available', null, 'errors');
322 } else {
323 include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
324
325 $upload_dir = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output;
326 $basepath = realpath($upload_dir);
327 $basepathwithslash = ($basepath ? rtrim($basepath, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : '');
328 $filestoarchive = array();
329 $invoicecache = array();
330
331 foreach ($selectedfiles as $selectedfile) {
332 if (!is_scalar($selectedfile)) {
333 continue;
334 }
335
336 $relativefile = str_replace('\\', '/', (string) $selectedfile);
337 $relativefile = preg_replace('/\/+/', '/', $relativefile);
338 $relativefile = ltrim($relativefile, '/');
339
340 if ($relativefile == ''
341 || preg_match('/(^|\/)\.\.(\/|$)/', $relativefile)
342 || preg_match('/[<>|\x00-\x1F]/', $relativefile)
343 || preg_match('/(^|\/)(temp|thumbs|CVS|payments)(\/|$)/i', $relativefile)
344 || preg_match('/(\.meta|_preview.*\.png)$/i', $relativefile)
345 ) {
346 continue;
347 }
348
349 $reg = array();
350 preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg);
351 $ref = (isset($reg[1]) ? $reg[1] : '');
352 $id = 0;
353 if ($ref === '') {
354 continue;
355 }
356 if (is_numeric($ref)) {
357 $id = (int) $ref;
358 $ref = '';
359 }
360
361 $cachekey = $id.'_'.$ref;
362 if (!array_key_exists($cachekey, $invoicecache)) {
363 $invoicecache[$cachekey] = false;
364 $objecttmp = new FactureFournisseur($db);
365 $result = 0;
366 if ($id > 0) {
367 $result = $objecttmp->fetch($id);
368 } else {
369 if (!($result = $objecttmp->fetch(0, $ref))) {
370 $result = $objecttmp->fetchOneLike($ref);
371 }
372 }
373 if ($result > 0 && (int) $objecttmp->entity === (int) $conf->entity) {
374 $invoicecache[$cachekey] = true;
375 }
376 }
377 if (empty($invoicecache[$cachekey])) {
378 continue;
379 }
380
381 $fullpath = realpath($upload_dir.'/'.$relativefile);
382 if (empty($basepath) || empty($fullpath) || strpos($fullpath, $basepathwithslash) !== 0 || !is_file($fullpath)) {
383 continue;
384 }
385
386 $filestoarchive[$relativefile] = $fullpath;
387 }
388
389 if (count($filestoarchive) < 1) {
390 setEventMessages($langs->trans("NoRecordSelected"), null, 'warnings');
391 } else {
392 $tmpdir = DOL_DATA_ROOT.'/ecm/temp';
393 dol_mkdir($tmpdir);
394
395 if (!is_writable($tmpdir)) {
396 setEventMessages($langs->trans("ErrorFailedToWriteInDir", $tmpdir), null, 'errors');
397 } else {
398 $zipfilename = 'supplier_invoice_documents_'.dol_print_date(dol_now(), 'dayhourlog').'.zip';
399 $zipfullpath = $tmpdir.'/'.$zipfilename;
400
401 $zip = new ZipArchive();
402 $result = $zip->open($zipfullpath, ZipArchive::CREATE | ZipArchive::OVERWRITE);
403 if ($result !== true) {
404 setEventMessages($langs->trans("ErrorFailedToBuildArchive", $zipfullpath), null, 'errors');
405 } else {
406 $errorarchive = 0;
407 foreach ($filestoarchive as $relativefile => $fullpath) {
408 $result = $zip->addFile($fullpath, $relativefile);
409 if (!$result) {
410 $errorarchive++;
411 setEventMessages($langs->trans("ErrorArchiveAddFile", $relativefile), null, 'errors');
412 break;
413 }
414 }
415 $closeok = $zip->close();
416
417 if ($errorarchive || !$closeok || !is_file($zipfullpath)) {
418 if (!$errorarchive) {
419 setEventMessages($langs->trans("ErrorFailedToBuildArchive", $zipfullpath), null, 'errors');
420 }
421 dol_delete_file($zipfullpath, 1, 0, 1, null, false, 0, 1);
422 } else {
423 top_httphead('application/zip');
424 header('Content-Disposition: attachment; filename="'.$zipfilename.'"');
425 header('Content-Length: '.filesize($zipfullpath));
426 readfile($zipfullpath);
427 dol_delete_file($zipfullpath, 1, 0, 1, null, false, 0, 1);
428 $db->close();
429 exit;
430 }
431 }
432 }
433 }
434 }
435
436 $action = '';
437}
438
439
440
441/*
442 * View
443 */
444
445// Define height of file area (depends on $_SESSION["dol_screenheight"])
446//print $_SESSION["dol_screenheight"];
447$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466) ? ($_SESSION["dol_screenheight"] - 136) : 660; // Also into index.php file
448
449$moreheadcss = '';
450$moreheadjs = '';
451
452$morejs=array();
453if (!getDolGlobalString('MAIN_ECM_DISABLE_JS')) {
454 $morejs[] = "public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
455}
456
457llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', '', 'mod-ecm page-index_auto');
458
459
460// Add sections to manage
461$rowspan = 0;
462$sectionauto = array();
463if (!getDolGlobalString('ECM_AUTO_TREE_HIDEN')) {
464 if (isModEnabled("product") || isModEnabled("service")) {
465 $langs->load("products");
466 $rowspan++;
467 $sectionauto[] = array('position' => 10, 'level' => 1, 'module' => 'product', 'test' => $user->hasRight('produit', 'lire'), 'label' => $langs->trans("ProductsAndServices"), 'desc' => $langs->trans("ECMDocsByProducts"));
468 }
469 if (isModEnabled("societe")) {
470 $rowspan++;
471 $sectionauto[] = array('position' => 20, 'level' => 1, 'module' => 'company', 'test' => $user->hasRight('societe', 'lire'), 'label' => $langs->trans("ThirdParties"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
472 }
473 if (isModEnabled("propal")) {
474 $rowspan++;
475 $sectionauto[] = array('position' => 30, 'level' => 1, 'module' => 'propal', 'test' => $user->hasRight('propale', 'lire'), 'label' => $langs->trans("Proposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
476 }
477 if (isModEnabled('contract')) {
478 $rowspan++;
479 $sectionauto[] = array('position' => 40, 'level' => 1, 'module' => 'contract', 'test' => $user->hasRight('contrat', 'lire'), 'label' => $langs->trans("Contracts"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
480 }
481 if (isModEnabled('order')) {
482 $rowspan++;
483 $sectionauto[] = array('position' => 50, 'level' => 1, 'module' => 'order', 'test' => $user->hasRight('commande', 'lire'), 'label' => $langs->trans("CustomersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
484 }
485 if (isModEnabled('invoice')) {
486 $rowspan++;
487 $sectionauto[] = array('position' => 60, 'level' => 1, 'module' => 'invoice', 'test' => $user->hasRight('facture', 'lire'), 'label' => $langs->trans("CustomersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
488 }
489 if (isModEnabled('supplier_proposal')) {
490 $langs->load("supplier_proposal");
491 $rowspan++;
492 $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")));
493 }
494 if (isModEnabled("supplier_order")) {
495 $rowspan++;
496 $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")));
497 }
498 if (isModEnabled("supplier_invoice")) {
499 $rowspan++;
500 $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")));
501 }
502 if (isModEnabled('tax')) {
503 $langs->load("compta");
504 $rowspan++;
505 $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")));
506 $rowspan++;
507 $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")));
508 }
509 if (isModEnabled('salaries')) {
510 $langs->load("compta");
511 $rowspan++;
512 $sectionauto[] = array('position' => 120, 'level' => 1, 'module' => 'salaries', 'test' => $user->hasRight('salaries', 'read'), 'label' => $langs->trans("Salaries"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries")));
513 }
514 if (isModEnabled('project')) {
515 $rowspan++;
516 $sectionauto[] = array('position' => 130, 'level' => 1, 'module' => 'project', 'test' => 1, 'label' => $langs->trans("Projects"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
517 $rowspan++;
518 $sectionauto[] = array('position' => 140, 'level' => 1, 'module' => 'project_task', 'test' => 1, 'label' => $langs->trans("Tasks"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks")));
519 }
520 if (isModEnabled('intervention')) {
521 $langs->load("interventions");
522 $rowspan++;
523 $sectionauto[] = array('position' => 150, 'level' => 1, 'module' => 'fichinter', 'test' => $user->hasRight('ficheinter', 'lire'), 'label' => $langs->trans("Interventions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
524 }
525 if (isModEnabled('expensereport')) {
526 $langs->load("trips");
527 $rowspan++;
528 $sectionauto[] = array('position' => 160, 'level' => 1, 'module' => 'expensereport', 'test' => $user->hasRight('expensereport', 'lire'), 'label' => $langs->trans("ExpenseReports"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
529 }
530 if (isModEnabled('holiday')) {
531 $langs->load("holiday");
532 $rowspan++;
533 $sectionauto[] = array('position' => 170, 'level' => 1, 'module' => 'holiday', 'test' => $user->hasRight('holiday', 'read'), 'label' => $langs->trans("Holidays"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
534 }
535 if (isModEnabled("bank")) {
536 $langs->load("banks");
537 $rowspan++;
538 $sectionauto[] = array('position' => 180, 'level' => 1, 'module' => 'banque', 'test' => $user->hasRight('banque', 'lire'), 'label' => $langs->trans("BankAccount"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
539 // TODO Enable this
540 //$rowspan++;
541 //$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")));
542 $rowspan++;
543 $sectionauto[] = array('position' => 190, 'level' => 1, 'module' => 'chequereceipt', 'test' => $user->hasRight('banque', 'lire'), 'label' => $langs->trans("CheckReceipt"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
544 }
545 if (isModEnabled('mrp')) {
546 $langs->load("mrp");
547 $rowspan++;
548 $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")));
549 }
550 if (isModEnabled('recruitment')) {
551 $langs->load("recruitment");
552 $rowspan++;
553 $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")));
554 }
555 $rowspan++;
556 $sectionauto[] = array('position' => 220, 'level' => 1, 'module' => 'user', 'test' => 1, 'label' => $langs->trans("Users"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
557
558 $parameters = array();
559 $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
560 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
561 $res = $hookmanager->resArray[0];
562 if (is_array($hookmanager->resArray[0])) {
563 $sectionauto = array_merge($sectionauto, $hookmanager->resArray);
564 $rowspan += count($hookmanager->resArray);
565 } else {
566 $sectionauto[] = $hookmanager->resArray;
567 $rowspan++;
568 }
569 }
570}
571
573print dol_get_fiche_head($head, 'index_auto', '', -1, '');
574
575
576
577// Confirm remove file (for non javascript users)
578if ($action == 'deletefile' && empty($conf->use_javascript_ajax)) {
579 print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], array('section' => $section, 'urlfile' => GETPOST("urlfile"))), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
580}
581
582// Start container of all panels
583?>
584<!-- Begin div id="containerlayout" -->
585<div id="containerlayout">
586<div id="ecm-layout-north" class="toolbar largebutton">
587<?php
588
589// Start top panel, toolbar
590print '<div class="inline-block toolbarbutton centpercent">';
591
592// Toolbar
593if (!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS')) {
594 $url = '#';
595} else {
596 $paramsrefresh = array('action' => 'refreshmanual');
597 if ($module) {
598 $paramsrefresh['module'] = $module;
599 }
600 if ($section) {
601 $paramsrefresh['section'] = $section;
602 }
603 $url = dolBuildUrl($_SERVER["PHP_SELF"], $paramsrefresh);
604}
605print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
606print img_picto('', 'refresh', 'id="refreshbutton"', 0, 0, 0, '', 'size15x marginrightonly');
607print '</a>';
608
609print '</div>';
610// End top panel, toolbar
611
612?>
613</div>
614<div id="ecm-layout-west" class="inline-block">
615<?php
616// Start left area
617
618
619// Generate form to confirm the deletion of a category line
620if ($action == 'delete_section') {
621 print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], array('section' => $section)), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1);
622}
623// End confirm
624
625
626if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'deletefile') {
627 print '<table class="liste centpercent noborder">'."\n";
628
629 print '<!-- Title for auto directories -->'."\n";
630 print '<tr class="liste_titre">'."\n";
631 print '<th class="liste_titre" align="left" colspan="6">';
632 print '&nbsp;'.$langs->trans("ECMSections");
633 print '</th></tr>';
634
635 $showonrightsize = '';
636
637 // Auto section
638 if (count($sectionauto)) {
639 $htmltooltip = $langs->trans("ECMAreaDesc2");
640 $htmltooltip .= '<br>'.$langs->trans("ECMAreaDesc2b");
641
642 $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', 1, 0);
643
644 print '<tr>';
645 print '<td colspan="6">';
646 print '<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
647
648 $arrayofmodulesforexternalusers = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL'));
649
650 $nbofentries = 0;
651 $oldvallevel = 0;
652 foreach ($sectionauto as $key => $val) {
653 if (empty($val['test'])) {
654 continue; // If condition to show the ECM auto directory is ok
655 }
656
657 // External users are not allowed to see manual directories so we quit.
658 if ($user->socid > 0) {
659 // Check if dir is allowed to external users
660 //var_dump($conf->global->MAIN_MODULES_FOR_EXTERNAL);
661 if (! in_array($val['module'], $arrayofmodulesforexternalusers)) {
662 // Discard this entry
663 continue;
664 }
665 }
666
667 print '<li class="directory collapsed">';
668 print '<a class="fmdirlia jqft ecmjqft" href="'.dolBuildUrl($_SERVER["PHP_SELF"], array('module' => $val['module'])).'">';
669 print dolPrintLabel($val['label']);
670 print '</a>';
671
672 print '<div class="ecmjqft">';
673 // Info
674 $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
675 $htmltooltip .= '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionAuto").'<br>';
676 $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto").'<br>';
677 $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['desc'];
678 print $form->textwithpicto('', $htmltooltip, 1, 'info');
679 print '</div>';
680
681 print '</li>';
682
683 $nbofentries++;
684 }
685
686 print '</ul></div></td></tr>';
687 }
688
689 print "</table>";
690}
691
692
693// End left panel
694?>
695</div>
696<div id="ecm-layout-center" class="inline-block">
697<div class="pane-in ecm-in-layout-center">
698<div id="ecmfileview" class="ecmfileview">
699<?php
700// Start right panel
701
702$mode = 'noajax';
703$url = DOL_URL_ROOT.'/ecm/index_auto.php';
704include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
705
706
707// End right panel
708?>
709</div>
710</div>
711
712</div>
713</div> <!-- End div id="containerlayout" -->
714<?php
715// End of page
716
717if (!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS')) {
718 include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
719}
720
721
722print dol_get_fiche_end();
723
724llxFooter();
725
726$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.
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
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:
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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)
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:540
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Definition html.lib.php:738
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Definition html.lib.php:181
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, $nodie=0, $mode='')
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.