dolibarr  18.0.0-alpha
ajaxtooltip.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2018 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
26 if (!defined('NOTOKENRENEWAL')) {
27  define('NOTOKENRENEWAL', 1); // Disables token renewal
28 }
29 if (!defined('NOREQUIREMENU')) {
30  define('NOREQUIREMENU', '1');
31 }
32 if (!defined('NOREQUIREHTML')) {
33  define('NOREQUIREHTML', '1');
34 }
35 if (!defined('NOREQUIREAJAX')) {
36  define('NOREQUIREAJAX', '1');
37 }
38 include '../../main.inc.php';
39 include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
40 include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
41 
42 top_httphead();
43 
44 // opensurvey as aZ09 id
45 $id = GETPOST('id', 'aZ09');
46 $objecttype = GETPOST('objecttype', 'aZ09');
47 
48 $html = '';
49 $regs = array();
50 $params = array();
51 if (GETPOSTISSET('infologin')) {
52  $params['infologin'] = GETPOST('infologin', 'int');
53 }
54 if (GETPOSTISSET('option')) {
55  $params['option'] = GETPOST('option', 'restricthtml');
56 }
57 // If we ask a resource form external module (instead of default path)
58 if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) {
59  $myobject = $regs[1];
60  $module = $regs[2];
61 } else {
62  // Parse $objecttype (ex: project_task)
63  $module = $myobject = $objecttype;
64  if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
65  $module = $regs[1];
66  $myobject = $regs[2];
67  }
68 }
69 
70 // Generic case for $classpath
71 $classpath = $module.'/class';
72 
73 // Special cases, to work with non standard path
74 if ($objecttype == 'facture' || $objecttype == 'invoice') {
75  $langs->load('bills');
76  $classpath = 'compta/facture/class';
77  $module = 'facture';
78  $myobject = 'facture';
79 } elseif ($objecttype == 'bank_account') {
80  $langs->loadLangs(['banks', 'compta']);
81  $classpath = 'compta/bank/class';
82  $module = 'banque';
83  $myobject = 'account';
84 } elseif ($objecttype == 'category') {
85  $langs->loadLangs(['categories']);
86  $classpath = 'categories/class';
87  $module = 'categorie';
88  $myobject = 'categorie';
89 } elseif ($objecttype == 'commande' || $objecttype == 'order') {
90  $langs->load('orders');
91  $classpath = 'commande/class';
92  $module = 'commande';
93  $myobject = 'commande';
94 } elseif ($objecttype == 'propal') {
95  $langs->load('propal');
96  $classpath = 'comm/propal/class';
97 } elseif ($objecttype == 'action') {
98  $langs->load('agenda');
99  $classpath = 'comm/action/class';
100  $module = 'agenda';
101  $myobject = 'actioncomm';
102 } elseif ($objecttype == 'supplier_proposal') {
103  $langs->load('supplier_proposal');
104  $classpath = 'supplier_proposal/class';
105 } elseif ($objecttype == 'shipping') {
106  $langs->load('sendings');
107  $classpath = 'expedition/class';
108  $myobject = 'expedition';
109  $module = 'expedition_bon';
110 } elseif ($objecttype == 'delivery') {
111  $langs->load('deliveries');
112  $classpath = 'delivery/class';
113  $myobject = 'delivery';
114  $module = 'delivery_note';
115 } elseif ($objecttype == 'contract') {
116  $langs->load('contracts');
117  $classpath = 'contrat/class';
118  $module = 'contrat';
119  $myobject = 'contrat';
120 } elseif ($objecttype == 'member') {
121  $classpath = 'adherents/class';
122  $module = 'adherent';
123  $myobject = 'adherent';
124 } elseif ($objecttype == 'fichinter') {
125  $langs->load('interventions');
126  $classpath = 'fichinter/class';
127  $module = 'ficheinter';
128  $myobject = 'fichinter';
129 } elseif ($objecttype == 'project') {
130  $langs->load('projects');
131  $classpath = 'projet/class';
132  $module = 'projet';
133 } elseif ($objecttype == 'project_task') {
134  $classpath = 'projet/class';
135  $module = 'projet';
136  $myobject = 'task';
137 } elseif ($objecttype == 'stock') {
138  $classpath = 'product/stock/class';
139  $module = 'stock';
140  $myobject = 'stock';
141 } elseif ($objecttype == 'inventory') {
142  $classpath = 'product/inventory/class';
143  $module = 'stock';
144  $myobject = 'inventory';
145 } elseif ($objecttype == 'mo') {
146  $classpath = 'mrp/class';
147  $module = 'mrp';
148  $myobject = 'mo';
149 } elseif ($objecttype == 'productlot') {
150  $classpath = 'product/stock/class';
151  $module = 'stock';
152  $myobject = 'productlot';
153 } elseif ($objecttype == 'usergroup') {
154  $classpath = 'user/class';
155  $module = 'user';
156  $myobject = 'usergroup';
157 } elseif ($objecttype == 'dolresource') {
158  $classpath = 'resource/class';
159  $module = 'resource';
160  $myobject = 'dolresource';
161 } elseif ($objecttype == 'opensurvey_sondage') {
162  $classpath = 'opensurvey/class';
163  $module = 'opensurvey';
164  $myobject = 'opensurveysondage';
165 } elseif ($objecttype == 'knowledgerecord') {
166  $classpath = 'knowledgemanagement/class';
167  $module = 'knowledgemanagement';
168  $myobject = 'knowledgerecord';
169 }
170 
171 // Generic case for $classfile and $classname
172 $classfile = strtolower($myobject);
173 $classname = ucfirst($myobject);
174 
175 if ($objecttype == 'invoice_supplier') {
176  $classfile = 'fournisseur.facture';
177  $classname = 'FactureFournisseur';
178  $classpath = 'fourn/class';
179  $module = 'fournisseur';
180 } elseif ($objecttype == 'order_supplier') {
181  $classfile = 'fournisseur.commande';
182  $classname = 'CommandeFournisseur';
183  $classpath = 'fourn/class';
184  $module = 'fournisseur';
185 } elseif ($objecttype == 'supplier_proposal') {
186  $classfile = 'supplier_proposal';
187  $classname = 'SupplierProposal';
188  $classpath = 'supplier_proposal/class';
189  $module = 'supplier_proposal';
190 } elseif ($objecttype == 'stock') {
191  $classpath = 'product/stock/class';
192  $classfile = 'entrepot';
193  $classname = 'Entrepot';
194 } elseif ($objecttype == 'facturerec') {
195  $classpath = 'compta/facture/class';
196  $classfile = 'facture-rec';
197  $classname = 'FactureRec';
198  $module = 'facture';
199 } elseif ($objecttype == 'mailing') {
200  $classpath = 'comm/mailing/class';
201  $classfile = 'mailing';
202  $classname = 'Mailing';
203 } elseif ($objecttype == 'adherent_type') {
204  $classpath = 'adherents/class';
205  $classfile = 'adherent_type';
206  $module = 'adherent';
207  $myobject = 'adherent_type';
208  $classname = 'AdherentType';
209 } elseif ($objecttype == 'contact') {
210  $module = 'societe';
211 } elseif ($objecttype == 'salary') {
212  $classpath = 'salaries/class';
213  $module = 'salaries';
214 }
215 // print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath."<br>";
216 
217 if (isModEnabled($module)) {
218  $res = dol_include_once('/'.$classpath.'/'.$classfile.'.class.php');
219  if ($res) {
220  if (class_exists($classname)) {
221  $object = new $classname($db);
222  $res = $object->fetch($id);
223  if ($res > 0) {
224  $html = $object->getTooltipContent($params);
225  } elseif ($res == 0) {
226  $html = $langs->trans('Deleted');
227  }
228  unset($object);
229  } else {
230  dol_syslog("Class with classname ".$classname." is unknown even after the include", LOG_ERR);
231  }
232  }
233 }
234 
235 print $html;
236 
237 $db->close();
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:530
dol_include_once
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Definition: functions.lib.php:1043
top_httphead
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1470
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1639
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:147
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:431