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