index_auto.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <?php
  2. /* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2008-2010 Regis Houssin <regis.houssin@inodbox.com>
  4. * Copyright (C) 2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/ecm/index_auto.php
  21. * \ingroup ecm
  22. * \brief Main page for ECM section area
  23. */
  24. // Load Dolibarr environment
  25. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
  30. require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
  31. // Load translation files required by the page
  32. $langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
  33. // Get parameters
  34. $socid = GETPOST('socid', 'int');
  35. $action = GETPOST('action', 'aZ09');
  36. $section = GETPOST('section', 'int') ?GETPOST('section', 'int') : GETPOST('section_id', 'int');
  37. $module = GETPOST('module', 'alpha');
  38. if (!$section) {
  39. $section = 0;
  40. }
  41. $section_dir = GETPOST('section_dir', 'alpha');
  42. $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
  43. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  44. $sortfield = GETPOST('sortfield', 'aZ09comma');
  45. $sortorder = GETPOST('sortorder', 'aZ09comma');
  46. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  47. if (empty($page) || $page == -1) {
  48. $page = 0;
  49. } // If $page is not defined, or '' or -1
  50. $offset = $limit * $page;
  51. $pageprev = $page - 1;
  52. $pagenext = $page + 1;
  53. if (!$sortorder) {
  54. $sortorder = "ASC";
  55. }
  56. if (!$sortfield) {
  57. $sortfield = "fullname";
  58. }
  59. if ($module == 'invoice_supplier' && $sortfield == "fullname") {
  60. $sortfield = "level1name";
  61. }
  62. $ecmdir = new EcmDirectory($db);
  63. if ($section) {
  64. $result = $ecmdir->fetch($section);
  65. if (!($result > 0)) {
  66. dol_print_error($db, $ecmdir->error);
  67. exit;
  68. }
  69. }
  70. $form = new Form($db);
  71. $ecmdirstatic = new EcmDirectory($db);
  72. $userstatic = new User($db);
  73. $error = 0;
  74. // Security check
  75. if ($user->socid) {
  76. $socid = $user->socid;
  77. }
  78. $result = restrictedArea($user, 'ecm', 0);
  79. /*
  80. * Actions
  81. */
  82. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  83. $hookmanager->initHooks(array('ecmautocard', 'globalcard'));
  84. // Purge search criteria
  85. if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
  86. $search_doc_ref = '';
  87. }
  88. // Add directory
  89. if ($action == 'add' && $user->rights->ecm->setup) {
  90. $ecmdir->ref = 'NOTUSEDYET';
  91. $ecmdir->label = GETPOST("label");
  92. $ecmdir->description = GETPOST("desc");
  93. $id = $ecmdir->create($user);
  94. if ($id > 0) {
  95. header("Location: ".$_SERVER["PHP_SELF"]);
  96. exit;
  97. } else {
  98. setEventMessages('Error '.$langs->trans($ecmdir->error), null, 'errors');
  99. $action = "create";
  100. }
  101. clearstatcache();
  102. }
  103. // Remove file
  104. if ($action == 'confirm_deletefile') {
  105. if (GETPOST('confirm') == 'yes') {
  106. $langs->load("other");
  107. if ($section) {
  108. $result = $ecmdir->fetch($section);
  109. if (!($result > 0)) {
  110. dol_print_error($db, $ecmdir->error);
  111. exit;
  112. }
  113. $relativepath = $ecmdir->getRelativePath();
  114. } else {
  115. $relativepath = '';
  116. }
  117. $upload_dir = $conf->ecm->dir_output.($relativepath ? '/'.$relativepath : '');
  118. $file = $upload_dir."/".GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_POST are already decoded by PHP).
  119. $ret = dol_delete_file($file);
  120. if ($ret) {
  121. setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
  122. } else {
  123. setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
  124. }
  125. $result = $ecmdir->changeNbOfFiles('-');
  126. clearstatcache();
  127. }
  128. $action = 'file_manager';
  129. }
  130. // Remove directory
  131. if ($action == 'confirm_deletesection' && GETPOST('confirm') == 'yes') {
  132. $result = $ecmdir->delete($user);
  133. setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs');
  134. clearstatcache();
  135. }
  136. // Refresh directory view
  137. // This refresh list of dirs, not list of files (for preformance reason). List of files is refresh only if dir was not synchronized.
  138. // To refresh content of dir with cache, just open the dir in edit mode.
  139. if ($action == 'refreshmanual') {
  140. $ecmdirtmp = new EcmDirectory($db);
  141. // This part of code is same than into file ecm/ajax/ecmdatabase.php TODO Remove duplicate
  142. clearstatcache();
  143. $diroutputslash = str_replace('\\', '/', $conf->ecm->dir_output);
  144. $diroutputslash .= '/';
  145. // Scan directory tree on disk
  146. $disktree = dol_dir_list($conf->ecm->dir_output, 'directories', 1, '', '^temp$', '', '', 0);
  147. // Scan directory tree in database
  148. $sqltree = $ecmdirstatic->get_full_arbo(0);
  149. $adirwascreated = 0;
  150. // Now we compare both trees to complete missing trees into database
  151. //var_dump($disktree);
  152. //var_dump($sqltree);
  153. foreach ($disktree as $dirdesc) { // Loop on tree onto disk
  154. $dirisindatabase = 0;
  155. foreach ($sqltree as $dirsqldesc) {
  156. if ($conf->ecm->dir_output.'/'.$dirsqldesc['fullrelativename'] == $dirdesc['fullname']) {
  157. $dirisindatabase = 1;
  158. break;
  159. }
  160. }
  161. if (!$dirisindatabase) {
  162. $txt = "Directory found on disk ".$dirdesc['fullname'].", not found into database so we add it";
  163. dol_syslog($txt);
  164. //print $txt."<br>\n";
  165. // We must first find the fk_parent of directory to create $dirdesc['fullname']
  166. $fk_parent = -1;
  167. $relativepathmissing = str_replace($diroutputslash, '', $dirdesc['fullname']);
  168. $relativepathtosearchparent = $relativepathmissing;
  169. //dol_syslog("Try to find parent id for directory ".$relativepathtosearchparent);
  170. if (preg_match('/\//', $relativepathtosearchparent)) {
  171. //while (preg_match('/\//',$relativepathtosearchparent))
  172. $relativepathtosearchparent = preg_replace('/\/[^\/]*$/', '', $relativepathtosearchparent);
  173. $txt = "Is relative parent path ".$relativepathtosearchparent." for ".$relativepathmissing." found in sql tree ?";
  174. dol_syslog($txt);
  175. //print $txt." -> ";
  176. $parentdirisindatabase = 0;
  177. foreach ($sqltree as $dirsqldesc) {
  178. if ($dirsqldesc['fullrelativename'] == $relativepathtosearchparent) {
  179. $parentdirisindatabase = $dirsqldesc['id'];
  180. break;
  181. }
  182. }
  183. if ($parentdirisindatabase > 0) {
  184. dol_syslog("Yes with id ".$parentdirisindatabase);
  185. //print "Yes with id ".$parentdirisindatabase."<br>\n";
  186. $fk_parent = $parentdirisindatabase;
  187. //break; // We found parent, we can stop the while loop
  188. } else {
  189. dol_syslog("No");
  190. //print "No<br>\n";
  191. }
  192. } else {
  193. dol_syslog("Parent is root");
  194. $fk_parent = 0; // Parent is root
  195. }
  196. if ($fk_parent >= 0) {
  197. $ecmdirtmp->ref = 'NOTUSEDYET';
  198. $ecmdirtmp->label = dol_basename($dirdesc['fullname']);
  199. $ecmdirtmp->description = '';
  200. $ecmdirtmp->fk_parent = $fk_parent;
  201. $txt = "We create directory ".$ecmdirtmp->label." with parent ".$fk_parent;
  202. dol_syslog($txt);
  203. //print $ecmdirtmp->cachenbofdoc."<br>\n";exit;
  204. $id = $ecmdirtmp->create($user);
  205. if ($id > 0) {
  206. $newdirsql = array('id'=>$id,
  207. 'id_mere'=>$ecmdirtmp->fk_parent,
  208. 'label'=>$ecmdirtmp->label,
  209. 'description'=>$ecmdirtmp->description,
  210. 'fullrelativename'=>$relativepathmissing);
  211. $sqltree[] = $newdirsql; // We complete fulltree for following loops
  212. //var_dump($sqltree);
  213. $adirwascreated = 1;
  214. } else {
  215. dol_syslog("Failed to create directory ".$ecmdirtmp->label, LOG_ERR);
  216. }
  217. } else {
  218. $txt = "Parent of ".$dirdesc['fullname']." not found";
  219. dol_syslog($txt);
  220. //print $txt."<br>\n";
  221. }
  222. }
  223. }
  224. // Loop now on each sql tree to check if dir exists
  225. foreach ($sqltree as $dirdesc) { // Loop on each sqltree to check dir is on disk
  226. $dirtotest = $conf->ecm->dir_output.'/'.$dirdesc['fullrelativename'];
  227. if (!dol_is_dir($dirtotest)) {
  228. $ecmdirtmp->id = $dirdesc['id'];
  229. $ecmdirtmp->delete($user, 'databaseonly');
  230. //exit;
  231. }
  232. }
  233. $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories set cachenbofdoc = -1 WHERE cachenbofdoc < 0"; // If pb into cache counting, we set to value -1 = "unknown"
  234. dol_syslog("sql = ".$sql);
  235. $db->query($sql);
  236. // If a directory was added, the fulltree array is not correctly completed and sorted, so we clean
  237. // it to be sure that fulltree array is not used without reloading it.
  238. if ($adirwascreated) {
  239. $sqltree = null;
  240. }
  241. }
  242. /*
  243. * View
  244. */
  245. // Define height of file area (depends on $_SESSION["dol_screenheight"])
  246. //print $_SESSION["dol_screenheight"];
  247. $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 466) ? ($_SESSION["dol_screenheight"] - 136) : 660; // Also into index.php file
  248. $moreheadcss = '';
  249. $moreheadjs = '';
  250. //$morejs=array();
  251. $morejs = array('includes/jquery/plugins/blockUI/jquery.blockUI.js', 'core/js/blockUI.js'); // Used by ecm/tpl/enabledfiletreeajax.tpl.pgp
  252. if (empty($conf->global->MAIN_ECM_DISABLE_JS)) {
  253. $morejs[] = "includes/jquery/plugins/jqueryFileTree/jqueryFileTree.js";
  254. }
  255. $moreheadjs .= '<script type="text/javascript">'."\n";
  256. $moreheadjs .= 'var indicatorBlockUI = \''.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'\';'."\n";
  257. $moreheadjs .= '</script>'."\n";
  258. llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0);
  259. // Add sections to manage
  260. $rowspan = 0;
  261. $sectionauto = array();
  262. if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) {
  263. if (isModEnabled("product") || isModEnabled("service")) {
  264. $langs->load("products");
  265. $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
  266. }
  267. if (isModEnabled("societe")) {
  268. $rowspan++; $sectionauto[] = array('position'=>20, 'level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
  269. }
  270. if (isModEnabled("propal")) {
  271. $rowspan++; $sectionauto[] = array('position'=>30, 'level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
  272. }
  273. if (isModEnabled('contrat')) {
  274. $rowspan++; $sectionauto[] = array('position'=>40, 'level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
  275. }
  276. if (isModEnabled('commande')) {
  277. $rowspan++; $sectionauto[] = array('position'=>50, 'level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
  278. }
  279. if (isModEnabled('facture')) {
  280. $rowspan++; $sectionauto[] = array('position'=>60, 'level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
  281. }
  282. if (isModEnabled('supplier_proposal')) {
  283. $langs->load("supplier_proposal");
  284. $rowspan++; $sectionauto[] = array('position'=>70, 'level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
  285. }
  286. if (isModEnabled("supplier_order")) {
  287. $rowspan++; $sectionauto[] = array('position'=>80, 'level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
  288. }
  289. if (isModEnabled("supplier_invoice")) {
  290. $rowspan++; $sectionauto[] = array('position'=>90, 'level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
  291. }
  292. if (isModEnabled('tax')) {
  293. $langs->load("compta");
  294. $rowspan++; $sectionauto[] = array('position'=>100, 'level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
  295. $rowspan++; $sectionauto[] = array('position'=>110, 'level'=>1, 'module'=>'tax-vat', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("VAT"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("VAT")));
  296. }
  297. if (!empty($conf->salaries->enabled)) {
  298. $langs->load("compta");
  299. $rowspan++; $sectionauto[] = array('position'=>120, 'level'=>1, 'module'=>'salaries', 'test'=>isModEnabled('salaries'), 'label'=>$langs->trans("Salaries"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Salaries")));
  300. }
  301. if (isModEnabled('project')) {
  302. $rowspan++; $sectionauto[] = array('position'=>130, 'level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
  303. $rowspan++; $sectionauto[] = array('position'=>140, 'level'=>1, 'module'=>'project_task', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Tasks"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Tasks")));
  304. }
  305. if (isModEnabled('ficheinter')) {
  306. $langs->load("interventions");
  307. $rowspan++; $sectionauto[] = array('position'=>150, 'level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
  308. }
  309. if (isModEnabled('expensereport')) {
  310. $langs->load("trips");
  311. $rowspan++; $sectionauto[] = array('position'=>160, 'level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
  312. }
  313. if (isModEnabled('holiday')) {
  314. $langs->load("holiday");
  315. $rowspan++; $sectionauto[] = array('position'=>170, 'level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
  316. }
  317. if (isModEnabled("banque")) {
  318. $langs->load("banks");
  319. $rowspan++; $sectionauto[] = array('position'=>180, 'level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
  320. $rowspan++; $sectionauto[] = array('position'=>190, 'level'=>1, 'module'=>'chequereceipt', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("CheckReceipt"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("CheckReceipt")));
  321. }
  322. if (isModEnabled('mrp')) {
  323. $langs->load("mrp");
  324. $rowspan++; $sectionauto[] = array('position'=>200, 'level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
  325. }
  326. if (isModEnabled('recruitment')) {
  327. $langs->load("recruitment");
  328. $rowspan++; $sectionauto[] = array('position'=>210, 'level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
  329. }
  330. $rowspan++; $sectionauto[] = array('position'=>220, 'level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Users")));
  331. $parameters = array();
  332. $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters);
  333. if ($reshook > 0 && is_array($hookmanager->resArray) && count($hookmanager->resArray) > 0) {
  334. $sectionauto[] = $hookmanager->resArray;
  335. $rowspan += count($hookmanager->resArray);
  336. }
  337. }
  338. $head = ecm_prepare_dasboard_head(null);
  339. print dol_get_fiche_head($head, 'index_auto', '', -1, '');
  340. // Confirm remove file (for non javascript users)
  341. if ($action == 'deletefile' && empty($conf->use_javascript_ajax)) {
  342. print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', '', 1);
  343. }
  344. // Start container of all panels
  345. ?>
  346. <!-- Begin div id="containerlayout" -->
  347. <div id="containerlayout">
  348. <div id="ecm-layout-north" class="toolbar largebutton">
  349. <?php
  350. // Start top panel, toolbar
  351. print '<div class="inline-block toolbarbutton centpercent">';
  352. // Toolbar
  353. $url = ((!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) ? '#' : ($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module ? '&amp;module='.$module : '').($section ? '&amp;section='.$section : '')));
  354. print '<a href="'.$url.'" class="inline-block valignmiddle toolbarbutton paddingtop" title="'.dol_escape_htmltag($langs->trans('Refresh')).'">';
  355. print img_picto('', 'refresh', 'id="refreshbutton"', false, 0, 0, '', 'size15x marginrightonly');
  356. print '</a>';
  357. print '</div>';
  358. // End top panel, toolbar
  359. ?>
  360. </div>
  361. <div id="ecm-layout-west" class="inline-block">
  362. <?php
  363. // Start left area
  364. // Confirmation de la suppression d'une ligne categorie
  365. if ($action == 'delete_section') {
  366. print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.$section, $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection', $ecmdir->label), 'confirm_deletesection', '', '', 1);
  367. }
  368. // End confirm
  369. if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i', $action) || $action == 'deletefile') {
  370. print '<table class="liste centpercent">'."\n";
  371. print '<!-- Title for auto directories -->'."\n";
  372. print '<tr class="liste_titre">'."\n";
  373. print '<th class="liste_titre" align="left" colspan="6">';
  374. print '&nbsp;'.$langs->trans("ECMSections");
  375. print '</th></tr>';
  376. $showonrightsize = '';
  377. // Auto section
  378. if (count($sectionauto)) {
  379. $htmltooltip = $langs->trans("ECMAreaDesc2");
  380. $htmltooltip .= '<br>'.$langs->trans("ECMAreaDesc2b");
  381. $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', true, false);
  382. print '<tr>';
  383. print '<td colspan="6">';
  384. print '<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">';
  385. $nbofentries = 0;
  386. $oldvallevel = 0;
  387. foreach ($sectionauto as $key => $val) {
  388. if (empty($val['test'])) {
  389. continue; // If condition to show the ECM auto directory is ok
  390. }
  391. print '<li class="directory collapsed">';
  392. if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
  393. print '<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER["PHP_SELF"].'?module='.urlencode($val['module']).'">';
  394. print $val['label'];
  395. print '</a>';
  396. } else {
  397. print '<a class="fmdirlia jqft ecmjqft" href="'.$_SERVER["PHP_SELF"].'?module='.urlencode($val['module']).'">';
  398. print $val['label'];
  399. print '</a>';
  400. }
  401. print '<div class="ecmjqft">';
  402. // Info
  403. $htmltooltip = '<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
  404. $htmltooltip .= '<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionAuto").'<br>';
  405. $htmltooltip .= '<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto").'<br>';
  406. $htmltooltip .= '<b>'.$langs->trans("Description").'</b>: '.$val['desc'];
  407. print $form->textwithpicto('', $htmltooltip, 1, 'info');
  408. print '</div>';
  409. print '</li>';
  410. $nbofentries++;
  411. }
  412. print '</ul></div></td></tr>';
  413. }
  414. print "</table>";
  415. }
  416. // End left panel
  417. ?>
  418. </div>
  419. <div id="ecm-layout-center" class="inline-block">
  420. <div class="pane-in ecm-in-layout-center">
  421. <div id="ecmfileview" class="ecmfileview">
  422. <?php
  423. // Start right panel
  424. $mode = 'noajax';
  425. $url = DOL_URL_ROOT.'/ecm/index_auto.php';
  426. include_once DOL_DOCUMENT_ROOT.'/core/ajax/ajaxdirpreview.php';
  427. // End right panel
  428. ?>
  429. </div>
  430. </div>
  431. </div>
  432. </div> <!-- End div id="containerlayout" -->
  433. <?php
  434. // End of page
  435. if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) {
  436. include DOL_DOCUMENT_ROOT.'/ecm/tpl/enablefiletreeajax.tpl.php';
  437. }
  438. print dol_get_fiche_end();
  439. llxFooter();
  440. $db->close();