26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
34 $langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts"));
38 $socid = $user->socid;
43 $socid =
GETPOST(
'socid',
'int');
44 $action =
GETPOST(
'action',
'aZ09');
46 $module =
GETPOST(
'module',
'alpha');
50 $section_dir =
GETPOST(
'section_dir',
'alpha');
52 $search_doc_ref =
GETPOST(
'search_doc_ref',
'alpha');
54 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
55 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
56 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58 if (empty($page) || $page == -1) {
61 $offset = $limit * $page;
62 $pageprev = $page - 1;
63 $pagenext = $page + 1;
68 $sortfield =
"fullname";
70 if ($module ==
'invoice_supplier' && $sortfield ==
"fullname") {
71 $sortfield =
"level1name";
76 $result = $ecmdir->fetch($section);
85 $userstatic =
new User($db);
95 $hookmanager->initHooks(array(
'ecmautocard',
'globalcard'));
98 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
106 if ($action ==
'add' && $user->rights->ecm->setup) {
107 $ecmdir->ref =
'NOTUSEDYET';
108 $ecmdir->label =
GETPOST(
"label");
109 $ecmdir->description =
GETPOST(
"desc");
111 $id = $ecmdir->create($user);
113 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
124 if ($action ==
'confirm_deletefile') {
125 if (
GETPOST(
'confirm') ==
'yes') {
126 $langs->load(
"other");
128 $result = $ecmdir->fetch($section);
129 if (!($result > 0)) {
133 $relativepath = $ecmdir->getRelativePath();
137 $upload_dir = $conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
138 $file = $upload_dir.
"/".
GETPOST(
'urlfile');
147 $result = $ecmdir->changeNbOfFiles(
'-');
151 $action =
'file_manager';
155 if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm') ==
'yes') {
156 $result = $ecmdir->delete($user);
157 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
165 if ($action ==
'refreshmanual') {
171 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
172 $diroutputslash .=
'/';
175 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
178 $sqltree = $ecmdirstatic->get_full_arbo(0);
185 foreach ($disktree as $dirdesc) {
186 $dirisindatabase = 0;
187 foreach ($sqltree as $dirsqldesc) {
188 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
189 $dirisindatabase = 1;
194 if (!$dirisindatabase) {
195 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
201 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
202 $relativepathtosearchparent = $relativepathmissing;
204 if (preg_match(
'/\//', $relativepathtosearchparent)) {
206 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
207 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
210 $parentdirisindatabase = 0;
211 foreach ($sqltree as $dirsqldesc) {
212 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
213 $parentdirisindatabase = $dirsqldesc[
'id'];
217 if ($parentdirisindatabase > 0) {
218 dol_syslog(
"Yes with id ".$parentdirisindatabase);
220 $fk_parent = $parentdirisindatabase;
231 if ($fk_parent >= 0) {
232 $ecmdirtmp->ref =
'NOTUSEDYET';
234 $ecmdirtmp->description =
'';
235 $ecmdirtmp->fk_parent = $fk_parent;
237 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
240 $id = $ecmdirtmp->create($user);
242 $newdirsql = array(
'id'=>$id,
243 'id_mere'=>$ecmdirtmp->fk_parent,
244 'label'=>$ecmdirtmp->label,
245 'description'=>$ecmdirtmp->description,
246 'fullrelativename'=>$relativepathmissing);
247 $sqltree[] = $newdirsql;
251 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
254 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
262 foreach ($sqltree as $dirdesc) {
263 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
265 $ecmdirtmp->id = $dirdesc[
'id'];
266 $ecmdirtmp->delete($user,
'databaseonly');
271 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
277 if ($adirwascreated) {
290 $maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
296 $morejs = array(
'includes/jquery/plugins/blockUI/jquery.blockUI.js',
'core/js/blockUI.js');
297 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
298 $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
301 $moreheadjs .=
'<script type="text/javascript">'.
"\n";
302 $moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
303 $moreheadjs .= '</script>
'."\n";
305 llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
308 // Add sections to manage
310 $sectionauto = array();
311 if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) {
312 if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
313 $langs->load("products");
314 $rowspan++; $sectionauto[] = array('position
'=>10, 'level
'=>1, 'module
'=>'product
', 'test
'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label
'=>$langs->trans("ProductsAndServices"), 'desc
'=>$langs->trans("ECMDocsByProducts"));
316 if (!empty($conf->societe->enabled)) {
317 $rowspan++; $sectionauto[] = array('position
'=>20, 'level
'=>1, 'module
'=>'company
', 'test
'=>$conf->societe->enabled, 'label
'=>$langs->trans("ThirdParties"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
319 if (!empty($conf->propal->enabled)) {
320 $rowspan++; $sectionauto[] = array('position
'=>30, 'level
'=>1, 'module
'=>'propal
', 'test
'=>$conf->propal->enabled, 'label
'=>$langs->trans("Proposals"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
322 if (!empty($conf->contrat->enabled)) {
323 $rowspan++; $sectionauto[] = array('position
'=>40, 'level
'=>1, 'module
'=>'contract
', 'test
'=>$conf->contrat->enabled, 'label
'=>$langs->trans("Contracts"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
325 if (!empty($conf->commande->enabled)) {
326 $rowspan++; $sectionauto[] = array('position
'=>50, 'level
'=>1, 'module
'=>'order
', 'test
'=>$conf->commande->enabled, 'label
'=>$langs->trans("CustomersOrders"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
328 if (isModEnabled('facture
')) {
329 $rowspan++; $sectionauto[] = array('position
'=>60, 'level
'=>1, 'module
'=>'invoice
', 'test
'=>$conf->facture->enabled, 'label
'=>$langs->trans("CustomersInvoices"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
331 if (!empty($conf->supplier_proposal->enabled)) {
332 $langs->load("supplier_proposal");
333 $rowspan++; $sectionauto[] = array('position
'=>70, 'level
'=>1, 'module
'=>'supplier_proposal
', 'test
'=>$conf->supplier_proposal->enabled, 'label
'=>$langs->trans("SupplierProposals"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
335 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) {
336 $rowspan++; $sectionauto[] = array('position
'=>80, 'level
'=>1, 'module
'=>'order_supplier
', 'test
'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)), 'label
'=>$langs->trans("SuppliersOrders"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
338 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) {
339 $rowspan++; $sectionauto[] = array('position
'=>90, 'level
'=>1, 'module
'=>'invoice_supplier
', 'test
'=>(!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)), 'label
'=>$langs->trans("SuppliersInvoices"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
341 if (!empty($conf->tax->enabled)) {
342 $langs->load("compta");
343 $rowspan++; $sectionauto[] = array('position
'=>100, 'level
'=>1, 'module
'=>'tax
', 'test
'=>$conf->tax->enabled, 'label
'=>$langs->trans("SocialContributions"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
344 $rowspan++; $sectionauto[] = array('position
'=>110, 'level
'=>1, 'module
'=>'tax-vat
', 'test
'=>$conf->tax->enabled, 'label
'=>$langs->trans("VAT"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT")));
346 if (!empty($conf->salaries->enabled)) {
347 $langs->load("compta");
348 $rowspan++; $sectionauto[] = array('position
'=>120, 'level
'=>1, 'module
'=>'salaries
', 'test
'=>$conf->salaries->enabled, 'label
'=>$langs->trans("Salaries"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries")));
350 if (!empty($conf->project->enabled)) {
351 $rowspan++; $sectionauto[] = array('position
'=>130, 'level
'=>1, 'module
'=>'project
', 'test
'=>$conf->project->enabled, 'label
'=>$langs->trans("Projects"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
352 $rowspan++; $sectionauto[] = array('position
'=>140, 'level
'=>1, 'module
'=>'project_task
', 'test
'=>$conf->project->enabled, 'label
'=>$langs->trans("Tasks"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks")));
354 if (!empty($conf->ficheinter->enabled)) {
355 $langs->load("interventions");
356 $rowspan++; $sectionauto[] = array('position
'=>150, 'level
'=>1, 'module
'=>'fichinter
', 'test
'=>$conf->ficheinter->enabled, 'label
'=>$langs->trans("Interventions"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
358 if (!empty($conf->expensereport->enabled)) {
359 $langs->load("trips");
360 $rowspan++; $sectionauto[] = array('position
'=>160, 'level
'=>1, 'module
'=>'expensereport
', 'test
'=>$conf->expensereport->enabled, 'label
'=>$langs->trans("ExpenseReports"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
362 if (!empty($conf->holiday->enabled)) {
363 $langs->load("holiday");
364 $rowspan++; $sectionauto[] = array('position
'=>170, 'level
'=>1, 'module
'=>'holiday
', 'test
'=>$conf->holiday->enabled, 'label
'=>$langs->trans("Holidays"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
366 if (!empty($conf->banque->enabled)) {
367 $langs->load("banks");
368 $rowspan++; $sectionauto[] = array('position
'=>180, 'level
'=>1, 'module
'=>'banque
', 'test
'=>$conf->banque->enabled, 'label
'=>$langs->trans("BankAccount"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
369 $rowspan++; $sectionauto[] = array('position
'=>190, 'level
'=>1, 'module
'=>'chequereceipt
', 'test
'=>$conf->banque->enabled, 'label
'=>$langs->trans("CheckReceipt"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
371 if (!empty($conf->mrp->enabled)) {
373 $rowspan++; $sectionauto[] = array('position
'=>200, 'level
'=>1, 'module
'=>'mrp-mo
', 'test
'=>$conf->mrp->enabled, 'label
'=>$langs->trans("MOs"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
375 if (!empty($conf->recruitment->enabled)) {
376 $langs->load("recruitment");
377 $rowspan++; $sectionauto[] = array('position
'=>210, 'level
'=>1, 'module
'=>'recruitment-recruitmentcandidature
', 'test
'=>$conf->recruitment->enabled, 'label
'=>$langs->trans("Candidatures"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
379 $rowspan++; $sectionauto[] = array('position
'=>220, 'level
'=>1, 'module
'=>'user', 'test
'=>1, 'label
'=>$langs->trans("Users"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
381 $parameters = array();
382 $reshook = $hookmanager->executeHooks('addSectionECMAuto
', $parameters);
383 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
384 $sectionauto[] = $hookmanager->resArray;
385 $rowspan += count($hookmanager->resArray);
389 $head = ecm_prepare_dasboard_head('');
390 print dol_get_fiche_head($head, 'index_auto
', '', -1, '');
394 // Confirm remove file (for non javascript users)
395 if ($action == 'deletefile
' && empty($conf->use_javascript_ajax)) {
396 print $form->formconfirm($_SERVER["PHP_SELF"].'?section=
'.$section.'&urlfile=
'.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile
'), $langs->trans('ConfirmDeleteFile
'), 'confirm_deletefile
', '', '', 1);
399 // Start container of all panels
401 <!-- Begin div id="containerlayout" -->
402 <div id="containerlayout">
403 <div id="ecm-layout-north" class="toolbar largebutton">
406 // Start top panel, toolbar
407 print '<div
class=
"inline-block toolbarbutton centpercent">
';
410 $url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#
' : ($_SERVER["PHP_SELF"].'?action=refreshmanual
'.($module ? '&module=
'.$module : '').($section ? '&section=
'.$section : '')));
411 print '<a href=
"'.$url.'" class=
"inline-block valignmiddle toolbarbutton paddingtop" title=
"'.dol_escape_htmltag($langs->trans('Refresh')).'">
';
412 print img_picto('', 'refresh
', 'id=
"refreshbutton"', false, 0, 0, '', 'size15x marginrightonly
');
416 // End top panel, toolbar
420 <div id="ecm-layout-west" class="inline-block">
425 // Confirmation de la suppression d'une ligne categorie
426 if ($action ==
'delete_section') {
427 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
432 if (empty($action) || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'deletefile') {
433 print
'<table class="liste centpercent">'.
"\n";
435 print
'<!-- Title for auto directories -->'.
"\n";
436 print
'<tr class="liste_titre">'.
"\n";
437 print
'<th class="liste_titre" align="left" colspan="6">';
438 print
' '.$langs->trans(
"ECMSections");
441 $showonrightsize =
'';
443 if (count($sectionauto)) {
444 $htmltooltip = $langs->trans(
"ECMAreaDesc2");
446 $sectionauto =
dol_sort_array($sectionauto,
'label',
'ASC',
true,
false);
449 print
'<td colspan="6">';
450 print
'<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
454 foreach ($sectionauto as $key => $val) {
455 if (empty($val[
'test'])) {
459 print
'<li class="directory collapsed">';
460 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
461 print
'<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER[
"PHP_SELF"].
'?module='.urlencode($val[
'module']).
'">';
465 print
'<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER[
"PHP_SELF"].
'?module='.urlencode($val[
'module']).
'">';
470 print
'<div class="ecmjqft">';
472 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
473 $htmltooltip .=
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionAuto").
'<br>';
474 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$langs->trans(
"ECMTypeAuto").
'<br>';
475 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'desc'];
476 print
$form->textwithpicto(
'', $htmltooltip, 1,
'info');
483 print
'</ul></div></td></tr>';
493 <div
id=
"ecm-layout-center" class=
"inline-block">
494 <div
class=
"pane-in ecm-in-layout-center">
495 <div
id=
"ecmfileview" class=
"ecmfileview">
500 $url = DOL_URL_ROOT.
'/ecm/index_auto.php';
501 include_once DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
510 </div> <!-- End div
id=
"containerlayout" -->
514 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
515 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';