dolibarr  13.0.2
search_page.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This file is a modified version of datepicker.php from phpBSM to fix some
5  * bugs, to add new features and to dramatically increase speed.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
26 //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
27 //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
28 //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
29 //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
30 if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1);
31 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1);
32 //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
33 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1);
34 //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
35 
36 require_once '../main.inc.php';
37 
38 if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
39 
40 $langs->load("main");
41 
42 $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
43 $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
44 
45 
46 /*
47  * View
48  */
49 
50 $title = $langs->trans("Search");
51 
52 // URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
53 $head = '<!-- Quick access -->'."\n";
54 $arrayofjs = array();
55 $arrayofcss = array();
56 top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
57 
58 
59 
60 print '<body>'."\n";
61 print '<div>';
62 //print '<br>';
63 
64 $nbofsearch = 0;
65 
66 // Instantiate hooks of thirdparty module
67 $hookmanager->initHooks(array('searchform'));
68 
69 // Define $searchform
70 $searchform = '';
71 
72 if ($conf->use_javascript_ajax && 1 == 2) // select2 is ko with jmobile
73 {
74  if (!is_object($form)) $form = new Form($db);
75  $selected = -1;
76  $searchform .= '<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
77 } else {
78  $usedbyinclude = 1; // Used into next include
79  $showtitlebefore = GETPOST('showtitlebefore', 'int');
80  $arrayresult = array();
81  include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
82 
83  $i = 0;
84  $accesskeyalreadyassigned = array();
85  foreach ($arrayresult as $key => $val)
86  {
87  $tmp = explode('?', $val['url']);
88  $urlaction = $tmp[0];
89  $keysearch = 'search_all';
90 
91  $accesskey = '';
92  if (!$accesskeyalreadyassigned[$val['label'][0]])
93  {
94  $accesskey = $val['label'][0];
95  $accesskeyalreadyassigned[$accesskey] = $accesskey;
96  }
97 
98  $searchform .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, $val['img'], $showtitlebefore, ($i > 0 ? 0 : 1));
99 
100  $i++;
101  }
102 }
103 
104 // Execute hook printSearchForm
105 $parameters = array('searchform'=>$searchform);
106 $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
107 if (empty($reshook))
108 {
109  $searchform .= $hookmanager->resPrint;
110 } else $searchform = $hookmanager->resPrint;
111 
112 
113 print "\n";
114 print "<!-- Begin SearchForm -->\n";
115 print '<div class="center"><div class="center" style="padding: 6px;">';
116 print '<style>.menu_titre { padding-top: 7px; }</style>';
117 print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
118 print $searchform;
119 print '</div>'."\n";
120 print '</div></div>';
121 print "\n<!-- End SearchForm -->\n";
122 
123 print '</div>';
124 print '</body></html>'."\n";
125 
126 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
top_htmlhead($head, $title= '', $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
Definition: main.inc.php:1280
Class to manage generation of HTML components Only common components must be here.
print
Draft customers invoices.
Definition: index.php:89
printSearchForm($urlaction, $urlobject, $title, $htmlmorecss, $htmlinputname, $accesskey= '', $prefhtmlinputname= '', $img= '', $showtitlebefore=0, $autofocus=0)
Show a search area.
Definition: main.inc.php:2749