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