dolibarr 21.0.0-beta
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 MDW <mdeweerd@users.noreply.github.com>
5 * Copyright (C) 2024 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// Load translation files required by the page
44$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
45
46// Security check
47if ($user->socid) {
48 $socid = $user->socid;
49}
50$result = restrictedArea($user, 'ecm', '');
51
52// Load permissions
53$user->loadRights('ecm');
54
55// Get parameters
56$socid = GETPOSTINT('socid');
57$action = GETPOST('action', 'aZ09');
58$section = GETPOST('section');
59if (!$section) {
60 $section = 0;
61}
62
63$module = GETPOST('module', 'alpha');
64$website = GETPOST('website', 'alpha');
65$pageid = GETPOSTINT('pageid');
66if (empty($module)) {
67 $module = 'ecm';
68}
69
70$upload_dir = $conf->ecm->dir_output.'/'.$section;
71
72$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
73$sortfield = GETPOST('sortfield', 'aZ09comma');
74$sortorder = GETPOST('sortorder', 'aZ09comma');
75$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
76if (empty($page) || $page == -1) {
77 $page = 0;
78} // If $page is not defined, or '' or -1
79$offset = $limit * $page;
80$pageprev = $page - 1;
81$pagenext = $page + 1;
82if (!$sortorder) {
83 $sortorder = "ASC";
84}
85if (!$sortfield) {
86 $sortfield = "label";
87}
88
89$ecmdir = new EcmDirectory($db);
90if (!empty($section)) {
91 $result = $ecmdir->fetch($section);
92 if (!($result > 0)) {
93 dol_print_error($db, $ecmdir->error);
94 exit;
95 }
96}
97
98$permissiontoread = $user->hasRight('ecm', 'read');
99
100if (!$permissiontoread) {
102}
103
104
105/*
106 * Actions
107 */
108
109// None
110
111
112
113/*
114 * View
115 */
116
117llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-ecm page-search');
118
119$form = new Form($db);
120$ecmdirstatic = new EcmDirectory($db);
121$userstatic = new User($db);
122
123
124// Ajout rubriques automatiques
125$rowspan = 0;
126$sectionauto = array();
127if (isModEnabled("product") || isModEnabled("service")) {
128 $langs->load("products");
129 $rowspan++;
130 $sectionauto[] = array('level' => 1, 'module' => 'product', 'test' => (isModEnabled("product") || isModEnabled("service")), 'label' => $langs->trans("ProductsAndServices"), 'desc' => $langs->trans("ECMDocsByProducts"));
131}
132if (isModEnabled("societe")) {
133 $rowspan++;
134 $sectionauto[] = array('level' => 1, 'module' => 'company', 'test' => isModEnabled('societe'), 'label' => $langs->trans("ThirdParties"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
135}
136if (isModEnabled("propal")) {
137 $rowspan++;
138 $sectionauto[] = array('level' => 1, 'module' => 'propal', 'test' => isModEnabled('propal'), 'label' => $langs->trans("Proposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
139}
140if (isModEnabled('contract')) {
141 $rowspan++;
142 $sectionauto[] = array('level' => 1, 'module' => 'contract', 'test' => isModEnabled('contract'), 'label' => $langs->trans("Contracts"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
143}
144if (isModEnabled('order')) {
145 $rowspan++;
146 $sectionauto[] = array('level' => 1, 'module' => 'order', 'test' => isModEnabled('order'), 'label' => $langs->trans("CustomersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
147}
148if (isModEnabled('invoice')) {
149 $rowspan++;
150 $sectionauto[] = array('level' => 1, 'module' => 'invoice', 'test' => isModEnabled('invoice'), 'label' => $langs->trans("CustomersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
151}
152if (isModEnabled('supplier_proposal')) {
153 $langs->load("supplier_proposal");
154 $rowspan++;
155 $sectionauto[] = array('level' => 1, 'module' => 'supplier_proposal', 'test' => isModEnabled('supplier_proposal'), 'label' => $langs->trans("SupplierProposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
156}
157if (isModEnabled("supplier_order")) {
158 $rowspan++;
159 $sectionauto[] = array('level' => 1, 'module' => 'order_supplier', 'test' => isModEnabled("supplier_order"), 'label' => $langs->trans("SuppliersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
160}
161if (isModEnabled("supplier_invoice")) {
162 $rowspan++;
163 $sectionauto[] = array('level' => 1, 'module' => 'invoice_supplier', 'test' => isModEnabled("supplier_invoice"), 'label' => $langs->trans("SuppliersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
164}
165if (isModEnabled('tax')) {
166 $langs->load("compta");
167 $rowspan++;
168 $sectionauto[] = array('level' => 1, 'module' => 'tax', 'test' => isModEnabled('tax'), 'label' => $langs->trans("SocialContributions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
169}
170if (isModEnabled('project')) {
171 $rowspan++;
172 $sectionauto[] = array('level' => 1, 'module' => 'project', 'test' => isModEnabled('project'), 'label' => $langs->trans("Projects"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
173}
174if (isModEnabled('intervention')) {
175 $langs->load("interventions");
176 $rowspan++;
177 $sectionauto[] = array('level' => 1, 'module' => 'fichinter', 'test' => isModEnabled('intervention'), 'label' => $langs->trans("Interventions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
178}
179if (isModEnabled('expensereport')) {
180 $langs->load("trips");
181 $rowspan++;
182 $sectionauto[] = array('level' => 1, 'module' => 'expensereport', 'test' => isModEnabled('expensereport'), 'label' => $langs->trans("ExpenseReports"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
183}
184if (isModEnabled('holiday')) {
185 $langs->load("holiday");
186 $rowspan++;
187 $sectionauto[] = array('level' => 1, 'module' => 'holiday', 'test' => isModEnabled('holiday'), 'label' => $langs->trans("Holidays"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
188}
189if (isModEnabled("bank")) {
190 $langs->load("banks");
191 $rowspan++;
192 $sectionauto[] = array('level' => 1, 'module' => 'banque', 'test' => isModEnabled('bank'), 'label' => $langs->trans("BankAccount"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
193}
194if (isModEnabled('mrp')) {
195 $langs->load("mrp");
196 $rowspan++;
197 $sectionauto[] = array('level' => 1, 'module' => 'mrp-mo', 'test' => isModEnabled('mrp'), 'label' => $langs->trans("MOs"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
198}
199if (isModEnabled('recruitment')) {
200 $langs->load("recruitment");
201 $rowspan++;
202 $sectionauto[] = array('level' => 1, 'module' => 'recruitment-recruitmentcandidature', 'test' => isModEnabled('recruitment'), 'label' => $langs->trans("Candidatures"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
203}
204
205
206//***********************
207// List
208//***********************
209print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
210
211print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
212
213// Tool bar
214$head = ecm_prepare_head_fm($ecmdir);
215//print dol_get_fiche_head($head, 'search_form', '', 1);
216
217
218print '<table class="border centpercent"><tr><td width="40%" valign="top">';
219
220// Left area
221
222
223//print load_fiche_titre($langs->trans("ECMSectionsManual"));
224
225print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
226print '<input type="hidden" name="token" value="'.newToken().'">';
227print '<table class="nobordernopadding" width="100%">';
228print "<tr class=\"liste_titre\">";
229print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
230print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
231print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
232print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
233print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
234print "</table></form>";
235//print $langs->trans("ECMSectionManualDesc");
236
237//print load_fiche_titre($langs->trans("ECMSectionAuto"));
238
239print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
240print '<input type="hidden" name="token" value="'.newToken().'">';
241print '<table class="nobordernopadding" width="100%">';
242print "<tr class=\"liste_titre\">";
243print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
244
245$buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
246$butshown = 0;
247foreach ($sectionauto as $sectioncur) {
248 if (!$sectioncur['test']) {
249 continue;
250 }
251 print '<tr class="impair">';
252 print "<td>".$sectioncur['label'].':</td>';
253 print '<td';
254 print ' class="right"';
255 print '>';
256 print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
257 print '</td>';
258 print '</tr>';
259 $butshown++;
260}
261
262print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
263print "</table></form>";
264//print $langs->trans("ECMSectionAutoDesc");
265
266
267
268print '</td><td class="tdtop">';
269
270// Right area
271$relativepath = $ecmdir->getRelativePath();
272$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
273$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
274
275$formfile = new FormFile($db);
276$param = '&section='.urlencode($section);
277$textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
278$formfile->list_of_documents($filearray, null, 'ecm', $param, 1, $relativepath, $user->hasRight('ecm', 'upload'), 1, $textifempty);
279
280
281print '</td></tr>';
282
283print '</table>';
284
285
286print '<br>';
287
288// End of page
289llxFooter();
290$db->close();
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:71
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.
llxFooter()
Footer empty.
Definition document.php:107
ecm_prepare_head_fm($object)
Prepare array with list of tabs.
Definition ecm.lib.php:154
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:63
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.