28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
36$langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts"));
40$action =
GETPOST(
'action',
'aZ09');
42$module =
GETPOST(
'module',
'alpha');
46$section_dir =
GETPOST(
'section_dir',
'alpha');
48$search_doc_ref =
GETPOST(
'search_doc_ref',
'alpha');
51$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
52$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
54if (empty($page) || $page == -1) {
57$offset = $limit * $page;
64 $sortfield =
"fullname";
66if ($module ==
'invoice_supplier' && $sortfield ==
"fullname") {
67 $sortfield =
"level1name";
72 $result = $ecmdir->fetch($section);
81$userstatic =
new User($db);
87 $socid = $user->socid;
97$hookmanager->initHooks(array(
'ecmautocard',
'globalcard'));
100if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
101 $search_doc_ref =
'';
108if ($action ==
'add' && $user->hasRight(
'ecm',
'setup')) {
109 $ecmdir->ref =
'NOTUSEDYET';
110 $ecmdir->label =
GETPOST(
"label");
111 $ecmdir->description =
GETPOST(
"desc");
113 $id = $ecmdir->create($user);
115 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
126if ($action ==
'confirm_deletefile') {
127 if (
GETPOST(
'confirm') ==
'yes') {
128 $langs->load(
"other");
130 $result = $ecmdir->fetch($section);
131 if (!($result > 0)) {
135 $relativepath = $ecmdir->getRelativePath();
139 $upload_dir = $conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
140 $file = $upload_dir.
"/".
GETPOST(
'urlfile');
149 $result = $ecmdir->changeNbOfFiles(
'-');
153 $action =
'file_manager';
157if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm') ==
'yes') {
158 $result = $ecmdir->delete($user);
159 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
167if ($action ==
'refreshmanual') {
173 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
174 $diroutputslash .=
'/';
177 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
180 $sqltree = $ecmdirstatic->get_full_arbo(0);
187 foreach ($disktree as $dirdesc) {
188 $dirisindatabase = 0;
189 foreach ($sqltree as $dirsqldesc) {
190 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
191 $dirisindatabase = 1;
196 if (!$dirisindatabase) {
197 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
203 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
204 $relativepathtosearchparent = $relativepathmissing;
206 if (preg_match(
'/\//', $relativepathtosearchparent)) {
208 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
209 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
212 $parentdirisindatabase = 0;
213 foreach ($sqltree as $dirsqldesc) {
214 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
215 $parentdirisindatabase = $dirsqldesc[
'id'];
219 if ($parentdirisindatabase > 0) {
220 dol_syslog(
"Yes with id ".$parentdirisindatabase);
222 $fk_parent = $parentdirisindatabase;
233 if ($fk_parent >= 0) {
234 $ecmdirtmp->ref =
'NOTUSEDYET';
236 $ecmdirtmp->description =
'';
237 $ecmdirtmp->fk_parent = $fk_parent;
239 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
242 $id = $ecmdirtmp->create($user);
244 $newdirsql = array(
'id' => $id,
245 'id_mere' => $ecmdirtmp->fk_parent,
246 'label' => $ecmdirtmp->label,
247 'description' => $ecmdirtmp->description,
248 'fullrelativename' => $relativepathmissing);
249 $sqltree[] = $newdirsql;
253 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
256 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
264 foreach ($sqltree as $dirdesc) {
265 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
267 $ecmdirtmp->id = $dirdesc[
'id'];
268 $ecmdirtmp->delete($user,
'databaseonly');
273 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
279 if ($adirwascreated) {
292$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
298$morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
300 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
303$moreheadjs .=
'<script type="text/javascript">'.
"\n";
304$moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
305$moreheadjs .= '</script>
'."\n";
307llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
310// Add sections to manage
312$sectionauto = array();
313if (!getDolGlobalString('ECM_AUTO_TREE_HIDEN
')) {
314 if (isModEnabled("product") || isModEnabled("service")) {
315 $langs->load("products");
317 $sectionauto[] = array('position' => 10, 'level
' => 1, 'module
' => 'product
', 'test
' => (isModEnabled("product") || isModEnabled("service")), 'label
' => $langs->trans("ProductsAndServices"), 'desc
' => $langs->trans("ECMDocsByProducts"));
319 if (isModEnabled("societe")) {
321 $sectionauto[] = array('position' => 20, 'level
' => 1, 'module
' => 'company
', 'test
' => isModEnabled('societe
'), 'label
' => $langs->trans("ThirdParties"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
323 if (isModEnabled("propal")) {
325 $sectionauto[] = array('position' => 30, 'level
' => 1, 'module
' => 'propal
', 'test
' => isModEnabled('propal
'), 'label
' => $langs->trans("Proposals"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
327 if (isModEnabled('contract
')) {
329 $sectionauto[] = array('position' => 40, 'level
' => 1, 'module
' => 'contract
', 'test
' => isModEnabled('contract
'), 'label
' => $langs->trans("Contracts"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
331 if (isModEnabled('order
')) {
333 $sectionauto[] = array('position' => 50, 'level
' => 1, 'module
' => 'order
', 'test
' => isModEnabled('order
'), 'label
' => $langs->trans("CustomersOrders"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
335 if (isModEnabled('invoice
')) {
337 $sectionauto[] = array('position' => 60, 'level
' => 1, 'module
' => 'invoice
', 'test
' => isModEnabled('invoice
'), 'label
' => $langs->trans("CustomersInvoices"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
339 if (isModEnabled('supplier_proposal
')) {
340 $langs->load("supplier_proposal");
342 $sectionauto[] = array('position' => 70, 'level
' => 1, 'module
' => 'supplier_proposal
', 'test
' => isModEnabled('supplier_proposal
'), 'label
' => $langs->trans("SupplierProposals"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
344 if (isModEnabled("supplier_order")) {
346 $sectionauto[] = array('position' => 80, 'level
' => 1, 'module
' => 'order_supplier
', 'test
' => isModEnabled("supplier_order"), 'label
' => $langs->trans("SuppliersOrders"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
348 if (isModEnabled("supplier_invoice")) {
350 $sectionauto[] = array('position' => 90, 'level
' => 1, 'module
' => 'invoice_supplier
', 'test
' => isModEnabled("supplier_invoice"), 'label
' => $langs->trans("SuppliersInvoices"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
352 if (isModEnabled('tax
')) {
353 $langs->load("compta");
355 $sectionauto[] = array('position' => 100, 'level
' => 1, 'module
' => 'tax
', 'test
' => isModEnabled('tax
'), 'label
' => $langs->trans("SocialContributions"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
357 $sectionauto[] = array('position' => 110, 'level
' => 1, 'module
' => 'tax-vat
', 'test
' => isModEnabled('tax
'), 'label
' => $langs->trans("VAT"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT")));
359 if (isModEnabled('salaries
')) {
360 $langs->load("compta");
362 $sectionauto[] = array('position' => 120, 'level
' => 1, 'module
' => 'salaries
', 'test
' => isModEnabled('salaries
'), 'label
' => $langs->trans("Salaries"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries")));
364 if (isModEnabled('project
')) {
366 $sectionauto[] = array('position' => 130, 'level
' => 1, 'module
' => 'project
', 'test
' => isModEnabled('project
'), 'label
' => $langs->trans("Projects"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
368 $sectionauto[] = array('position' => 140, 'level
' => 1, 'module
' => 'project_task
', 'test
' => isModEnabled('project
'), 'label
' => $langs->trans("Tasks"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks")));
370 if (isModEnabled('intervention
')) {
371 $langs->load("interventions");
373 $sectionauto[] = array('position' => 150, 'level
' => 1, 'module
' => 'fichinter
', 'test
' => isModEnabled('intervention
'), 'label
' => $langs->trans("Interventions"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
375 if (isModEnabled('expensereport
')) {
376 $langs->load("trips");
378 $sectionauto[] = array('position' => 160, 'level
' => 1, 'module
' => 'expensereport
', 'test
' => isModEnabled('expensereport
'), 'label
' => $langs->trans("ExpenseReports"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
380 if (isModEnabled('holiday
')) {
381 $langs->load("holiday");
383 $sectionauto[] = array('position' => 170, 'level
' => 1, 'module
' => 'holiday
', 'test
' => isModEnabled('holiday
'), 'label
' => $langs->trans("Holidays"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
385 if (isModEnabled("bank")) {
386 $langs->load("banks");
388 $sectionauto[] = array('position' => 180, 'level
' => 1, 'module
' => 'banque
', 'test
' => isModEnabled('bank
'), 'label
' => $langs->trans("BankAccount"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
390 $sectionauto[] = array('position' => 190, 'level
' => 1, 'module
' => 'chequereceipt
', 'test
' => isModEnabled('bank
'), 'label
' => $langs->trans("CheckReceipt"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
392 if (isModEnabled('mrp
')) {
395 $sectionauto[] = array('position' => 200, 'level
' => 1, 'module
' => 'mrp-mo
', 'test
' => isModEnabled('mrp
'), 'label
' => $langs->trans("MOs"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
397 if (isModEnabled('recruitment
')) {
398 $langs->load("recruitment");
400 $sectionauto[] = array('position' => 210, 'level
' => 1, 'module
' => 'recruitment-recruitmentcandidature
', 'test
' => isModEnabled('recruitment
'), 'label
' => $langs->trans("Candidatures"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
403 $sectionauto[] = array('position' => 220, 'level
' => 1, 'module
' => 'user', 'test
' => 1, 'label
' => $langs->trans("Users"), 'desc
' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
405 $parameters = array();
406 $reshook = $hookmanager->executeHooks('addSectionECMAuto
', $parameters);
407 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
408 $sectionauto[] = $hookmanager->resArray;
409 $rowspan += count($hookmanager->resArray);
413$head = ecm_prepare_dasboard_head(null);
414print dol_get_fiche_head($head, 'index_auto
', '', -1, '');
418// Confirm remove file (for non javascript users)
419if ($action == 'deletefile
' && empty($conf->use_javascript_ajax)) {
420 print $form->formconfirm($_SERVER["PHP_SELF"].'?section=
'.$section.'&urlfile=
'.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile
'), $langs->trans('ConfirmDeleteFile
'), 'confirm_deletefile
', '', '', 1);
423// Start container of all panels
425<!-- Begin div id="containerlayout" -->
426<div id="containerlayout">
427<div id="ecm-layout-north" class="toolbar largebutton">
430// Start top panel, toolbar
431print '<div
class=
"inline-block toolbarbutton centpercent">
';
434$url = ((!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_ECM_DISABLE_JS
')) ? '#
' : ($_SERVER["PHP_SELF"].'?action=refreshmanual
'.($module ? '&module=
'.$module : '').($section ? '&section=
'.$section : '')));
435print '<a href=
"'.$url.'" class=
"inline-block valignmiddle toolbarbutton paddingtop" title=
"'.dol_escape_htmltag($langs->trans('Refresh')).'">
';
436print img_picto('', 'refresh
', 'id=
"refreshbutton"', false, 0, 0, '', 'size15x marginrightonly
');
440// End top panel, toolbar
444<div id="ecm-layout-west" class="inline-block">
449// Confirmation de la suppression d'une ligne categorie
450if ($action ==
'delete_section') {
451 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
456if (empty($action) || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'deletefile') {
457 print
'<table class="liste centpercent">'.
"\n";
459 print
'<!-- Title for auto directories -->'.
"\n";
460 print
'<tr class="liste_titre">'.
"\n";
461 print
'<th class="liste_titre" align="left" colspan="6">';
462 print
' '.$langs->trans(
"ECMSections");
465 $showonrightsize =
'';
467 if (count($sectionauto)) {
468 $htmltooltip = $langs->trans(
"ECMAreaDesc2");
469 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
471 $sectionauto =
dol_sort_array($sectionauto,
'label',
'ASC',
true,
false);
474 print
'<td colspan="6">';
475 print
'<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
479 foreach ($sectionauto as $key => $val) {
480 if (empty($val[
'test'])) {
484 print
'<li class="directory collapsed">';
485 print
'<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER[
"PHP_SELF"].
'?module='.urlencode($val[
'module']).
'">';
489 print
'<div class="ecmjqft">';
491 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
492 $htmltooltip .=
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionAuto").
'<br>';
493 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$langs->trans(
"ECMTypeAuto").
'<br>';
494 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'desc'];
495 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
503 print
'</ul></div></td></tr>';
513<div
id=
"ecm-layout-center" class=
"inline-block">
514<div
class=
"pane-in ecm-in-layout-center">
515<div
id=
"ecmfileview" class=
"ecmfileview">
520$url = DOL_URL_ROOT.
'/ecm/index_auto.php';
521include_once DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
530</div> <!-- End div
id=
"containerlayout" -->
534if (!empty($conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_ECM_DISABLE_JS')) {
535 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.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
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.