dolibarr  19.0.0-dev
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
26 require '../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
31 require_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
37 if ($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');
49 if (!$section) {
50  $section = 0;
51 }
52 
53 $module = GETPOST('module', 'alpha');
54 $website = GETPOST('website', 'alpha');
55 $pageid = GETPOST('pageid', 'int');
56 if (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');
66 if (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;
72 if (!$sortorder) {
73  $sortorder = "ASC";
74 }
75 if (!$sortfield) {
76  $sortfield = "label";
77 }
78 
79 $ecmdir = new EcmDirectory($db);
80 if (!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 
90 if (!$permissiontoread) {
92 }
93 
94 
95 /*
96  * Actions
97  */
98 
99 // None
100 
101 
102 
103 /*
104  * View
105  */
106 
107 llxHeader();
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();
117 if (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 }
120 if (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 }
123 if (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 }
126 if (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 }
129 if (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 }
132 if (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 }
135 if (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 }
138 if (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 }
141 if (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 }
144 if (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 }
147 if (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 }
150 if (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 }
153 if (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 }
156 if (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 }
159 if (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 }
162 if (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 }
165 if (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 //***********************
173 print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
174 
175 print $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 
182 print '<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 
189 print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
190 print '<input type="hidden" name="token" value="'.newToken().'">';
191 print '<table class="nobordernopadding" width="100%">';
192 print "<tr class=\"liste_titre\">";
193 print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
194 print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
195 print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
196 print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
197 print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
198 print "</table></form>";
199 //print $langs->trans("ECMSectionManualDesc");
200 
201 //print load_fiche_titre($langs->trans("ECMSectionAuto"));
202 
203 print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
204 print '<input type="hidden" name="token" value="'.newToken().'">';
205 print '<table class="nobordernopadding" width="100%">';
206 print "<tr class=\"liste_titre\">";
207 print '<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;
211 foreach ($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 
226 print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
227 print "</table></form>";
228 //print $langs->trans("ECMSectionAutoDesc");
229 
230 
231 
232 print '</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 
245 print '</td></tr>';
246 
247 print '</table>';
248 
249 
250 print '<br>';
251 
252 // End of page
253 llxFooter();
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.
Definition: user.class.php:48
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.