search.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
  97. }
  98. if (isModEnabled("societe")) {
  99. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
  100. }
  101. if (isModEnabled("propal")) {
  102. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
  103. }
  104. if (isModEnabled('contrat')) {
  105. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
  106. }
  107. if (isModEnabled('commande')) {
  108. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
  109. }
  110. if (isModEnabled('facture')) {
  111. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
  112. }
  113. if (isModEnabled('supplier_proposal')) {
  114. $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
  115. }
  116. if (isModEnabled("supplier_order")) {
  117. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
  118. }
  119. if (isModEnabled("supplier_invoice")) {
  120. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
  121. }
  122. if (isModEnabled('tax')) {
  123. $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
  124. }
  125. if (isModEnabled('project')) {
  126. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
  127. }
  128. if (isModEnabled('ficheinter')) {
  129. $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
  130. }
  131. if (isModEnabled('expensereport')) {
  132. $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
  133. }
  134. if (isModEnabled('holiday')) {
  135. $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
  136. }
  137. if (isModEnabled("banque")) {
  138. $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
  139. }
  140. if (isModEnabled('mrp')) {
  141. $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
  142. }
  143. if (isModEnabled('recruitment')) {
  144. $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
  145. }
  146. //***********************
  147. // List
  148. //***********************
  149. print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
  150. print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
  151. // Tool bar
  152. $head = ecm_prepare_head_fm($ecmdir);
  153. //print dol_get_fiche_head($head, 'search_form', '', 1);
  154. print '<table class="border centpercent"><tr><td width="40%" valign="top">';
  155. // Left area
  156. //print load_fiche_titre($langs->trans("ECMSectionsManual"));
  157. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  158. print '<input type="hidden" name="token" value="'.newToken().'">';
  159. print '<table class="nobordernopadding" width="100%">';
  160. print "<tr class=\"liste_titre\">";
  161. print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
  162. print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
  163. print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
  164. print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
  165. print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  166. print "</table></form>";
  167. //print $langs->trans("ECMSectionManualDesc");
  168. //print load_fiche_titre($langs->trans("ECMSectionAuto"));
  169. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  170. print '<input type="hidden" name="token" value="'.newToken().'">';
  171. print '<table class="nobordernopadding" width="100%">';
  172. print "<tr class=\"liste_titre\">";
  173. print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
  174. $buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
  175. $butshown = 0;
  176. foreach ($sectionauto as $sectioncur) {
  177. if (!$sectioncur['test']) {
  178. continue;
  179. }
  180. print '<tr class="impair">';
  181. print "<td>".$sectioncur['label'].':</td>';
  182. print '<td';
  183. print ' class="right"';
  184. print '>';
  185. print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
  186. print '</td>';
  187. print '</tr>';
  188. $butshown++;
  189. }
  190. print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  191. print "</table></form>";
  192. //print $langs->trans("ECMSectionAutoDesc");
  193. print '</td><td class="tdtop">';
  194. // Right area
  195. $relativepath = $ecmdir->getRelativePath();
  196. $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
  197. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  198. $formfile = new FormFile($db);
  199. $param = '&section='.urlencode($section);
  200. $textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
  201. $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty);
  202. print '</td></tr>';
  203. print '</table>';
  204. print '<br>';
  205. // End of page
  206. llxFooter();
  207. $db->close();