29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
37$langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts"));
41$action =
GETPOST(
'action',
'aZ09');
43$module =
GETPOST(
'module',
'alpha');
47$section_dir =
GETPOST(
'section_dir',
'alpha');
49$search_doc_ref =
GETPOST(
'search_doc_ref',
'alpha');
52$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
53$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
55if (empty($page) || $page == -1) {
58$offset = $limit * $page;
65 $sortfield =
"fullname";
67if ($module ==
'invoice_supplier' && $sortfield ==
"fullname") {
68 $sortfield =
"level1name";
73 $result = $ecmdir->fetch($section);
82$userstatic =
new User($db);
88 $socid = $user->socid;
92$hookmanager->initHooks(array(
'ecmautocard',
'globalcard'));
102if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
103 $search_doc_ref =
'';
107if ($action ==
'add' && $user->hasRight(
'ecm',
'setup')) {
108 $ecmdir->ref =
'NOTUSEDYET';
109 $ecmdir->label =
GETPOST(
"label");
110 $ecmdir->description =
GETPOST(
"desc");
112 $id = $ecmdir->create($user);
114 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
125if ($action ==
'confirm_deletefile' && $user->hasRight(
'ecm',
'upload')) {
126 if (
GETPOST(
'confirm') ==
'yes') {
127 $langs->load(
"other");
129 $result = $ecmdir->fetch($section);
130 if (!($result > 0)) {
134 $relativepath = $ecmdir->getRelativePath();
138 $upload_dir = $conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
139 $file = $upload_dir.
"/".
GETPOST(
'urlfile');
148 $result = $ecmdir->changeNbOfFiles(
'-');
152 $action =
'file_manager';
156if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm') ==
'yes' && $user->hasRight(
'ecm',
'setup')) {
157 $result = $ecmdir->delete($user);
158 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
166if ($action ==
'refreshmanual' && $user->hasRight(
'ecm',
'read')) {
172 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
173 $diroutputslash .=
'/';
176 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
179 $sqltree = $ecmdirstatic->get_full_arbo(0);
186 foreach ($disktree as $dirdesc) {
187 $dirisindatabase = 0;
188 foreach ($sqltree as $dirsqldesc) {
189 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
190 $dirisindatabase = 1;
195 if (!$dirisindatabase) {
196 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
202 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
203 $relativepathtosearchparent = $relativepathmissing;
205 if (preg_match(
'/\//', $relativepathtosearchparent)) {
207 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
208 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
211 $parentdirisindatabase = 0;
212 foreach ($sqltree as $dirsqldesc) {
213 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
214 $parentdirisindatabase = $dirsqldesc[
'id'];
218 if ($parentdirisindatabase > 0) {
219 dol_syslog(
"Yes with id ".$parentdirisindatabase);
221 $fk_parent = $parentdirisindatabase;
232 if ($fk_parent >= 0) {
233 $ecmdirtmp->ref =
'NOTUSEDYET';
235 $ecmdirtmp->description =
'';
236 $ecmdirtmp->fk_parent = $fk_parent;
238 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
241 $id = $ecmdirtmp->create($user);
243 $newdirsql = array(
'id' =>
$id,
244 'id_mere' => $ecmdirtmp->fk_parent,
245 'label' => $ecmdirtmp->label,
246 'description' => $ecmdirtmp->description,
247 'fullrelativename' => $relativepathmissing);
248 $sqltree[] = $newdirsql;
252 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
255 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
263 foreach ($sqltree as $dirdesc) {
264 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
266 $ecmdirtmp->id = $dirdesc[
'id'];
267 $ecmdirtmp->delete($user,
'databaseonly');
272 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
278 if ($adirwascreated) {
291$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
297$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
299 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
302$moreheadjs .=
'<script type="text/javascript">'.
"\n";
303$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
304$moreheadjs .= '</script>
'."\n";
306llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', 0, 0, $morejs, '', '', 'mod-ecm page-index_auto
');
309// Add sections to manage
311$sectionauto = array();
312if (!getDolGlobalString('ECM_AUTO_TREE_HIDEN
')) {
313 if (isModEnabled("product") || isModEnabled("service")) {
314 $langs->load("products");
316 $sectionauto[] = array('position' => 10, 'level
' => 1, 'module
' => 'product
', 'test
' => (isModEnabled("product") || isModEnabled("service")), 'label
' => $langs->trans("ProductsAndServices"), 'desc
' => $langs->trans("ECMDocsByProducts"));
318 if (isModEnabled("societe")) {
320 $sectionauto[] = array('position' => 20, 'level
' => 1, 'module
' => 'company
', 'test
' => isModEnabled('societe
'), 'label
' => $langs->trans("ThirdParties"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
322 if (isModEnabled("propal")) {
324 $sectionauto[] = array('position' => 30, 'level
' => 1, 'module
' => 'propal
', 'test
' => isModEnabled('propal
'), 'label
' => $langs->trans("Proposals"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
326 if (isModEnabled('contract
')) {
328 $sectionauto[] = array('position' => 40, 'level
' => 1, 'module
' => 'contract
', 'test
' => isModEnabled('contract
'), 'label
' => $langs->trans("Contracts"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
330 if (isModEnabled('order
')) {
332 $sectionauto[] = array('position' => 50, 'level
' => 1, 'module
' => 'order
', 'test
' => isModEnabled('order
'), 'label
' => $langs->trans("CustomersOrders"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
334 if (isModEnabled('invoice
')) {
336 $sectionauto[] = array('position' => 60, 'level
' => 1, 'module
' => 'invoice
', 'test
' => isModEnabled('invoice
'), 'label
' => $langs->trans("CustomersInvoices"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
338 if (isModEnabled('supplier_proposal
')) {
339 $langs->load("supplier_proposal");
341 $sectionauto[] = array('position' => 70, 'level
' => 1, 'module
' => 'supplier_proposal
', 'test
' => isModEnabled('supplier_proposal
'), 'label
' => $langs->trans("SupplierProposals"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
343 if (isModEnabled("supplier_order")) {
345 $sectionauto[] = array('position' => 80, 'level
' => 1, 'module
' => 'order_supplier
', 'test
' => isModEnabled("supplier_order"), 'label
' => $langs->trans("SuppliersOrders"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
347 if (isModEnabled("supplier_invoice")) {
349 $sectionauto[] = array('position' => 90, 'level
' => 1, 'module
' => 'invoice_supplier
', 'test
' => isModEnabled("supplier_invoice"), 'label
' => $langs->trans("SuppliersInvoices"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
351 if (isModEnabled('tax
')) {
352 $langs->load("compta");
354 $sectionauto[] = array('position' => 100, 'level
' => 1, 'module
' => 'tax
', 'test
' => isModEnabled('tax
'), 'label
' => $langs->trans("SocialContributions"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
356 $sectionauto[] = array('position' => 110, 'level
' => 1, 'module
' => 'tax-vat
', 'test
' => isModEnabled('tax
'), 'label
' => $langs->trans("VAT"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT")));
358 if (isModEnabled('salaries
')) {
359 $langs->load("compta");
361 $sectionauto[] = array('position' => 120, 'level
' => 1, 'module
' => 'salaries
', 'test
' => isModEnabled('salaries
'), 'label
' => $langs->trans("Salaries"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries")));
363 if (isModEnabled('project
')) {
365 $sectionauto[] = array('position' => 130, 'level
' => 1, 'module
' => 'project
', 'test
' => isModEnabled('project
'), 'label
' => $langs->trans("Projects"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
367 $sectionauto[] = array('position' => 140, 'level
' => 1, 'module
' => 'project_task
', 'test
' => isModEnabled('project
'), 'label
' => $langs->trans("Tasks"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks")));
369 if (isModEnabled('intervention
')) {
370 $langs->load("interventions");
372 $sectionauto[] = array('position' => 150, 'level
' => 1, 'module
' => 'fichinter
', 'test
' => isModEnabled('intervention
'), 'label
' => $langs->trans("Interventions"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
374 if (isModEnabled('expensereport
')) {
375 $langs->load("trips");
377 $sectionauto[] = array('position' => 160, 'level
' => 1, 'module
' => 'expensereport
', 'test
' => isModEnabled('expensereport
'), 'label
' => $langs->trans("ExpenseReports"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
379 if (isModEnabled('holiday
')) {
380 $langs->load("holiday");
382 $sectionauto[] = array('position' => 170, 'level
' => 1, 'module
' => 'holiday
', 'test
' => isModEnabled('holiday
'), 'label
' => $langs->trans("Holidays"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
384 if (isModEnabled("bank")) {
385 $langs->load("banks");
387 $sectionauto[] = array('position' => 180, 'level
' => 1, 'module
' => 'banque
', 'test
' => isModEnabled('bank
'), 'label
' => $langs->trans("BankAccount"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
389 $sectionauto[] = array('position' => 190, 'level
' => 1, 'module
' => 'chequereceipt
', 'test
' => isModEnabled('bank
'), 'label
' => $langs->trans("CheckReceipt"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
391 if (isModEnabled('mrp
')) {
394 $sectionauto[] = array('position' => 200, 'level
' => 1, 'module
' => 'mrp-mo
', 'test
' => isModEnabled('mrp
'), 'label
' => $langs->trans("MOs"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
396 if (isModEnabled('recruitment
')) {
397 $langs->load("recruitment");
399 $sectionauto[] = array('position' => 210, 'level
' => 1, 'module
' => 'recruitment-recruitmentcandidature
', 'test
' => isModEnabled('recruitment
'), 'label
' => $langs->trans("Candidatures"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
402 $sectionauto[] = array('position' => 220, 'level
' => 1, 'module
' => 'user', 'test
' => 1, 'label
' => $langs->trans("Users"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
404 $parameters = array();
405 $reshook = $hookmanager->executeHooks('addSectionECMAuto
', $parameters);
406 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
407 $sectionauto[] = $hookmanager->resArray;
408 $rowspan += count($hookmanager->resArray);
412$head = ecm_prepare_dasboard_head();
413print dol_get_fiche_head($head, 'index_auto
', '', -1, '');
417// Confirm remove file (for non javascript users)
418if ($action == 'deletefile
' && empty($conf->use_javascript_ajax)) {
419 print $form->formconfirm($_SERVER["PHP_SELF"].'?section=
'.$section.'&urlfile=
'.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile
'), $langs->trans('ConfirmDeleteFile
'), 'confirm_deletefile
', '', '', 1);
422// Start container of all panels
424<!-- Begin div id="containerlayout" -->
425<div id="containerlayout">
426<div id="ecm-layout-north" class="toolbar largebutton">
429// Start top panel, toolbar
430print '<div
class=
"inline-block toolbarbutton centpercent">
';
433$url = ((!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS
')) ? '#
' : ($_SERVER["PHP_SELF"].'?action=refreshmanual
'.($module ? '&module=
'.$module : '').($section ? '&section=
'.$section : '')));
434print '<a href=
"'.$url.'" class=
"inline-block valignmiddle toolbarbutton paddingtop" title=
"'.dol_escape_htmltag($langs->trans('Refresh')).'">
';
435print img_picto('', 'refresh
', 'id=
"refreshbutton"', 0, 0, 0, '', 'size15x marginrightonly
');
439// End top panel, toolbar
443<div id="ecm-layout-west" class="inline-block">
448// Confirmation de la suppression d'une ligne categorie
449if ($action ==
'delete_section') {
450 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
455if (empty($action) || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'deletefile') {
456 print
'<table class="liste centpercent noborder">'.
"\n";
458 print
'<!-- Title for auto directories -->'.
"\n";
459 print
'<tr class="liste_titre">'.
"\n";
460 print
'<th class="liste_titre" align="left" colspan="6">';
461 print
' '.$langs->trans(
"ECMSections");
464 $showonrightsize =
'';
467 if (count($sectionauto)) {
468 $htmltooltip = $langs->trans(
"ECMAreaDesc2");
469 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
471 $sectionauto =
dol_sort_array($sectionauto,
'label',
'ASC', 1, 0);
474 print
'<td colspan="6">';
475 print
'<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
477 $arrayofmodulesforexternalusers = explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL'));
481 foreach ($sectionauto as $key => $val) {
482 if (empty($val[
'test'])) {
487 if ($user->socid > 0) {
490 if (! in_array($val[
'module'], $arrayofmodulesforexternalusers)) {
496 print
'<li class="directory collapsed">';
497 print
'<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER[
"PHP_SELF"].
'?module='.urlencode($val[
'module']).
'">';
501 print
'<div class="ecmjqft">';
503 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
504 $htmltooltip .=
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionAuto").
'<br>';
505 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$langs->trans(
"ECMTypeAuto").
'<br>';
506 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'desc'];
507 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
515 print
'</ul></div></td></tr>';
525<div
id=
"ecm-layout-center" class=
"inline-block">
526<div
class=
"pane-in ecm-in-layout-center">
527<div
id=
"ecmfileview" class=
"ecmfileview">
532$url = DOL_URL_ROOT.
'/ecm/index_auto.php';
533include_once DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
542</div> <!-- End div
id=
"containerlayout" -->
546if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_ECM_DISABLE_JS')) {
547 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
Class to manage ECM directories.
Class to manage Dolibarr users.
dol_basename($pathfile)
Make a basename working with all page code (default PHP basenamed fails with cyrillic).
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.
dol_is_dir($folder)
Test if filename is a directory.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dolPrintLabel($s)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db user
Active Directory does not allow anonymous connections.
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.