search.php 8.3 KB

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