dolibarr 21.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 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
33
34// Load translation files required by the page
35$langs->loadLangs(array("ecm", "companies", "other", "users", "orders", "propal", "bills", "contracts"));
36
37// Security check
38if ($user->socid) {
39 $socid = $user->socid;
40}
41$result = restrictedArea($user, 'ecm', '');
42
43// Load permissions
44$user->loadRights('ecm');
45
46// Get parameters
47$socid = GETPOSTINT('socid');
48$action = GETPOST('action', 'aZ09');
49$section = GETPOST('section');
50if (!$section) {
51 $section = 0;
52}
53
54$module = GETPOST('module', 'alpha');
55$website = GETPOST('website', 'alpha');
56$pageid = GETPOSTINT('pageid');
57if (empty($module)) {
58 $module = 'ecm';
59}
60
61$upload_dir = $conf->ecm->dir_output.'/'.$section;
62
63$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
64$sortfield = GETPOST('sortfield', 'aZ09comma');
65$sortorder = GETPOST('sortorder', 'aZ09comma');
66$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
67if (empty($page) || $page == -1) {
68 $page = 0;
69} // If $page is not defined, or '' or -1
70$offset = $limit * $page;
71$pageprev = $page - 1;
72$pagenext = $page + 1;
73if (!$sortorder) {
74 $sortorder = "ASC";
75}
76if (!$sortfield) {
77 $sortfield = "label";
78}
79
80$ecmdir = new EcmDirectory($db);
81if (!empty($section)) {
82 $result = $ecmdir->fetch($section);
83 if (!($result > 0)) {
84 dol_print_error($db, $ecmdir->error);
85 exit;
86 }
87}
88
89$permissiontoread = $user->hasRight('ecm', 'read');
90
91if (!$permissiontoread) {
93}
94
95
96/*
97 * Actions
98 */
99
100// None
101
102
103
104/*
105 * View
106 */
107
108llxHeader('', '', '', '', 0, 0, '', '', '', 'mod-ecm page-search');
109
110$form = new Form($db);
111$ecmdirstatic = new EcmDirectory($db);
112$userstatic = new User($db);
113
114
115// Ajout rubriques automatiques
116$rowspan = 0;
117$sectionauto = array();
118if (isModEnabled("product") || isModEnabled("service")) {
119 $langs->load("products");
120 $rowspan++;
121 $sectionauto[] = array('level' => 1, 'module' => 'product', 'test' => (isModEnabled("product") || isModEnabled("service")), 'label' => $langs->trans("ProductsAndServices"), 'desc' => $langs->trans("ECMDocsByProducts"));
122}
123if (isModEnabled("societe")) {
124 $rowspan++;
125 $sectionauto[] = array('level' => 1, 'module' => 'company', 'test' => isModEnabled('societe'), 'label' => $langs->trans("ThirdParties"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
126}
127if (isModEnabled("propal")) {
128 $rowspan++;
129 $sectionauto[] = array('level' => 1, 'module' => 'propal', 'test' => isModEnabled('propal'), 'label' => $langs->trans("Proposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
130}
131if (isModEnabled('contract')) {
132 $rowspan++;
133 $sectionauto[] = array('level' => 1, 'module' => 'contract', 'test' => isModEnabled('contract'), 'label' => $langs->trans("Contracts"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
134}
135if (isModEnabled('order')) {
136 $rowspan++;
137 $sectionauto[] = array('level' => 1, 'module' => 'order', 'test' => isModEnabled('order'), 'label' => $langs->trans("CustomersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
138}
139if (isModEnabled('invoice')) {
140 $rowspan++;
141 $sectionauto[] = array('level' => 1, 'module' => 'invoice', 'test' => isModEnabled('invoice'), 'label' => $langs->trans("CustomersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
142}
143if (isModEnabled('supplier_proposal')) {
144 $langs->load("supplier_proposal");
145 $rowspan++;
146 $sectionauto[] = array('level' => 1, 'module' => 'supplier_proposal', 'test' => isModEnabled('supplier_proposal'), 'label' => $langs->trans("SupplierProposals"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
147}
148if (isModEnabled("supplier_order")) {
149 $rowspan++;
150 $sectionauto[] = array('level' => 1, 'module' => 'order_supplier', 'test' => isModEnabled("supplier_order"), 'label' => $langs->trans("SuppliersOrders"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
151}
152if (isModEnabled("supplier_invoice")) {
153 $rowspan++;
154 $sectionauto[] = array('level' => 1, 'module' => 'invoice_supplier', 'test' => isModEnabled("supplier_invoice"), 'label' => $langs->trans("SuppliersInvoices"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
155}
156if (isModEnabled('tax')) {
157 $langs->load("compta");
158 $rowspan++;
159 $sectionauto[] = array('level' => 1, 'module' => 'tax', 'test' => isModEnabled('tax'), 'label' => $langs->trans("SocialContributions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
160}
161if (isModEnabled('project')) {
162 $rowspan++;
163 $sectionauto[] = array('level' => 1, 'module' => 'project', 'test' => isModEnabled('project'), 'label' => $langs->trans("Projects"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
164}
165if (isModEnabled('intervention')) {
166 $langs->load("interventions");
167 $rowspan++;
168 $sectionauto[] = array('level' => 1, 'module' => 'fichinter', 'test' => isModEnabled('intervention'), 'label' => $langs->trans("Interventions"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
169}
170if (isModEnabled('expensereport')) {
171 $langs->load("trips");
172 $rowspan++;
173 $sectionauto[] = array('level' => 1, 'module' => 'expensereport', 'test' => isModEnabled('expensereport'), 'label' => $langs->trans("ExpenseReports"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
174}
175if (isModEnabled('holiday')) {
176 $langs->load("holiday");
177 $rowspan++;
178 $sectionauto[] = array('level' => 1, 'module' => 'holiday', 'test' => isModEnabled('holiday'), 'label' => $langs->trans("Holidays"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
179}
180if (isModEnabled("bank")) {
181 $langs->load("banks");
182 $rowspan++;
183 $sectionauto[] = array('level' => 1, 'module' => 'banque', 'test' => isModEnabled('bank'), 'label' => $langs->trans("BankAccount"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
184}
185if (isModEnabled('mrp')) {
186 $langs->load("mrp");
187 $rowspan++;
188 $sectionauto[] = array('level' => 1, 'module' => 'mrp-mo', 'test' => isModEnabled('mrp'), 'label' => $langs->trans("MOs"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
189}
190if (isModEnabled('recruitment')) {
191 $langs->load("recruitment");
192 $rowspan++;
193 $sectionauto[] = array('level' => 1, 'module' => 'recruitment-recruitmentcandidature', 'test' => isModEnabled('recruitment'), 'label' => $langs->trans("Candidatures"), 'desc' => $langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
194}
195
196
197//***********************
198// List
199//***********************
200print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
201
202print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
203
204// Tool bar
205$head = ecm_prepare_head_fm($ecmdir);
206//print dol_get_fiche_head($head, 'search_form', '', 1);
207
208
209print '<table class="border centpercent"><tr><td width="40%" valign="top">';
210
211// Left area
212
213
214//print load_fiche_titre($langs->trans("ECMSectionsManual"));
215
216print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
217print '<input type="hidden" name="token" value="'.newToken().'">';
218print '<table class="nobordernopadding" width="100%">';
219print "<tr class=\"liste_titre\">";
220print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
221print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
222print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
223print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
224print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
225print "</table></form>";
226//print $langs->trans("ECMSectionManualDesc");
227
228//print load_fiche_titre($langs->trans("ECMSectionAuto"));
229
230print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
231print '<input type="hidden" name="token" value="'.newToken().'">';
232print '<table class="nobordernopadding" width="100%">';
233print "<tr class=\"liste_titre\">";
234print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
235
236$buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
237$butshown = 0;
238foreach ($sectionauto as $sectioncur) {
239 if (!$sectioncur['test']) {
240 continue;
241 }
242 print '<tr class="impair">';
243 print "<td>".$sectioncur['label'].':</td>';
244 print '<td';
245 print ' class="right"';
246 print '>';
247 print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
248 print '</td>';
249 print '</tr>';
250 $butshown++;
251}
252
253print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
254print "</table></form>";
255//print $langs->trans("ECMSectionAutoDesc");
256
257
258
259print '</td><td class="tdtop">';
260
261// Right area
262$relativepath = $ecmdir->getRelativePath();
263$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
264$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1);
265
266$formfile = new FormFile($db);
267$param = '&section='.urlencode($section);
268$textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
269$formfile->list_of_documents($filearray, null, 'ecm', $param, 1, $relativepath, $user->hasRight('ecm', 'upload'), 1, $textifempty);
270
271
272print '</td></tr>';
273
274print '</table>';
275
276
277print '<br>';
278
279// End of page
280llxFooter();
281$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:70
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...
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.