dolibarr  7.0.0-beta
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 <http://www.gnu.org/licenses/>.
16  */
17 
23 if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
24 if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
25 if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
26 if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
27 if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
28 if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
29 
30 require '../../main.inc.php';
31 
32 $objectdesc=GETPOST('objectdesc', 'alpha');
33 $htmlname=GETPOST('htmlname', 'aZ09');
34 $sqlfilter=GETPOST('sqlfilter', 'alpha');
35 $outjson=(GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
36 $action=GETPOST('action', 'alpha');
37 $id=GETPOST('id', 'int');
38 
39 
40 /*
41  * View
42  */
43 
44 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
45 
46 dol_syslog(join(',', $_GET));
47 //print_r($_GET);
48 
49 
50 require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
51 $form = new Form($db);
52 
53 //$langs->load("companies");
54 
55 top_httphead();
56 
57 if (empty($htmlname)) return;
58 
59 
60 $InfoFieldList = explode(":", $objectdesc);
61 $classname=$InfoFieldList[0];
62 $classpath=$InfoFieldList[1];
63 if (! empty($classpath))
64 {
65  dol_include_once($classpath);
66  if ($classname && class_exists($classname))
67  {
68  $objecttmp = new $classname($db);
69  }
70 }
71 if (! is_object($objecttmp))
72 {
73  dol_syslog('Error bad param objectdesc', LOG_WARNING);
74  print 'Error bad param objectdesc';
75 }
76 
77 // When used from jQuery, the search term is added as GET param "term".
78 $searchkey=(($id && GETPOST($id, 'alpha'))?GETPOST($id, 'alpha'):(($htmlname && GETPOST($htmlname, 'alpha'))?GETPOST($htmlname, 'alpha'):''));
79 
80 // TODO Add a security test to avoid to get content of all tables
81 
82 $arrayresult=$form->selectForFormsList($objecttmp, $htmlname, '', 0, $searchkey, '', '', '', 0, 1);
83 
84 $db->close();
85 
86 if ($outjson) print json_encode($arrayresult);
if(empty($reshook)) $form
View.
Definition: perms.php:103
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
print
Draft customers invoices.
Definition: index.php:91
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Return a prefix to use for this Dolibarr instance, for session/cookie names or email id...
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html')
Show HTTP header.
Definition: main.inc.php:1052