30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/ecm.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/treeview.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/ecm/class/ecmdirectory.class.php';
46$langs->loadLangs(array(
"ecm",
"companies",
"other",
"users",
"orders",
"propal",
"bills",
"contracts"));
50$action =
GETPOST(
'action',
'aZ09');
52$module =
GETPOST(
'module',
'alpha');
56$section_dir =
GETPOST(
'section_dir',
'alpha');
58$search_doc_ref =
GETPOST(
'search_doc_ref',
'alpha');
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64if (empty($page) || $page == -1) {
67$offset = $limit * $page;
74 $sortfield =
"fullname";
76if ($module ==
'invoice_supplier' && $sortfield ==
"fullname") {
77 $sortfield =
"level1name";
82 $result = $ecmdir->fetch($section);
97 $socid = $user->socid;
101$hookmanager->initHooks(array(
'ecmautocard',
'globalcard'));
111if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
112 $search_doc_ref =
'';
116if ($action ==
'add' && $user->hasRight(
'ecm',
'setup')) {
117 $ecmdir->ref =
'NOTUSEDYET';
118 $ecmdir->label =
GETPOST(
"label");
119 $ecmdir->description =
GETPOST(
"desc");
121 $id = $ecmdir->create($user);
123 header(
"Location: ".$_SERVER[
"PHP_SELF"]);
134if ($action ==
'confirm_deletefile' && $user->hasRight(
'ecm',
'upload')) {
135 if (
GETPOST(
'confirm') ==
'yes') {
136 $langs->load(
"other");
138 $result = $ecmdir->fetch($section);
139 if (!($result > 0)) {
143 $relativepath = $ecmdir->getRelativePath();
147 $upload_dir =
$conf->ecm->dir_output.($relativepath ?
'/'.$relativepath :
'');
148 $file = $upload_dir.
"/".
GETPOST(
'urlfile');
157 $result = $ecmdir->changeNbOfFiles(
'-');
161 $action =
'file_manager';
165if ($action ==
'confirm_deletesection' &&
GETPOST(
'confirm') ==
'yes' && $user->hasRight(
'ecm',
'setup')) {
166 $result = $ecmdir->delete($user);
167 setEventMessages($langs->trans(
"ECMSectionWasRemoved", $ecmdir->label),
null,
'mesgs');
175if ($action ==
'refreshmanual' && $user->hasRight(
'ecm',
'read')) {
181 $diroutputslash = str_replace(
'\\',
'/',
$conf->ecm->dir_output);
182 $diroutputslash .=
'/';
185 $disktree =
dol_dir_list(
$conf->ecm->dir_output,
'directories', 1,
'',
'^temp$',
'', 0, 0);
188 $sqltree = $ecmdirstatic->get_full_arbo(0);
195 foreach ($disktree as $dirdesc) {
196 $dirisindatabase = 0;
197 foreach ($sqltree as $dirsqldesc) {
198 if (
$conf->ecm->dir_output.
'/'.$dirsqldesc[
'fullrelativename'] == $dirdesc[
'fullname']) {
199 $dirisindatabase = 1;
204 if (!$dirisindatabase) {
205 $txt =
"Directory found on disk ".$dirdesc[
'fullname'].
", not found into database so we add it";
211 $relativepathmissing = str_replace($diroutputslash,
'', $dirdesc[
'fullname']);
212 $relativepathtosearchparent = $relativepathmissing;
214 if (preg_match(
'/\//', $relativepathtosearchparent)) {
216 $relativepathtosearchparent = preg_replace(
'/\/[^\/]*$/',
'', $relativepathtosearchparent);
217 $txt =
"Is relative parent path ".$relativepathtosearchparent.
" for ".$relativepathmissing.
" found in sql tree ?";
220 $parentdirisindatabase = 0;
221 foreach ($sqltree as $dirsqldesc) {
222 if ($dirsqldesc[
'fullrelativename'] == $relativepathtosearchparent) {
223 $parentdirisindatabase = $dirsqldesc[
'id'];
227 if ($parentdirisindatabase > 0) {
228 dol_syslog(
"Yes with id ".$parentdirisindatabase);
230 $fk_parent = $parentdirisindatabase;
241 if ($fk_parent >= 0) {
242 $ecmdirtmp->ref =
'NOTUSEDYET';
244 $ecmdirtmp->description =
'';
245 $ecmdirtmp->fk_parent = $fk_parent;
247 $txt =
"We create directory ".$ecmdirtmp->label.
" with parent ".$fk_parent;
250 $id = $ecmdirtmp->create($user);
252 $newdirsql = array(
'id' =>
$id,
253 'id_mere' => $ecmdirtmp->fk_parent,
254 'label' => $ecmdirtmp->label,
255 'description' => $ecmdirtmp->description,
256 'fullrelativename' => $relativepathmissing);
257 $sqltree[] = $newdirsql;
261 dol_syslog(
"Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
264 $txt =
"Parent of ".$dirdesc[
'fullname'].
" not found";
272 foreach ($sqltree as $dirdesc) {
273 $dirtotest =
$conf->ecm->dir_output.
'/'.$dirdesc[
'fullrelativename'];
275 $ecmdirtmp->id = $dirdesc[
'id'];
276 $ecmdirtmp->delete($user,
'databaseonly');
281 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0";
287 if ($adirwascreated) {
300$maxheightwin = (isset($_SESSION[
"dol_screenheight"]) && $_SESSION[
"dol_screenheight"] > 466) ? ($_SESSION[
"dol_screenheight"] - 136) : 660;
307 $morejs[] =
"public/includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
310llxHeader($moreheadcss.$moreheadjs, $langs->trans(
"ECMArea"),
'',
'', 0, 0, $morejs,
'',
'',
'mod-ecm page-index_auto');
315$sectionauto = array();
318 $langs->load(
"products");
320 $sectionauto[] = array(
'position' => 10,
'level' => 1,
'module' =>
'product',
'test' => $user->hasRight(
'produit',
'lire'),
'label' => $langs->trans(
"ProductsAndServices"),
'desc' => $langs->trans(
"ECMDocsByProducts"));
324 $sectionauto[] = array(
'position' => 20,
'level' => 1,
'module' =>
'company',
'test' => $user->hasRight(
'societe',
'lire'),
'label' => $langs->trans(
"ThirdParties"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"ThirdParties")));
328 $sectionauto[] = array(
'position' => 30,
'level' => 1,
'module' =>
'propal',
'test' => $user->hasRight(
'propale',
'lire'),
'label' => $langs->trans(
"Proposals"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Proposals")));
332 $sectionauto[] = array(
'position' => 40,
'level' => 1,
'module' =>
'contract',
'test' => $user->hasRight(
'contrat',
'lire'),
'label' => $langs->trans(
"Contracts"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Contracts")));
336 $sectionauto[] = array(
'position' => 50,
'level' => 1,
'module' =>
'order',
'test' => $user->hasRight(
'commande',
'lire'),
'label' => $langs->trans(
"CustomersOrders"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Orders")));
340 $sectionauto[] = array(
'position' => 60,
'level' => 1,
'module' =>
'invoice',
'test' => $user->hasRight(
'facture',
'lire'),
'label' => $langs->trans(
"CustomersInvoices"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Invoices")));
343 $langs->load(
"supplier_proposal");
345 $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")));
349 $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")));
353 $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")));
356 $langs->load(
"compta");
358 $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")));
360 $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")));
363 $langs->load(
"compta");
365 $sectionauto[] = array(
'position' => 120,
'level' => 1,
'module' =>
'salaries',
'test' => $user->hasRight(
'salaries',
'read'),
'label' => $langs->trans(
"Salaries"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Salaries")));
369 $sectionauto[] = array(
'position' => 130,
'level' => 1,
'module' =>
'project',
'test' => 1,
'label' => $langs->trans(
"Projects"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Projects")));
371 $sectionauto[] = array(
'position' => 140,
'level' => 1,
'module' =>
'project_task',
'test' => 1,
'label' => $langs->trans(
"Tasks"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Tasks")));
374 $langs->load(
"interventions");
376 $sectionauto[] = array(
'position' => 150,
'level' => 1,
'module' =>
'fichinter',
'test' => $user->hasRight(
'ficheinter',
'lire'),
'label' => $langs->trans(
"Interventions"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Interventions")));
379 $langs->load(
"trips");
381 $sectionauto[] = array(
'position' => 160,
'level' => 1,
'module' =>
'expensereport',
'test' => $user->hasRight(
'expensereport',
'lire'),
'label' => $langs->trans(
"ExpenseReports"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"ExpenseReports")));
384 $langs->load(
"holiday");
386 $sectionauto[] = array(
'position' => 170,
'level' => 1,
'module' =>
'holiday',
'test' => $user->hasRight(
'holiday',
'read'),
'label' => $langs->trans(
"Holidays"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Holidays")));
389 $langs->load(
"banks");
391 $sectionauto[] = array(
'position' => 180,
'level' => 1,
'module' =>
'banque',
'test' => $user->hasRight(
'banque',
'lire'),
'label' => $langs->trans(
"BankAccount"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"BankAccount")));
396 $sectionauto[] = array(
'position' => 190,
'level' => 1,
'module' =>
'chequereceipt',
'test' => $user->hasRight(
'banque',
'lire'),
'label' => $langs->trans(
"CheckReceipt"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"CheckReceipt")));
401 $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")));
404 $langs->load(
"recruitment");
406 $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")));
409 $sectionauto[] = array(
'position' => 220,
'level' => 1,
'module' =>
'user',
'test' => 1,
'label' => $langs->trans(
"Users"),
'desc' => $langs->trans(
"ECMDocsBy", $langs->transnoentitiesnoconv(
"Users")));
411 $parameters = array();
412 $reshook = $hookmanager->executeHooks(
'addSectionECMAuto', $parameters);
413 if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
414 $res = $hookmanager->resArray[0];
415 if (is_array($hookmanager->resArray[0])) {
416 $sectionauto = array_merge($sectionauto, $hookmanager->resArray);
417 $rowspan += count($hookmanager->resArray);
419 $sectionauto[] = $hookmanager->resArray;
431if ($action ==
'deletefile' && empty(
$conf->use_javascript_ajax)) {
432 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section.
'&urlfile='.urlencode(
GETPOST(
"urlfile")), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'',
'', 1);
437<!-- Begin div
id=
"containerlayout" -->
438<div
id=
"containerlayout">
439<div
id=
"ecm-layout-north" class=
"toolbar largebutton">
443print
'<div class="inline-block toolbarbutton centpercent">';
446$url = ((!empty(
$conf->use_javascript_ajax) && !
getDolGlobalString(
'MAIN_ECM_DISABLE_JS')) ?
'#' : ($_SERVER[
"PHP_SELF"].
'?action=refreshmanual'.($module ?
'&module='.$module :
'').($section ?
'&section='.$section :
'')));
447print
'<a href="'.$url.
'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.
dol_escape_htmltag($langs->trans(
'Refresh')).
'">';
448print
img_picto(
'',
'refresh',
'id="refreshbutton"', 0, 0, 0,
'',
'size15x marginrightonly');
456<div
id=
"ecm-layout-west" class=
"inline-block">
462if ($action ==
'delete_section') {
463 print $form->formconfirm($_SERVER[
"PHP_SELF"].
'?section='.$section, $langs->trans(
'DeleteSection'), $langs->trans(
'ConfirmDeleteSection', $ecmdir->label),
'confirm_deletesection',
'',
'', 1);
468if (empty($action) || $action ==
'file_manager' || preg_match(
'/refresh/i', $action) || $action ==
'deletefile') {
469 print
'<table class="liste centpercent noborder">'.
"\n";
471 print
'<!-- Title for auto directories -->'.
"\n";
472 print
'<tr class="liste_titre">'.
"\n";
473 print
'<th class="liste_titre" align="left" colspan="6">';
474 print
' '.$langs->trans(
"ECMSections");
477 $showonrightsize =
'';
480 if (count($sectionauto)) {
481 $htmltooltip = $langs->trans(
"ECMAreaDesc2");
482 $htmltooltip .=
'<br>'.$langs->trans(
"ECMAreaDesc2b");
484 $sectionauto =
dol_sort_array($sectionauto,
'label',
'ASC', 1, 0);
487 print
'<td colspan="6">';
488 print
'<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
490 $arrayofmodulesforexternalusers = explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL'));
494 foreach ($sectionauto as $key => $val) {
495 if (empty($val[
'test'])) {
500 if ($user->socid > 0) {
503 if (! in_array($val[
'module'], $arrayofmodulesforexternalusers)) {
509 print
'<li class="directory collapsed">';
510 print
'<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER[
"PHP_SELF"].
'?module='.urlencode($val[
'module']).
'">';
514 print
'<div class="ecmjqft">';
516 $htmltooltip =
'<b>'.$langs->trans(
"ECMSection").
'</b>: '.$val[
'label'].
'<br>';
517 $htmltooltip .=
'<b>'.$langs->trans(
"Type").
'</b>: '.$langs->trans(
"ECMSectionAuto").
'<br>';
518 $htmltooltip .=
'<b>'.$langs->trans(
"ECMCreationUser").
'</b>: '.$langs->trans(
"ECMTypeAuto").
'<br>';
519 $htmltooltip .=
'<b>'.$langs->trans(
"Description").
'</b>: '.$val[
'desc'];
520 print $form->textwithpicto(
'', $htmltooltip, 1,
'info');
528 print
'</ul></div></td></tr>';
538<div
id=
"ecm-layout-center" class=
"inline-block">
539<div
class=
"pane-in ecm-in-layout-center">
540<div
id=
"ecmfileview" class=
"ecmfileview">
545$url = DOL_URL_ROOT.
'/ecm/index_auto.php';
546include_once DOL_DOCUMENT_ROOT.
'/core/ajax/ajaxdirpreview.php';
555</div> <!-- End div
id=
"containerlayout" -->
560 include DOL_DOCUMENT_ROOT.
'/ecm/tpl/enablefiletreeajax.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
Class to manage ECM directories.
Class to manage Dolibarr users.
ecm_prepare_dasboard_head()
Prepare array with list of different ecm main dashboard.
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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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...
dolPrintLabel($s, $escapeonlyhtmltags=0)
Return a string label (so on 1 line only and that should not contains any HTML) ready to be output on...
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.