dolibarr/htdocs/core/search_page.php

147 lines
4.9 KiB
PHP
Raw Normal View History

2013-02-24 18:22:28 +01:00
<?php
/* Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
2013-02-24 18:22:28 +01:00
*
* This file is a modified version of datepicker.php from phpBSM to fix some
* bugs, to add new features and to dramatically increase speed.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2013-02-24 18:22:28 +01:00
*/
/**
* \file htdocs/core/search_page.php
2021-08-04 12:38:28 +02:00
* \brief File to return a page with the complete search form (all search input fields)
2013-02-24 18:22:28 +01:00
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations
2021-02-23 22:03:23 +01:00
if (!defined('NOCSRFCHECK')) {
define('NOCSRFCHECK', 1);
}
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
2013-02-24 18:22:28 +01:00
//if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language
2021-02-23 22:03:23 +01:00
if (!defined('NOREQUIREMENU')) {
define('NOREQUIREMENU', 1);
}
2013-02-24 18:22:28 +01:00
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
require_once '../main.inc.php';
2021-02-23 22:03:23 +01:00
if (GETPOST('lang', 'aZ09')) {
$langs->setDefaultLang(GETPOST('lang', 'aZ09')); // If language was forced on URL by the main.inc.php
}
2013-02-24 18:22:28 +01:00
$langs->load("main");
$right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
$left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
2013-02-24 18:22:28 +01:00
/*
* View
*/
2021-12-13 09:35:27 +01:00
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
if (empty($dolibarr_nocache) && GETPOST('cache', 'int')) {
header('Cache-Control: max-age='.GETPOST('cache', 'int').', public');
// For a .php, we must set an Expires to avoid to have it forced to an expired value by the web server
header('Expires: '.gmdate('D, d M Y H:i:s', dol_now('gmt') + GETPOST('cache', 'int')).' GMT');
// HTTP/1.0
header('Pragma: token=public');
} else {
// HTTP/1.0
header('Cache-Control: no-cache');
}
$title = $langs->trans("Search");
// URL http://mydolibarr/core/search_page?dol_use_jmobile=1 can be used for tests
2021-12-10 13:56:51 +01:00
$head = '<!-- Quick access -->'."\n"; // This is used by DoliDroid to know page is a search page
$arrayofjs = array();
$arrayofcss = array();
top_htmlhead($head, $title, 0, 0, $arrayofjs, $arrayofcss);
2013-02-24 18:22:28 +01:00
print '<body>'."\n";
print '<div>';
//print '<br>';
$nbofsearch = 0;
2013-02-24 18:22:28 +01:00
// Instantiate hooks of thirdparty module
$hookmanager->initHooks(array('searchform'));
// Define $searchform
2014-04-23 18:07:31 +02:00
$searchform = '';
2021-08-04 12:38:28 +02:00
if ($conf->use_javascript_ajax && 1 == 2) { // select2 is not best with smartphone
2021-02-23 22:03:23 +01:00
if (!is_object($form)) {
$form = new Form($db);
}
$selected = -1;
$searchform .= '<br><br>'.$form->selectArrayAjax('searchselectcombo', DOL_URL_ROOT.'/core/ajax/selectsearchbox.php', $selected, '', '', 0, 1, 'minwidth300', 1, $langs->trans("Search"), 0);
2020-05-21 15:05:19 +02:00
} else {
$usedbyinclude = 1; // Used into next include
$showtitlebefore = GETPOST('showtitlebefore', 'int');
$arrayresult = array();
include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php';
2017-06-10 21:37:27 +02:00
$i = 0;
$accesskeyalreadyassigned = array();
2021-02-23 22:03:23 +01:00
foreach ($arrayresult as $key => $val) {
$tmp = explode('?', $val['url']);
$urlaction = $tmp[0];
$keysearch = 'search_all';
$accesskey = '';
2021-02-23 22:03:23 +01:00
if (!$accesskeyalreadyassigned[$val['label'][0]]) {
$accesskey = $val['label'][0];
$accesskeyalreadyassigned[$accesskey] = $accesskey;
}
$searchform .= printSearchForm($urlaction, $urlaction, $val['label'], 'minwidth200', $keysearch, $accesskey, $key, $val['img'], $showtitlebefore, ($i > 0 ? 0 : 1));
$i++;
}
}
// Execute hook printSearchForm
$parameters = array('searchform'=>$searchform);
$reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks
2021-02-23 22:03:23 +01:00
if (empty($reshook)) {
$searchform .= $hookmanager->resPrint;
2021-02-23 22:03:23 +01:00
} else {
$searchform = $hookmanager->resPrint;
}
print "\n";
print "<!-- Begin SearchForm -->\n";
2019-12-12 10:31:08 +01:00
print '<div class="center"><div class="center" style="padding: 6px;">';
2013-06-19 15:52:06 +02:00
print '<style>.menu_titre { padding-top: 7px; }</style>';
2020-01-06 15:14:14 +01:00
print '<div id="blockvmenusearch" class="tagtable center searchpage">'."\n";
print $searchform;
print '</div>'."\n";
2013-06-19 15:52:06 +02:00
print '</div></div>';
print "\n<!-- End SearchForm -->\n";
2013-02-24 18:22:28 +01:00
print '</div>';
2013-02-24 18:22:28 +01:00
print '</body></html>'."\n";
$db->close();