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"));
37 if ($user->socid) $socid = $user->socid;
41 $socid =
GETPOST(
'socid',
'int');
42 $action =
GETPOST(
'action',
'aZ09');
44 $module =
GETPOST(
'module',
'alpha');
45 if (!$section) $section = 0;
46 $section_dir =
GETPOST(
'section_dir',
'alpha');
48 $search_doc_ref =
GETPOST(
'search_doc_ref',
'alpha');
50 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
51 $sortfield =
GETPOST(
"sortfield",
'alpha');
52 $sortorder =
GETPOST(
"sortorder",
'alpha');
54 if (empty($page) || $page == -1) { $page = 0; }
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
58 if (!$sortorder) $sortorder =
"ASC";
59 if (!$sortfield) $sortfield =
"fullname";
60 if ($module ==
'invoice_supplier' && $sortfield ==
"fullname") $sortfield =
"level1name";
65 $result = $ecmdir->fetch($section);
73 $form =
new Form($db);
75 $userstatic =
new User($db);
85 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
94 if ($action ==
'add' && $user->rights->ecm->setup)
96 $ecmdir->ref =
'NOTUSEDYET';
97 $ecmdir->label =
GETPOST(
"label");
98 $ecmdir->description =
GETPOST(
"desc");
100 $id = $ecmdir->create($user);
103 header(
"Location: ".
$_SERVER[
"PHP_SELF"]);
114 if ($action ==
'confirm_deletefile')
116 if (
GETPOST(
'confirm') ==
'yes')
118 $langs->load(
"other");
121 $result = $ecmdir->fetch($section);
127 $relativepath = $ecmdir->getRelativePath();
128 }
else $relativepath =
'';
129 $upload_dir = $conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
130 $file = $upload_dir.
"/".
GETPOST(
'urlfile');
136 $result = $ecmdir->changeNbOfFiles(
'-');
140 $action =
'file_manager';
144 if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm') ==
'yes')
146 $result = $ecmdir->delete($user);
147 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label), null,
'mesgs');
155 if ($action ==
'refreshmanual')
162 $diroutputslash = str_replace(
'\\',
'/', $conf->ecm->dir_output);
163 $diroutputslash .=
'/';
166 $disktree =
dol_dir_list($conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'',
'', 0);
169 $sqltree = $ecmdirstatic->get_full_arbo(0);
176 foreach ($disktree as $dirdesc)
178 $dirisindatabase = 0;
179 foreach ($sqltree as $dirsqldesc)
181 if ($conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname'])
183 $dirisindatabase = 1;
188 if (!$dirisindatabase)
190 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
196 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
197 $relativepathtosearchparent = $relativepathmissing;
199 if (preg_match(
'/\//', $relativepathtosearchparent))
202 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
203 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
206 $parentdirisindatabase = 0;
207 foreach ($sqltree as $dirsqldesc)
209 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent)
211 $parentdirisindatabase = $dirsqldesc[
'id'];
215 if ($parentdirisindatabase > 0)
217 dol_syslog(
"Yes with id ".$parentdirisindatabase);
219 $fk_parent = $parentdirisindatabase;
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);
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)
265 $dirtotest = $conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
268 $ecmdirtmp->id = $dirdesc[
'id'];
269 $ecmdirtmp->delete($user,
'databaseonly');
274 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
280 if ($adirwascreated) $sqltree = null;
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');
298 if (empty($conf->global->MAIN_ECM_DISABLE_JS)) $morejs[] =
"includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
300 $moreheadjs .=
'<script type="text/javascript">'.
"\n";
301 $moreheadjs .=
'var indicatorBlockUI = \''.DOL_URL_ROOT.
"/theme/".$conf->theme.
"/img/working.gif".
'\';
'."\n";
302 $moreheadjs .= '</script>
'."\n";
304 llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
307 // Add sections to manage
309 $sectionauto = array();
310 if (!empty($conf->global->ECM_AUTO_TREE_ENABLED))
312 if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $langs->load("products"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'product
', 'test
'=>(!empty($conf->product->enabled) || !empty($conf->service->enabled)), 'label
'=>$langs->trans("ProductsAndServices"), 'desc
'=>$langs->trans("ECMDocsByProducts")); }
313 if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'company
', 'test
'=>$conf->societe->enabled, 'label
'=>$langs->trans("ThirdParties"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); }
314 if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'propal
', 'test
'=>$conf->propal->enabled, 'label
'=>$langs->trans("Proposals"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); }
315 if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'contract
', 'test
'=>$conf->contrat->enabled, 'label
'=>$langs->trans("Contracts"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); }
316 if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'order
', 'test
'=>$conf->commande->enabled, 'label
'=>$langs->trans("CustomersOrders"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); }
317 if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'invoice
', 'test
'=>$conf->facture->enabled, 'label
'=>$langs->trans("CustomersInvoices"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); }
318 if (!empty($conf->supplier_proposal->enabled)) { $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'supplier_proposal
', 'test
'=>$conf->supplier_proposal->enabled, 'label
'=>$langs->trans("SupplierProposals"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals"))); }
319 if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'order_supplier
', 'test
'=>$conf->fournisseur->enabled, 'label
'=>$langs->trans("SuppliersOrders"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); }
320 if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'invoice_supplier
', 'test
'=>$conf->fournisseur->enabled, 'label
'=>$langs->trans("SuppliersInvoices"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); }
321 if (!empty($conf->tax->enabled)) { $langs->load("compta"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'tax
', 'test
'=>$conf->tax->enabled, 'label
'=>$langs->trans("SocialContributions"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions"))); }
322 if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'project
', 'test
'=>$conf->projet->enabled, 'label
'=>$langs->trans("Projects"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); }
323 if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'fichinter
', 'test
'=>$conf->ficheinter->enabled, 'label
'=>$langs->trans("Interventions"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions"))); }
324 if (!empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'expensereport
', 'test
'=>$conf->expensereport->enabled, 'label
'=>$langs->trans("ExpenseReports"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports"))); }
325 if (!empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'holiday
', 'test
'=>$conf->holiday->enabled, 'label
'=>$langs->trans("Holidays"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays"))); }
326 if (!empty($conf->banque->enabled)) { $langs->load("banks"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'banque
', 'test
'=>$conf->banque->enabled, 'label
'=>$langs->trans("BankAccount"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount"))); }
327 if (!empty($conf->mrp->enabled)) { $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'mrp-mo
', 'test
'=>$conf->mrp->enabled, 'label
'=>$langs->trans("MOs"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders"))); }
328 if (!empty($conf->recruitment->enabled)) { $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'recruitment-recruitmentcandidature
', 'test
'=>$conf->recruitment->enabled, 'label
'=>$langs->trans("Candidatures"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications"))); }
329 $rowspan++; $sectionauto[] = array('level
'=>1, 'module
'=>'user', 'test
'=>1, 'label
'=>$langs->trans("Users"), 'desc
'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
332 $head = ecm_prepare_dasboard_head('');
333 print dol_get_fiche_head($head, 'index_auto
', $langs->trans("ECMArea").' -
'.$langs->trans("ECMFileManager"), -1, '');
337 // Confirm remove file (for non javascript users)
338 if ($action == 'delete' && empty($conf->use_javascript_ajax))
340 print $form->formconfirm($_SERVER["PHP_SELF"].'?section=
'.$section.'&urlfile=
'.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile
'), $langs->trans('ConfirmDeleteFile
'), 'confirm_deletefile
', '', '', 1);
343 // Start container of all panels
345 <!-- Begin div id="containerlayout" -->
346 <div id="containerlayout">
347 <div id="ecm-layout-north" class="toolbar largebutton">
350 // Start top panel, toolbar
351 print '<div
class=
"inline-block toolbarbutton centpercent">
';
354 $url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#
' : ($_SERVER["PHP_SELF"].'?action=refreshmanual
'.($module ? '&module=
'.$module : '').($section ? '&section=
'.$section : '')));
355 print '<a href=
"'.$url.'" class=
"inline-block valignmiddle toolbarbutton paddingtop" title=
"'.dol_escape_htmltag($langs->trans('Refresh')).'">
';
356 print '<img
id=
"refreshbutton" class=
"toolbarbutton" border=
"0" src=
"'.DOL_URL_ROOT.'/theme/common/view-refresh.png">
';
360 // End top panel, toolbar
364 <div id="ecm-layout-west" class="inline-block">
369 // Confirmation de la suppression d'une ligne categorie
370 if ($action ==
'delete_section')
372 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
377 if (empty($action) || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'delete')
379 print '<table width="100%" class="liste noborderbottom">'.
"\n";
381 print '<!-- Title for auto directories -->'.
"\n";
382 print '<tr class="liste_titre">'.
"\n";
383 print '<th class="liste_titre" align="left" colspan="6">';
384 print ' '.$langs->trans(
"ECMSections");
387 $showonrightsize =
'';
389 if (count($sectionauto))
391 $htmltooltip = $langs->trans(
"ECMAreaDesc2");
393 $sectionauto =
dol_sort_array($sectionauto,
'label',
'ASC',
true,
false);
396 print '<td colspan="6">';
397 print '<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
401 foreach ($sectionauto as $key => $val)
403 if (empty($val[
'test']))
continue;
407 print '<li class="directory collapsed">';
408 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))
410 print '<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER[
"PHP_SELF"].
'?module='.$val[
'module'].
'">';
414 print '<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER[
"PHP_SELF"].
'?module='.$val[
'module'].
'">';
419 print '<div class="ecmjqft">';
421 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
422 $htmltooltip =
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionAuto").
'<br>';
423 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$langs->trans(
"ECMTypeAuto").
'<br>';
424 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'desc'];
425 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
432 print '</ul></div></td></tr>';
442 <div
id=
"ecm-layout-center" class=
"inline-block">
443 <div
class=
"pane-in ecm-in-layout-center">
444 <div
id=
"ecmfileview" class=
"ecmfileview">
450 $url = DOL_URL_ROOT.
'/ecm/index_auto.php';
451 include_once DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
460 </div> <!-- End div
id=
"containerlayout" -->
464 if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
465 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
dol_is_dir($folder)
Test if filename is a directory.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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)
Remove a file or several files with a mask.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage ECM directories.