search.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <?php
  2. /* Copyright (C) 2008-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2008-2009 Regis Houssin <regis.houssin@inodbox.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/ecm/search.php
  20. * \ingroup ecm
  21. * \brief Page to make advanced search into ECM
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
  32. // Security check
  33. if ($user->socid) {
  34. $socid = $user->socid;
  35. }
  36. $result = restrictedArea($user, 'ecm', '');
  37. // Load permissions
  38. $user->getrights('ecm');
  39. // Get parameters
  40. $socid = GETPOST('socid', 'int');
  41. $action = GETPOST('action', 'aZ09');
  42. $section = GETPOST('section');
  43. if (!$section) {
  44. $section = 0;
  45. }
  46. $module = GETPOST('module', 'alpha');
  47. $website = GETPOST('website', 'alpha');
  48. $pageid = GETPOST('pageid', 'int');
  49. if (empty($module)) {
  50. $module = 'ecm';
  51. }
  52. $upload_dir = $conf->ecm->dir_output.'/'.$section;
  53. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  54. $sortfield = GETPOST('sortfield', 'aZ09comma');
  55. $sortorder = GETPOST('sortorder', 'aZ09comma');
  56. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  57. if (empty($page) || $page == -1) {
  58. $page = 0;
  59. } // If $page is not defined, or '' or -1
  60. $offset = $limit * $page;
  61. $pageprev = $page - 1;
  62. $pagenext = $page + 1;
  63. if (!$sortorder) {
  64. $sortorder = "ASC";
  65. }
  66. if (!$sortfield) {
  67. $sortfield = "label";
  68. }
  69. $ecmdir = new EcmDirectory($db);
  70. if (!empty($section)) {
  71. $result = $ecmdir->fetch($section);
  72. if (!($result > 0)) {
  73. dol_print_error($db, $ecmdir->error);
  74. exit;
  75. }
  76. }
  77. $permissiontoread = $user->rights->ecm->read;
  78. if (!$permissiontoread) {
  79. accessforbidden();
  80. }
  81. /*
  82. * Actions
  83. */
  84. // None
  85. /*
  86. * View
  87. */
  88. llxHeader();
  89. $form = new Form($db);
  90. $ecmdirstatic = new EcmDirectory($db);
  91. $userstatic = new User($db);
  92. // Ajout rubriques automatiques
  93. $rowspan = 0;
  94. $sectionauto = array();
  95. if (isModEnabled("product") || isModEnabled("service")) {
  96. $langs->load("products");
  97. $rowspan++;
  98. $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
  99. }
  100. if (isModEnabled("societe")) {
  101. $rowspan++;
  102. $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
  103. }
  104. if (isModEnabled("propal")) {
  105. $rowspan++;
  106. $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
  107. }
  108. if (isModEnabled('contrat')) {
  109. $rowspan++;
  110. $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
  111. }
  112. if (isModEnabled('commande')) {
  113. $rowspan++;
  114. $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
  115. }
  116. if (isModEnabled('facture')) {
  117. $rowspan++;
  118. $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
  119. }
  120. if (isModEnabled('supplier_proposal')) {
  121. $langs->load("supplier_proposal");
  122. $rowspan++;
  123. $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
  124. }
  125. if (isModEnabled("supplier_order")) {
  126. $rowspan++;
  127. $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
  128. }
  129. if (isModEnabled("supplier_invoice")) {
  130. $rowspan++;
  131. $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
  132. }
  133. if (isModEnabled('tax')) {
  134. $langs->load("compta");
  135. $rowspan++;
  136. $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
  137. }
  138. if (isModEnabled('project')) {
  139. $rowspan++;
  140. $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
  141. }
  142. if (isModEnabled('ficheinter')) {
  143. $langs->load("interventions");
  144. $rowspan++;
  145. $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
  146. }
  147. if (isModEnabled('expensereport')) {
  148. $langs->load("trips");
  149. $rowspan++;
  150. $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
  151. }
  152. if (isModEnabled('holiday')) {
  153. $langs->load("holiday");
  154. $rowspan++;
  155. $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
  156. }
  157. if (isModEnabled("banque")) {
  158. $langs->load("banks");
  159. $rowspan++;
  160. $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
  161. }
  162. if (isModEnabled('mrp')) {
  163. $langs->load("mrp");
  164. $rowspan++;
  165. $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
  166. }
  167. if (isModEnabled('recruitment')) {
  168. $langs->load("recruitment");
  169. $rowspan++;
  170. $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
  171. }
  172. //***********************
  173. // List
  174. //***********************
  175. print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
  176. print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
  177. // Tool bar
  178. $head = ecm_prepare_head_fm($ecmdir);
  179. //print dol_get_fiche_head($head, 'search_form', '', 1);
  180. print '<table class="border centpercent"><tr><td width="40%" valign="top">';
  181. // Left area
  182. //print load_fiche_titre($langs->trans("ECMSectionsManual"));
  183. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  184. print '<input type="hidden" name="token" value="'.newToken().'">';
  185. print '<table class="nobordernopadding" width="100%">';
  186. print "<tr class=\"liste_titre\">";
  187. print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
  188. print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
  189. print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
  190. print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
  191. print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  192. print "</table></form>";
  193. //print $langs->trans("ECMSectionManualDesc");
  194. //print load_fiche_titre($langs->trans("ECMSectionAuto"));
  195. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  196. print '<input type="hidden" name="token" value="'.newToken().'">';
  197. print '<table class="nobordernopadding" width="100%">';
  198. print "<tr class=\"liste_titre\">";
  199. print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
  200. $buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
  201. $butshown = 0;
  202. foreach ($sectionauto as $sectioncur) {
  203. if (!$sectioncur['test']) {
  204. continue;
  205. }
  206. print '<tr class="impair">';
  207. print "<td>".$sectioncur['label'].':</td>';
  208. print '<td';
  209. print ' class="right"';
  210. print '>';
  211. print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
  212. print '</td>';
  213. print '</tr>';
  214. $butshown++;
  215. }
  216. print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  217. print "</table></form>";
  218. //print $langs->trans("ECMSectionAutoDesc");
  219. print '</td><td class="tdtop">';
  220. // Right area
  221. $relativepath = $ecmdir->getRelativePath();
  222. $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
  223. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
  224. $formfile = new FormFile($db);
  225. $param = '&section='.urlencode($section);
  226. $textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
  227. $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->hasRight('ecm', 'upload'), 1, $textifempty);
  228. print '</td></tr>';
  229. print '</table>';
  230. print '<br>';
  231. // End of page
  232. llxFooter();
  233. $db->close();