dolibarr  13.0.2
company.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
3  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
4  * Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
25 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
26 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
27 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
28 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
29 if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
30 if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
31 
32 require '../../main.inc.php';
33 
34 $htmlname = GETPOST('htmlname', 'alpha');
35 $filter = GETPOST('filter', 'alpha');
36 $outjson = (GETPOST('outjson', 'int') ? GETPOST('outjson', 'int') : 0);
37 $action = GETPOST('action', 'aZ09');
38 $id = GETPOST('id', 'int');
39 $showtype = GETPOST('showtype', 'int');
40 
41 
42 /*
43  * View
44  */
45 
46 //print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
47 
48 dol_syslog(join(',', $_GET));
49 //print_r($_GET);
50 
51 if (!empty($action) && $action == 'fetch' && !empty($id))
52 {
53  require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
54 
55  $outjson = array();
56 
57  $object = new Societe($db);
58  $ret = $object->fetch($id);
59  if ($ret > 0)
60  {
61  $outref = $object->ref;
62  $outname = $object->name;
63  $outdesc = '';
64  $outtype = $object->type;
65 
66  $outjson = array('ref' => $outref, 'name' => $outname, 'desc' => $outdesc, 'type' => $outtype);
67  }
68 
69  echo json_encode($outjson);
70 } else {
71  require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
72 
73  $langs->load("companies");
74 
75  top_httphead();
76 
77  if (empty($htmlname)) return;
78 
79  $match = preg_grep('/('.$htmlname.'[0-9]+)/', array_keys($_GET));
80  sort($match);
81  $id = (!empty($match[0]) ? $match[0] : '');
82 
83  // When used from jQuery, the search term is added as GET param "term".
84  $searchkey = (($id && GETPOST($id, 'alpha')) ?GETPOST($id, 'alpha') : (($htmlname && GETPOST($htmlname, 'alpha')) ?GETPOST($htmlname, 'alpha') : ''));
85 
86  if (!$searchkey) return;
87 
88  if (!is_object($form)) $form = new Form($db);
89  $arrayresult = $form->select_thirdparty_list(0, $htmlname, $filter, 1, $showtype, 0, null, $searchkey, $outjson);
90 
91  $db->close();
92 
93  if ($outjson) print json_encode($arrayresult);
94 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype= 'text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1214
Class to manage generation of HTML components Only common components must be here.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
print
Draft customers invoices.
Definition: index.php:89