dolibarr  13.0.2
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) $socid = $user->socid;
37 $result = restrictedArea($user, 'ecm', '');
38 
39 // Load permissions
40 $user->getrights('ecm');
41 
42 // Get parameters
43 $socid = GETPOST('socid', 'int');
44 $action = GETPOST('action', 'aZ09');
45 $section = GETPOST('section');
46 if (!$section) $section = 0;
47 
48 $module = GETPOST('module', 'alpha');
49 $website = GETPOST('website', 'alpha');
50 $pageid = GETPOST('pageid', 'int');
51 if (empty($module)) $module = 'ecm';
52 
53 $upload_dir = $conf->ecm->dir_output.'/'.$section;
54 
55 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
56 $sortfield = GETPOST("sortfield", 'alpha');
57 $sortorder = GETPOST("sortorder", 'alpha');
58 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
59 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
60 $offset = $limit * $page;
61 $pageprev = $page - 1;
62 $pagenext = $page + 1;
63 if (!$sortorder) $sortorder = "ASC";
64 if (!$sortfield) $sortfield = "label";
65 
66 $ecmdir = new EcmDirectory($db);
67 if (!empty($section))
68 {
69  $result = $ecmdir->fetch($section);
70  if (!$result > 0)
71  {
72  dol_print_error($db, $ecmdir->error);
73  exit;
74  }
75 }
76 
77 
78 /*
79  * Actions
80  */
81 
82 // None
83 
84 
85 
86 /*
87  * View
88  */
89 
90 llxHeader();
91 
92 $form = new Form($db);
93 $ecmdirstatic = new EcmDirectory($db);
94 $userstatic = new User($db);
95 
96 
97 // Ajout rubriques automatiques
98 $rowspan = 0;
99 $sectionauto = array();
100 if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $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")); }
101 if (!empty($conf->societe->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("ThirdParties"))); }
102 if (!empty($conf->propal->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Proposals"))); }
103 if (!empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'contract', 'test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Contracts"))); }
104 if (!empty($conf->commande->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled, 'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Orders"))); }
105 if (!empty($conf->facture->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Invoices"))); }
106 if (!empty($conf->supplier_proposal->enabled)) { $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"))); }
107 if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("PurchaseOrders"))); }
108 if (!empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("SupplierInvoices"))); }
109 if (!empty($conf->tax->enabled)) { $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"))); }
110 if (!empty($conf->projet->enabled)) { $rowspan++; $sectionauto[] = array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsBy", $langs->transnoentitiesnoconv("Projects"))); }
111 if (!empty($conf->ficheinter->enabled)) { $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"))); }
112 if (!empty($conf->expensereport->enabled)) { $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"))); }
113 if (!empty($conf->holiday->enabled)) { $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"))); }
114 if (!empty($conf->banque->enabled)) { $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"))); }
115 if (!empty($conf->mrp->enabled)) { $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"))); }
116 if (!empty($conf->recruitment->enabled)) { $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"))); }
117 
118 
119 //***********************
120 // List
121 //***********************
122 print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
123 
124 //print $langs->trans("ECMAreaDesc")."<br>";
125 //print $langs->trans("ECMAreaDesc2")."<br>";
126 //print "<br>\n";
127 print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
128 
129 // Tool bar
130 $head = ecm_prepare_head_fm($ecmdir, $module, $section);
131 //print dol_get_fiche_head($head, 'search_form', '', 1);
132 
133 
134 print '<table class="border centpercent"><tr><td width="40%" valign="top">';
135 
136 // Left area
137 
138 
139 //print load_fiche_titre($langs->trans("ECMSectionsManual"));
140 
141 print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
142 print '<input type="hidden" name="token" value="'.newToken().'">';
143 print '<table class="nobordernopadding" width="100%">';
144 print "<tr class=\"liste_titre\">";
145 print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
146 print '<tr class="impair"><td>'.$langs->trans("Ref").':</td><td class="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
147 print '<tr class="impair"><td>'.$langs->trans("Title").':</td><td class="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
148 print '<tr class="impair"><td>'.$langs->trans("Keyword").':</td><td class="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
149 print '<tr class="impair"><td colspan="2" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
150 print "</table></form>";
151 //print $langs->trans("ECMSectionManualDesc");
152 
153 //print load_fiche_titre($langs->trans("ECMSectionAuto"));
154 
155 print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
156 print '<input type="hidden" name="token" value="'.newToken().'">';
157 print '<table class="nobordernopadding" width="100%">';
158 print "<tr class=\"liste_titre\">";
159 print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
160 
161 $buthtml = '<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
162 $butshown = 0;
163 foreach ($sectionauto as $sectioncur)
164 {
165  if (!$sectioncur['test']) continue;
166  print '<tr class="impair">';
167  print "<td>".$sectioncur['label'].':</td>';
168  print '<td';
169  print ' class="right"';
170  print '>';
171  print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
172  print '</td>';
173  print '</tr>';
174  $butshown++;
175 }
176 
177 print '<tr '.$bc[false].'><td colspan="4" class="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
178 print "</table></form>";
179 //print $langs->trans("ECMSectionAutoDesc");
180 
181 
182 
183 print '</td><td class="tdtop">';
184 
185 // Right area
186 $relativepath = $ecmdir->getRelativePath();
187 $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
188 $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
189 
190 $formfile = new FormFile($db);
191 $param = '&amp;section='.$section;
192 $textifempty = ($section ? $langs->trans("NoFileFound") : $langs->trans("ECMSelectASection"));
193 $formfile->list_of_documents($filearray, '', 'ecm', $param, 1, $relativepath, $user->rights->ecm->upload, 1, $textifempty);
194 
195 
196 print '</td></tr>';
197 
198 print '</table>';
199 
200 
201 print '<br>';
202 
203 // End of page
204 llxFooter();
205 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
Definition: user.class.php:44
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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
Class to offer components to list and upload files.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
ecm_prepare_head_fm($object)
Prepare array with list of tabs.
Definition: ecm.lib.php:123
llxFooter()
Empty footer.
Definition: wrapper.php:59
Class to manage ECM directories.