dolibarr 25.0.0-alpha
search.php
Go to the documentation of this file.
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 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
34
43'
44@phan-var-force array<int,string> $bc
45';
46// Load translation files required by the page
47$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
48
49// Security check
50if ($user->socid) {
51 $socid = $user->socid;
52}
53$result = restrictedArea($user, 'ecm', '');
54
55// Load permissions
56$user->loadRights('ecm');
57
58// Get parameters
59$socid = GETPOSTINT('socid');
60$action = GETPOST('action', 'aZ09');
61$section = GETPOST('section');
62if (!$section) {
63 $section = 0;
64}
65
66$module = GETPOST('module', 'aZ09arobase');
67$website = GETPOST('website', 'alpha');
68$pageid = GETPOSTINT('pageid');
69if (empty($module)) {
70 $module = 'ecm';
71}
72
73$upload_dir = $conf->ecm->dir_output.'/'.$section;
74
75$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
76$sortfield = GETPOST('sortfield', 'aZ09comma');
77$sortorder = GETPOST('sortorder', 'aZ09comma');
78$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
79if (empty($page) || $page == -1) {
80 $page = 0;
81} // If $page is not defined, or '' or -1
82$offset = $limit * $page;
83$pageprev = $page - 1;
84$pagenext = $page + 1;
85if (!$sortorder) {
86 $sortorder = "ASC";
87}
88if (!$sortfield) {
89 $sortfield = "label";
90}
91
92$ecmdir = new EcmDirectory($db);
93if (!empty($section)) {
94 $result = $ecmdir->fetch((int) $section);
95 if (!($result > 0)) {
96 dol_print_error($db, $ecmdir->error);
97 exit;
98 }
99}
100
101$permissiontoread = $user->hasRight('ecm', 'read');
102
103if (!$permissiontoread) {
105}
106
107
108/*
109 * Actions
110 */
111
112// None
113
114
115
116/*
117 * View
118 */
119
120llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-ecm page-search');
121
122$form = new Form($db);
123$ecmdirstatic = new EcmDirectory($db);
124$userstatic = new User($db);
125
126
127// Ajout rubriques automatiques
128$rowspan = 0;
129$sectionauto = array();
130if (isModEnabled("product") || isModEnabled("service")) {
131 $langs->load("products");
132 $rowspan++;
133 $sectionauto[] = array('level' => 1, 'module' => 'product', 'test' => (isModEnabled("product") || isModEnabled("service")), 'label' => $langs->trans("ProductsAndServices"), 'desc' => $langs->trans("ECMDocsByProducts"));
134}
135if (isModEnabled("societe")) {
136 $rowspan++;
137 $sectionauto[] = array('level' => 1, 'module' => 'company', 'test' => isModEnabled('societe'), 'label' => $langs->trans("ThirdParties"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
138}
139if (isModEnabled("propal")) {
140 $rowspan++;
141 $sectionauto[] = array('level' => 1, 'module' => 'propal', 'test' => isModEnabled('propal'), 'label' => $langs->trans("Proposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
142}
143if (isModEnabled('contract')) {
144 $rowspan++;
145 $sectionauto[] = array('level' => 1, 'module' => 'contract', 'test' => isModEnabled('contract'), 'label' => $langs->trans("Contracts"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
146}
147if (isModEnabled('order')) {
148 $rowspan++;
149 $sectionauto[] = array('level' => 1, 'module' => 'order', 'test' => isModEnabled('order'), 'label' => $langs->trans("CustomersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
150}
151if (isModEnabled('invoice')) {
152 $rowspan++;
153 $sectionauto[] = array('level' => 1, 'module' => 'invoice', 'test' => isModEnabled('invoice'), 'label' => $langs->trans("CustomersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
154}
155if (isModEnabled('supplier_proposal')) {
156 $langs->load("supplier_proposal");
157 $rowspan++;
158 $sectionauto[] = array('level' => 1, 'module' => 'supplier_proposal', 'test' => isModEnabled('supplier_proposal'), 'label' => $langs->trans("SupplierProposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
159}
160if (isModEnabled("supplier_order")) {
161 $rowspan++;
162 $sectionauto[] = array('level' => 1, 'module' => 'order_supplier', 'test' => isModEnabled("supplier_order"), 'label' => $langs->trans("SuppliersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SuppliersOrders")));
163}
164if (isModEnabled("supplier_invoice")) {
165 $rowspan++;
166 $sectionauto[] = array('level' => 1, 'module' => 'invoice_supplier', 'test' => isModEnabled("supplier_invoice"), 'label' => $langs->trans("SuppliersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
167}
168if (isModEnabled('tax')) {
169 $langs->load("compta");
170 $rowspan++;
171 $sectionauto[] = array('level' => 1, 'module' => 'tax', 'test' => isModEnabled('tax'), 'label' => $langs->trans("SocialContributions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
172}
173if (isModEnabled('project')) {
174 $rowspan++;
175 $sectionauto[] = array('level' => 1, 'module' => 'project', 'test' => isModEnabled('project'), 'label' => $langs->trans("Projects"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
176}
177if (isModEnabled('intervention')) {
178 $langs->load("interventions");
179 $rowspan++;
180 $sectionauto[] = array('level' => 1, 'module' => 'fichinter', 'test' => isModEnabled('intervention'), 'label' => $langs->trans("Interventions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
181}
182if (isModEnabled('expensereport')) {
183 $langs->load("trips");
184 $rowspan++;
185 $sectionauto[] = array('level' => 1, 'module' => 'expensereport', 'test' => isModEnabled('expensereport'), 'label' => $langs->trans("ExpenseReports"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
186}
187if (isModEnabled('holiday')) {
188 $langs->load("holiday");
189 $rowspan++;
190 $sectionauto[] = array('level' => 1, 'module' => 'holiday', 'test' => isModEnabled('holiday'), 'label' => $langs->trans("Holidays"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
191}
192if (isModEnabled("bank")) {
193 $langs->load("banks");
194 $rowspan++;
195 $sectionauto[] = array('level' => 1, 'module' => 'banque', 'test' => isModEnabled('bank'), 'label' => $langs->trans("BankAccount"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
196}
197if (isModEnabled('mrp')) {
198 $langs->load("mrp");
199 $rowspan++;
200 $sectionauto[] = array('level' => 1, 'module' => 'mrp-mo', 'test' => isModEnabled('mrp'), 'label' => $langs->trans("MOs"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
201}
202if (isModEnabled('recruitment')) {
203 $langs->load("recruitment");
204 $rowspan++;
205 $sectionauto[] = array('level' => 1, 'module' => 'recruitment-recruitmentcandidature', 'test' => isModEnabled('recruitment'), 'label' => $langs->trans("Candidatures"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
206}
207
208
209//***********************
210// List
211//***********************
212print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
213
214print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
215
216// Tool bar
217$head = ecm_prepare_head_fm($ecmdir);
218//print dol_get_fiche_head($head, 'search_form', '', 1);
219
220
221print '<table class="border centpercent"><tr><td width="40%" valign="top">';
222
223// Left area
224
225
226//print load_fiche_titre($langs->trans("ECMSectionsManual"));
227
228print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
229print '<input type="hidden" name="token" value="'.newToken().'">';
230print '<table class="nobordernopadding" width="100%">';
231print "<tr class=\"liste_titre\">";
232print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
233print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
234print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
235print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
236print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
237print "</table></form>";
238//print $langs->trans("ECMSectionManualDesc");
239
240//print load_fiche_titre($langs->trans("ECMSectionAuto"));
241
242print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
243print '<input type="hidden" name="token" value="'.newToken().'">';
244print '<table class="nobordernopadding" width="100%">';
245print "<tr class=\"liste_titre\">";
246print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
247
248$buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
249$butshown = 0;
250foreach ($sectionauto as $sectioncur) {
251 if (!$sectioncur['test']) {
252 continue;
253 }
254 print '<tr class="impair">';
255 print "<td>".$sectioncur['label'].':</td>';
256 print '<td';
257 print ' class="right"';
258 print '>';
259 print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
260 print '</td>';
261 print '</tr>';
262 $butshown++;
263}
264
265print '<tr '.$bc[0].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
266print "</table></form>";
267//print $langs->trans("ECMSectionAutoDesc");
268
269
270
271print '</td><td class="tdtop">';
272
273// Right area
274$relativepath = $ecmdir->getRelativePath();
275$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
276$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
277
278$formfile = new FormFile($db);
279$param = '&section='.urlencode($section);
280$textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
281$formfile->list_of_documents($filearray, null, 'ecm', $param, 1, $relativepath, $user->hasRight('ecm', 'upload'), 1, $textifempty);
282
283
284print '</td></tr>';
285
286print '</table>';
287
288
289print '<br>';
290
291// End of page
292llxFooter();
293$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage ECM directories.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
Class to manage Dolibarr users.
ecm_prepare_head_fm($object)
Prepare array with list of tabs.
Definition ecm.lib.php:154
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:65
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
isModEnabled($module)
Is Dolibarr module enabled.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.