search.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 <http://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->societe_id) $socid=$user->societe_id;
  33. $result = restrictedArea($user, 'ecm','');
  34. // Load permissions
  35. $user->getrights('ecm');
  36. // Get parameters
  37. $socid = GETPOST('socid','int');
  38. $action = GETPOST('action','alpha');
  39. $section=GETPOST('section');
  40. if (! $section) $section=0;
  41. $module = GETPOST('module', 'alpha');
  42. $website = GETPOST('website', 'alpha');
  43. $pageid = GETPOST('pageid', 'int');
  44. if (empty($module)) $module='ecm';
  45. $upload_dir = $conf->ecm->dir_output.'/'.$section;
  46. $sortfield = GETPOST("sortfield",'alpha');
  47. $sortorder = GETPOST("sortorder",'alpha');
  48. $page = GETPOST("page",'int');
  49. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  50. $offset = $conf->liste_limit * $page;
  51. $pageprev = $page - 1;
  52. $pagenext = $page + 1;
  53. if (! $sortorder) $sortorder="ASC";
  54. if (! $sortfield) $sortfield="label";
  55. $ecmdir = new EcmDirectory($db);
  56. if (! empty($section))
  57. {
  58. $result=$ecmdir->fetch($section);
  59. if (! $result > 0)
  60. {
  61. dol_print_error($db,$ecmdir->error);
  62. exit;
  63. }
  64. }
  65. /*******************************************************************
  66. * ACTIONS
  67. *
  68. * Put here all code to do according to value of "action" parameter
  69. ********************************************************************/
  70. /*******************************************************************
  71. * PAGE
  72. *
  73. * Put here all code to do according to value of "action" parameter
  74. ********************************************************************/
  75. llxHeader();
  76. $form=new Form($db);
  77. $ecmdirstatic = new EcmDirectory($db);
  78. $userstatic = new User($db);
  79. // Ajout rubriques automatiques
  80. $rowspan=0;
  81. $sectionauto=array();
  82. if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>$conf->product->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); }
  83. if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); }
  84. if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); }
  85. if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); }
  86. if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
  87. if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
  88. if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
  89. if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
  90. //***********************
  91. // List
  92. //***********************
  93. print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
  94. //print $langs->trans("ECMAreaDesc")."<br>";
  95. //print $langs->trans("ECMAreaDesc2")."<br>";
  96. //print "<br>\n";
  97. print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
  98. // Tool bar
  99. $head = ecm_prepare_head_fm($ecmdir, $module, $section);
  100. //dol_fiche_head($head, 'search_form', '', 1);
  101. print '<table class="border" width="100%"><tr><td width="40%" valign="top">';
  102. // Left area
  103. //print load_fiche_titre($langs->trans("ECMSectionsManual"));
  104. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  105. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  106. print '<table class="nobordernopadding" width="100%">';
  107. print "<tr class=\"liste_titre\">";
  108. print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
  109. print "<tr ".$bc[false]."><td>".$langs->trans("Ref").':</td><td align="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
  110. print "<tr ".$bc[false]."><td>".$langs->trans("Title").':</td><td align="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
  111. print "<tr ".$bc[false]."><td>".$langs->trans("Keyword").':</td><td align="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
  112. print "<tr ".$bc[false].'><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  113. print "</table></form>";
  114. //print $langs->trans("ECMSectionManualDesc");
  115. //print load_fiche_titre($langs->trans("ECMSectionAuto"));
  116. print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
  117. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  118. print '<table class="nobordernopadding" width="100%">';
  119. print "<tr class=\"liste_titre\">";
  120. print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
  121. $buthtml='<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
  122. $butshown=0;
  123. foreach($sectionauto as $sectioncur)
  124. {
  125. if (! $sectioncur['test']) continue;
  126. //if ($butshown % 2 == 0)
  127. print '<tr '. $bc[false].'>';
  128. print "<td>".$sectioncur['label'].':</td>';
  129. print '<td';
  130. //if ($butshown % 2 == 1)
  131. print ' align="right"';
  132. print '>';
  133. print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
  134. print '</td>';
  135. //if ($butshown % 2 == 1)
  136. print '</tr>';
  137. $butshown++;
  138. }
  139. //if ($butshown % 2 == 1)
  140. // print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
  141. print '<tr '. $bc[false].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
  142. print "</table></form>";
  143. //print $langs->trans("ECMSectionAutoDesc");
  144. print '</td><td class="tdtop">';
  145. // Right area
  146. $relativepath=$ecmdir->getRelativePath();
  147. $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
  148. $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
  149. $formfile=new FormFile($db);
  150. $param='&amp;section='.$section;
  151. $textifempty=($section?$langs->trans("NoFileFound"):$langs->trans("ECMSelectASection"));
  152. $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty);
  153. // print '<table width="100%" class="border">';
  154. // print '<tr><td> </td></tr></table>';
  155. print '</td></tr>';
  156. print '</table>';
  157. print '<br>';
  158. // End of page
  159. llxFooter();
  160. $db->close();