dolibarr  17.0.4
selectobject.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
23 if (!defined('NOTOKENRENEWAL')) {
24  define('NOTOKENRENEWAL', 1); // Disables token renewal
25 }
26 if (!defined('NOREQUIREMENU')) {
27  define('NOREQUIREMENU', '1');
28 }
29 if (!defined('NOREQUIREHTML')) {
30  define('NOREQUIREHTML', '1');
31 }
32 if (!defined('NOREQUIREAJAX')) {
33  define('NOREQUIREAJAX', '1');
34 }
35 if (!defined('NOREQUIRESOC')) {
36  define('NOREQUIRESOC', '1');
37 }
38 
39 // Load Dolibarr environment
40 require '../../main.inc.php';
41 
42 $objectdesc = GETPOST('objectdesc', 'alpha');
43 $htmlname = GETPOST('htmlname', 'aZ09');
44 $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
45 $id = GETPOST('id', 'int');
46 $filter = GETPOST('filter', 'alphanohtml');
47 
48 
49 /*
50  * View
51  */
52 
53 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
54 //print_r($_GET);
55 
56 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
57 $form = new Form($db);
58 
59 //$langs->load("companies");
60 
61 top_httphead();
62 
63 if (empty($htmlname)) {
64  return;
65 }
66 
67 
68 $InfoFieldList = explode(":", $objectdesc);
69 $classname = $InfoFieldList[0];
70 $classpath = $InfoFieldList[1];
71 if (!empty($classpath)) {
72  dol_include_once($classpath);
73  if ($classname && class_exists($classname)) {
74  $objecttmp = new $classname($db);
75  }
76 }
77 if (!is_object($objecttmp)) {
78  dol_syslog('Error bad param objectdesc', LOG_WARNING);
79  print 'Error bad param objectdesc';
80 }
81 
82 // When used from jQuery, the search term is added as GET param "term".
83 $searchkey = (($id && GETPOST($id, 'alpha')) ? GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ? GETPOST($htmlname, 'alpha') : ''));
84 
85 // Add a security test to avoid to get content of all tables
86 restrictedArea($user, $objecttmp->element, $id);
87 
88 $arrayresult = $form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1, 0, '', $filter);
89 
90 $db->close();
91 
92 if ($outjson) {
93  print json_encode($arrayresult);
94 }
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1440
restrictedArea(User $user, $features, $object=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.