dolibarr 18.0.6
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"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts"));
119}
120if (isModEnabled("societe")) {
121 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>isModEnabled('societe'), 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties")));
122}
123if (isModEnabled("propal")) {
124 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>isModEnabled('propal'), 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals")));
125}
126if (isModEnabled('contrat')) {
127 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>isModEnabled('contrat'), 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts")));
128}
129if (isModEnabled('commande')) {
130 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>isModEnabled('commande'), 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders")));
131}
132if (isModEnabled('facture')) {
133 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>isModEnabled('facture'), 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices")));
134}
135if (isModEnabled('supplier_proposal')) {
136 $langs->load("supplier_proposal"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'supplier_proposal', 'test'=>isModEnabled('supplier_proposal'), 'label'=>$langs->trans("SupplierProposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierProposals")));
137}
138if (isModEnabled("supplier_order")) {
139 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>isModEnabled("supplier_order"), 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders")));
140}
141if (isModEnabled("supplier_invoice")) {
142 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>isModEnabled("supplier_invoice"), 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices")));
143}
144if (isModEnabled('tax')) {
145 $langs->load("compta"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'tax', 'test'=>isModEnabled('tax'), 'label'=>$langs->trans("SocialContributions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SocialContributions")));
146}
147if (isModEnabled('project')) {
148 $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>isModEnabled('project'), 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects")));
149}
150if (isModEnabled('ficheinter')) {
151 $langs->load("interventions"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'fichinter', 'test'=>isModEnabled('ficheinter'), 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Interventions")));
152}
153if (isModEnabled('expensereport')) {
154 $langs->load("trips"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'expensereport', 'test'=>isModEnabled('expensereport'), 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ExpenseReports")));
155}
156if (isModEnabled('holiday')) {
157 $langs->load("holiday"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'holiday', 'test'=>isModEnabled('holiday'), 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Holidays")));
158}
159if (isModEnabled("banque")) {
160 $langs->load("banks"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'banque', 'test'=>isModEnabled('banque'), 'label'=>$langs->trans("BankAccount"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("BankAccount")));
161}
162if (isModEnabled('mrp')) {
163 $langs->load("mrp"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'mrp-mo', 'test'=>isModEnabled('mrp'), 'label'=>$langs->trans("MOs"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ManufacturingOrders")));
164}
165if (isModEnabled('recruitment')) {
166 $langs->load("recruitment"); $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'recruitment-recruitmentcandidature', 'test'=>isModEnabled('recruitment'), 'label'=>$langs->trans("Candidatures"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("JobApplications")));
167}
168
169
170//***********************
171// List
172//***********************
173print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
174
175print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
176
177// Tool bar
178$head = ecm_prepare_head_fm($ecmdir);
179//print dol_get_fiche_head($head, 'search_form', '', 1);
180
181
182print '<table class="border centpercent"><tr><td width="40%" valign="top">';
183
184// Left area
185
186
187//print load_fiche_titre($langs->trans("ECMSectionsManual"));
188
189print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
190print '<input type="hidden" name="token" value="'.newToken().'">';
191print '<table class="nobordernopadding" width="100%">';
192print "<tr class=\"liste_titre\">";
193print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
194print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
195print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
196print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
197print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
198print "</table></form>";
199//print $langs->trans("ECMSectionManualDesc");
200
201//print load_fiche_titre($langs->trans("ECMSectionAuto"));
202
203print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
204print '<input type="hidden" name="token" value="'.newToken().'">';
205print '<table class="nobordernopadding" width="100%">';
206print "<tr class=\"liste_titre\">";
207print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
208
209$buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
210$butshown = 0;
211foreach ($sectionauto as $sectioncur) {
212 if (!$sectioncur['test']) {
213 continue;
214 }
215 print '<tr class="impair">';
216 print "<td>".$sectioncur['label'].':</td>';
217 print '<td';
218 print ' class="right"';
219 print '>';
220 print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
221 print '</td>';
222 print '</tr>';
223 $butshown++;
224}
225
226print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
227print "</table></form>";
228//print $langs->trans("ECMSectionAutoDesc");
229
230
231
232print '</td><td class="tdtop">';
233
234// Right area
235$relativepath = $ecmdir->getRelativePath();
236$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
237$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
238
239$formfile = new FormFile($db);
240$param = '&section='.urlencode($section);
241$textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
242$formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty);
243
244
245print '</td></tr>';
246
247print '</table>';
248
249
250print '<br>';
251
252// End of page
253llxFooter();
254$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:56
llxFooter()
Empty footer.
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.
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.