search.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
  29. // Load translation files required by the page
  30. $langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
  31. // Security check
  32. if ($user->socid) {
  33. $socid = $user->socid;
  34. }
  35. $result = restrictedArea($user, 'ecm', '');
  36. // Load permissions
  37. $user->getrights('ecm');
  38. // Get parameters
  39. $socid = GETPOST('socid', 'int');
  40. $action = GETPOST('action', 'aZ09');
  41. $section = GETPOST('section');
  42. if (!$section) {
  43. $section = 0;
  44. }
  45. $module = GETPOST('module', 'alpha');
  46. $website = GETPOST('website', 'alpha');
  47. $pageid = GETPOST('pageid', 'int');
  48. if (empty($module)) {
  49. $module = 'ecm';
  50. }
  51. $upload_dir = $conf->ecm->dir_output.'/'.$section;
  52. $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
  53. $sortfield = GETPOST('sortfield', 'aZ09comma');
  54. $sortorder = GETPOST('sortorder', 'aZ09comma');
  55. $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
  56. if (empty($page) || $page == -1) {
  57. $page = 0;
  58. } // If $page is not defined, or '' or -1
  59. $offset = $limit * $page;
  60. $pageprev = $page - 1;
  61. $pagenext = $page + 1;
  62. if (!$sortorder) {
  63. $sortorder = "ASC";
  64. }
  65. if (!$sortfield) {
  66. $sortfield = "label";
  67. }
  68. $ecmdir = new EcmDirectory($db);
  69. if (!empty($section)) {
  70. $result = $ecmdir->fetch($section);
  71. if (!$result > 0) {
  72. dol_print_error($db, $ecmdir->error);
  73. exit;
  74. }
  75. }
  76. $permtoread = $user->rights->ecm->read;
  77. if (!$permtoread) {
  78. accessforbidden();
  79. }
  80. /*
  81. * Actions
  82. */
  83. // None
  84. /*
  85. * View
  86. */
  87. llxHeader();
  88. $form = new Form($db);
  89. $ecmdirstatic = new EcmDirectory($db);
  90. $userstatic = new User($db);
  91. // Ajout rubriques automatiques
  92. $rowspan = 0;
  93. $sectionauto = array();
  94. if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
  95. $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"));
  96. }
  97. if (!empty($conf->societe->enabled)) {
  98. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
  99. }
  100. if (!empty($conf->propal->enabled)) {
  101. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
  102. }
  103. if (!empty($conf->contrat->enabled)) {
  104. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
  105. }
  106. if (!empty($conf->commande->enabled)) {
  107. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
  108. }
  109. if (!empty($conf->facture->enabled)) {
  110. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
  111. }
  112. if (!empty($conf->supplier_proposal->enabled)) {
  113. $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")));
  114. }
  115. if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
  116. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
  117. }
  118. if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) {
  119. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
  120. }
  121. if (!empty($conf->tax->enabled)) {
  122. $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")));
  123. }
  124. if (!empty($conf->projet->enabled)) {
  125. $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
  126. }
  127. if (!empty($conf->ficheinter->enabled)) {
  128. $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")));
  129. }
  130. if (!empty($conf->expensereport->enabled)) {
  131. $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")));
  132. }
  133. if (!empty($conf->holiday->enabled)) {
  134. $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")));
  135. }
  136. if (!empty($conf->banque->enabled)) {
  137. $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")));
  138. }
  139. if (!empty($conf->mrp->enabled)) {
  140. $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")));
  141. }
  142. if (!empty($conf->recruitment->enabled)) {
  143. $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")));
  144. }
  145. //***********************
  146. // List
  147. //***********************
  148. print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
  149. //print $langs->trans("ECMAreaDesc")."<br>";
  150. //print $langs->trans("ECMAreaDesc2")."<br>";
  151. //print "<br>\n";
  152. print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
  153. // Tool bar
  154. $head = ecm_prepare_head_fm($ecmdir, $module, $section);
  155. //print dol_get_fiche_head($head, 'search_form', '', 1);
  156. print '<table class="border centpercent"><tr><td width="40%" valign="top">';
  157. // Left area
  158. //print load_fiche_titre($langs->trans("ECMSectionsManual"));
  159. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  160. print '<input type="hidden" name="token" value="'.newToken().'">';
  161. print '<table class="nobordernopadding" width="100%">';
  162. print "<tr class=\"liste_titre\">";
  163. print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
  164. print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
  165. print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
  166. print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
  167. print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  168. print "</table></form>";
  169. //print $langs->trans("ECMSectionManualDesc");
  170. //print load_fiche_titre($langs->trans("ECMSectionAuto"));
  171. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  172. print '<input type="hidden" name="token" value="'.newToken().'">';
  173. print '<table class="nobordernopadding" width="100%">';
  174. print "<tr class=\"liste_titre\">";
  175. print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
  176. $buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
  177. $butshown = 0;
  178. foreach ($sectionauto as $sectioncur) {
  179. if (!$sectioncur['test']) {
  180. continue;
  181. }
  182. print '<tr class="impair">';
  183. print "<td>".$sectioncur['label'].':</td>';
  184. print '<td';
  185. print ' class="right"';
  186. print '>';
  187. print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
  188. print '</td>';
  189. print '</tr>';
  190. $butshown++;
  191. }
  192. print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  193. print "</table></form>";
  194. //print $langs->trans("ECMSectionAutoDesc");
  195. print '</td><td class="tdtop">';
  196. // Right area
  197. $relativepath = $ecmdir->getRelativePath();
  198. $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
  199. $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
  200. $formfile = new FormFile($db);
  201. $param = '&section='.urlencode($section);
  202. $textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
  203. $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty);
  204. print '</td></tr>';
  205. print '</table>';
  206. print '<br>';
  207. // End of page
  208. llxFooter();
  209. $db->close();