dolibarr  7.0.0-beta
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@capnetworks.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 <http://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 traductions files
33 $langs->loadLangs(array("ecm","companies","other","users","orders","propal","bills","contracts"));
34 
35 // Security check
36 if ($user->societe_id) $socid=$user->societe_id;
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','alpha');
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 $sortfield = GETPOST("sortfield",'alpha');
56 $sortorder = GETPOST("sortorder",'alpha');
57 $page = GETPOST("page",'int');
58 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
59 $offset = $conf->liste_limit * $page;
60 $pageprev = $page - 1;
61 $pagenext = $page + 1;
62 if (! $sortorder) $sortorder="ASC";
63 if (! $sortfield) $sortfield="label";
64 
65 $ecmdir = new EcmDirectory($db);
66 if (! empty($section))
67 {
68  $result=$ecmdir->fetch($section);
69  if (! $result > 0)
70  {
71  dol_print_error($db,$ecmdir->error);
72  exit;
73  }
74 }
75 
76 
77 /*******************************************************************
78  * ACTIONS
79  *
80  * Put here all code to do according to value of "action" parameter
81  ********************************************************************/
82 
83 
84 
85 
86 
87 /*******************************************************************
88  * PAGE
89  *
90  * Put here all code to do according to value of "action" parameter
91  ********************************************************************/
92 
93 llxHeader();
94 
95 $form=new Form($db);
96 $ecmdirstatic = new EcmDirectory($db);
97 $userstatic = new User($db);
98 
99 
100 // Ajout rubriques automatiques
101 $rowspan=0;
102 $sectionauto=array();
103 if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'product', 'test'=>$conf->product->enabled, 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); }
104 if (! empty($conf->societe->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'company', 'test'=>$conf->societe->enabled, 'label'=>$langs->trans("ThirdParties"), 'desc'=>$langs->trans("ECMDocsByThirdParties")); }
105 if (! empty($conf->propal->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'propal', 'test'=>$conf->propal->enabled, 'label'=>$langs->trans("Proposals"), 'desc'=>$langs->trans("ECMDocsByProposals")); }
106 if (! empty($conf->contrat->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'contract','test'=>$conf->contrat->enabled, 'label'=>$langs->trans("Contracts"), 'desc'=>$langs->trans("ECMDocsByContracts")); }
107 if (! empty($conf->commande->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order', 'test'=>$conf->commande->enabled,'label'=>$langs->trans("CustomersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
108 if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'order_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersInvoices"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
109 if (! empty($conf->facture->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice', 'test'=>$conf->facture->enabled, 'label'=>$langs->trans("CustomersInvoices"), 'desc'=>$langs->trans("ECMDocsByInvoices")); }
110 if (! empty($conf->fournisseur->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'invoice_supplier', 'test'=>$conf->fournisseur->enabled, 'label'=>$langs->trans("SuppliersOrders"), 'desc'=>$langs->trans("ECMDocsByOrders")); }
111 
112 
113 //***********************
114 // List
115 //***********************
116 print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search"));
117 
118 //print $langs->trans("ECMAreaDesc")."<br>";
119 //print $langs->trans("ECMAreaDesc2")."<br>";
120 //print "<br>\n";
121 print $langs->trans("FeatureNotYetAvailable").'.<br><br>';
122 
123 // Tool bar
124 $head = ecm_prepare_head_fm($ecmdir, $module, $section);
125 //dol_fiche_head($head, 'search_form', '', 1);
126 
127 
128 print '<table class="border" width="100%"><tr><td width="40%" valign="top">';
129 
130 // Left area
131 
132 
133 //print load_fiche_titre($langs->trans("ECMSectionsManual"));
134 
135 print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
136 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
137 print '<table class="nobordernopadding" width="100%">';
138 print "<tr class=\"liste_titre\">";
139 print '<td colspan="2">'.$langs->trans("ECMSearchByKeywords").'</td></tr>';
140 print "<tr ".$bc[false]."><td>".$langs->trans("Ref").':</td><td align="right"><input type="text" name="search_ref" class="flat" size="10"></td></tr>';
141 print "<tr ".$bc[false]."><td>".$langs->trans("Title").':</td><td align="right"><input type="text" name="search_title" class="flat" size="10"></td></tr>';
142 print "<tr ".$bc[false]."><td>".$langs->trans("Keyword").':</td><td align="right"><input type="text" name="search_keyword" class="flat" size="10"></td></tr>';
143 print "<tr ".$bc[false].'><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
144 print "</table></form>";
145 //print $langs->trans("ECMSectionManualDesc");
146 
147 //print load_fiche_titre($langs->trans("ECMSectionAuto"));
148 
149 print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
150 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
151 print '<table class="nobordernopadding" width="100%">';
152 print "<tr class=\"liste_titre\">";
153 print '<td colspan="4">'.$langs->trans("ECMSearchByEntity").'</td></tr>';
154 
155 $buthtml='<td rowspan="'.$rowspan.'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
156 $butshown=0;
157 foreach($sectionauto as $sectioncur)
158 {
159  if (! $sectioncur['test']) continue;
160  //if ($butshown % 2 == 0)
161  print '<tr '. $bc[false].'>';
162  print "<td>".$sectioncur['label'].':</td>';
163  print '<td';
164  //if ($butshown % 2 == 1)
165  print ' align="right"';
166  print '>';
167  print '<input type="text" name="search_'.$sectioncur['module'].'" class="flat" size="14">';
168  print '</td>';
169  //if ($butshown % 2 == 1)
170  print '</tr>';
171  $butshown++;
172 }
173 //if ($butshown % 2 == 1)
174 // print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
175 
176 print '<tr '. $bc[false].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
177 print "</table></form>";
178 //print $langs->trans("ECMSectionAutoDesc");
179 
180 
181 
182 print '</td><td class="tdtop">';
183 
184 // Right area
185 $relativepath=$ecmdir->getRelativePath();
186 $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
187 $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
188 
189 $formfile=new FormFile($db);
190 $param='&amp;section='.$section;
191 $textifempty=($section?$langs->trans("NoFileFound"):$langs->trans("ECMSelectASection"));
192 $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty);
193 
194 // print '<table width="100%" class="border">';
195 
196 // print '<tr><td> </td></tr></table>';
197 
198 
199 
200 print '</td></tr>';
201 
202 print '</table>';
203 
204 
205 print '<br>';
206 
207 // End of page
208 llxFooter();
209 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
Class to manage Dolibarr users.
Definition: user.class.php:39
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
Class to offer components to list and upload files.
print
Draft customers invoices.
Definition: index.php:91
ecm_prepare_head_fm($object)
Prepare array with list of tabs.
Definition: ecm.lib.php:125
Class to manage ECM directories.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.