dolibarr 25.0.0-alpha
command.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2026 Nick Fragoulis
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
29if (!defined('NOTOKENRENEWAL')) {
30 define('NOTOKENRENEWAL', 1);
31}
32if (!defined('NOREQUIREMENU')) {
33 define('NOREQUIREMENU', 1);
34}
35if (!defined('NOREQUIREHTML')) {
36 define('NOREQUIREHTML', 1);
37}
38if (!defined('NOREQUIREAJAX')) {
39 define('NOREQUIREAJAX', 1);
40}
41// The payload is read from the raw php://input body: the token is checked by aiCheckCsrfToken() below.
42if (!defined('NOCSRFCHECK')) {
43 define('NOCSRFCHECK', 1);
44}
45
46require '../../main.inc.php';
47require_once DOL_DOCUMENT_ROOT.'/ai/class/mcp.class.php';
48require_once DOL_DOCUMENT_ROOT.'/ai/lib/ai.lib.php';
49
57// Same gates as execute_tool.php.
58if (!isModEnabled('ai') || !getDolGlobalString('AI_ASSISTANT_ENABLED')) {
59 accessforbidden('Module or feature not allowed');
60}
61if (!$user->hasRight('ai', 'assistant', 'use')) {
63}
64aiCheckCsrfToken('ai/assistant/command.php');
65
66top_httphead('application/json');
67$langs->loadLangs(array('main', 'other', 'bills'));
68
69// Document commands: the bridge tool that writes, and the word the syntax uses
70// for the third party.
71$documentCommands = array(
72 'invoice' => array('tool' => 'api_invoices_create', 'label' => 'AICmdInvoice', 'who' => 'Customer'),
73 'order' => array('tool' => 'api_orders_create', 'label' => 'AICmdOrder', 'who' => 'Customer'),
74 'proposal' => array('tool' => 'api_proposals_create', 'label' => 'AICmdProposal', 'who' => 'Customer'),
75 'supplier-invoice' => array('tool' => 'api_supplier_invoices_create', 'label' => 'AICmdSupplierInvoice', 'who' => 'Supplier', 'ref' => true),
76 'supplier-order' => array('tool' => 'api_supplier_orders_create', 'label' => 'AICmdSupplierOrder', 'who' => 'Supplier'),
77);
78// Lists /total can add up: table, read right, and the payments table for invoices.
79$totalElements = array(
80 'facture' => array('table' => 'facture', 'right' => array('facture', 'lire'), 'paid' => array('paiement_facture', 'fk_facture')),
81 'invoice_supplier' => array('table' => 'facture_fourn', 'right' => array('fournisseur', 'facture', 'lire'), 'paid' => array('paiementfourn_facturefourn', 'fk_facturefourn')),
82 'commande' => array('table' => 'commande', 'right' => array('commande', 'lire')),
83 'propal' => array('table' => 'propal', 'right' => array('propal', 'lire')),
84 'order_supplier' => array('table' => 'commande_fournisseur', 'right' => array('fournisseur', 'commande', 'lire')),
85 'supplier_proposal' => array('table' => 'supplier_proposal', 'right' => array('supplier_proposal', 'lire')),
86);
87
88$mcp = new McpHandler($db, $user, $conf, McpHandler::CTX_ASSISTANT);
89$mcp->loadTools();
90// What this user may run: the same filter as the model gets (rights and allow-list).
91$allowedTools = array_flip(array_column($mcp->getToolsSchemaForLLM(), 'name'));
92
93// --- The list of commands, for the palette ---------------------------------
94if (GETPOST('action', 'aZ09') === 'list') {
95 $list = array();
96 foreach ($documentCommands as $cmd => $def) {
97 if (!isset($allowedTools[$def['tool']])) {
98 continue;
99 }
100 $list[] = array(
101 'name' => $cmd,
102 'label' => $langs->transnoentitiesnoconv($def['label']),
103 'syntax' => '/'.$cmd.' '.$langs->transnoentitiesnoconv('AICmdSyntaxDocument', dol_strtolower($langs->transnoentitiesnoconv($def['who']))).(!empty($def['ref']) ? ' ref:...' : '')
104 );
105 }
106 $list[] = array('name' => 'total', 'label' => $langs->transnoentitiesnoconv('AICmdTotal'), 'syntax' => '/total');
107 print json_encode(array('commands' => $list));
108 $db->close();
109 exit;
110}
111
112// --- Suggestions while typing: third parties, then products ----------------
113if (GETPOST('action', 'aZ09') === 'suggest') {
114 $kind = GETPOST('kind', 'aZ09');
115 $q = trim(GETPOST('q', 'restricthtml'));
116 $cmdName = GETPOST('cmd', 'alphanohtml');
117 $side = (strpos($cmdName, 'supplier') === 0) ? 'buy' : 'sell';
118 $items = array();
119 $consumed = $q;
120 if ($kind === 'thirdparty' && dol_strlen($q) >= 2 && $user->hasRight('societe', 'lire')) {
121 // Every word somewhere in the name or the trade name; only third parties the user sees.
122 $sql = "SELECT s.rowid, s.nom, s.name_alias, s.town, s.client, s.fournisseur FROM ".$db->prefix()."societe as s";
123 $sql .= " WHERE s.entity IN (".getEntity('societe').") AND s.status = 1";
124 foreach (array_slice(preg_split('/\s+/', $q, -1, PREG_SPLIT_NO_EMPTY) ?: array(), 0, 6) as $w) {
125 $like = $db->escape($db->escapeforlike($w));
126 $sql .= " AND (s.nom LIKE '%".$like."%' OR s.name_alias LIKE '%".$like."%')";
127 }
128 // As the lists of Dolibarr: an external user sees their own company, an
129 // internal one without "see all customers" the ones they follow.
130 if ($user->socid > 0) {
131 $sql .= " AND s.rowid = ".((int) $user->socid);
132 } elseif (!$user->hasRight('societe', 'client', 'voir')) {
133 $sql .= " AND s.rowid IN (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_user = ".((int) $user->id).")";
134 }
135 $sql .= " ORDER BY s.nom LIMIT 10";
136 $resql = $db->query($sql);
137 $langs->load('companies');
138 while ($resql && ($obj = $db->fetch_object($resql))) {
139 // Customer, prospect, supplier: what the third party is, then where.
140 $roles = array();
141 if (in_array((int) $obj->client, array(1, 3), true)) {
142 $roles[] = $langs->transnoentitiesnoconv('Customer');
143 }
144 if (in_array((int) $obj->client, array(2, 3), true)) {
145 $roles[] = $langs->transnoentitiesnoconv('Prospect');
146 }
147 if ((int) $obj->fournisseur === 1) {
148 $roles[] = $langs->transnoentitiesnoconv('Supplier');
149 }
150 $detail = implode(', ', array_filter(array(implode(' / ', $roles), (string) $obj->town)));
151 $items[] = array('value' => (string) $obj->nom, 'ref' => (string) $obj->nom, 'label' => (string) $obj->nom.((string) $obj->name_alias !== '' ? ' ('.$obj->name_alias.')' : ''), 'detail' => $detail);
152 }
153 } elseif ($kind === 'product') {
154 // A unit said before the product ("4 pieces pop") is not part of the search.
155 $words = preg_split('/\s+/', trim(str_replace('"', ' ', ltrim($q, '#'))), -1, PREG_SPLIT_NO_EMPTY) ?: array();
156 if (count($words) >= 1 && aiUnitIdFromName($db, $words[0]) > 0 && (count($words) > 1 || substr($q, -1) === ' ')) {
157 array_shift($words);
158 }
159 $consumed = implode(' ', $words);
160 if ($consumed !== '') {
161 $found = aiFindProducts($db, $user, $consumed, $side, 10);
162 } else {
163 // Nothing typed yet: what this third party had last.
164 $socid = GETPOSTINT('socid');
165 $name = trim(GETPOST('name', 'restricthtml'));
166 if ($socid <= 0 && $name !== '') {
167 $best = array('words' => 0, 'candidates' => array());
168 foreach (aiFindThirdpartiesInText($db, $user, $name) as $mt) {
169 if ($mt['words'] > $best['words']) {
170 $best = $mt;
171 }
172 }
173 $visible = array();
174 foreach ($best['candidates'] as $cid => $c) {
175 if (!empty($c['visible'])) {
176 $visible[$cid] = $c;
177 }
178 }
179 $socid = (count($visible) === 1) ? (int) key($visible) : 0;
180 }
181 $found = aiRecentProducts($db, $user, $socid, $side, 8);
182 }
183 $langs->load('products');
184 foreach ($found as $pr) {
185 // The product is written by its name, the word users know (a ref is
186 // rarely remembered). In a command a name with spaces, or that is a
187 // number, goes in quotes, so it is never read as a quantity, a price or
188 // two products.
189 $name = trim(str_replace('"', '', (string) ($pr['label'] !== '' ? $pr['label'] : $pr['ref'])));
190 $plain = (preg_match('/^\S+$/', $name) && !preg_match('/^\d+(?:[.,]\d+)?$/', $name));
191 $value = $plain ? $name : '"'.$name.'"';
192 $sentence = $name;
193 $detail = price($pr['price'], 0, $langs, 1, -1, -1, $conf->currency);
194 if (isModEnabled('stock')) {
195 $detail .= ' - '.$langs->transnoentitiesnoconv('Stock').' '.price2num($pr['stock'], 'MS');
196 }
197 // 'value' for a command line, 'ref' for a sentence to the AI.
198 $items[] = array('value' => $value, 'ref' => $sentence, 'label' => $pr['ref'].' - '.$pr['label'], 'detail' => $detail);
199 }
200 }
201 print json_encode(array('items' => $items, 'consumed' => $consumed));
202 $db->close();
203 exit;
204}
205
206$input = json_decode((string) file_get_contents('php://input'), true);
207$command = is_array($input) ? (string) ($input['command'] ?? '') : '';
208$text = is_array($input) ? trim((string) ($input['text'] ?? '')) : '';
209$context = (is_array($input) && isset($input['context']) && is_array($input['context'])) ? $input['context'] : array();
210$choices = (is_array($input) && isset($input['thirdparty_choices']) && is_array($input['thirdparty_choices'])) ? $input['thirdparty_choices'] : array();
211$productChoices = (is_array($input) && isset($input['product_choices']) && is_array($input['product_choices'])) ? $input['product_choices'] : array();
212$startTime = microtime(true);
213
225function aiCommandAnswer($db, $user, $query, $startTime, array $response, $status = 'Success')
226{
227 ai_log_request($db, $user, $query, $response, 'palette', microtime(true) - $startTime, 1.0, $status, (string) ($response['error'] ?? ''));
228 print json_encode($response);
229 $db->close();
230 exit;
231}
232$typedQuery = '/'.$command.' '.$text;
233
234// --- /total -----------------------------------------------------------------
235if ($command === 'total') {
236 $element = (string) ($context['element'] ?? '');
237 if (empty($context['list']) || !isset($totalElements[$element])) {
238 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AICmdTotalNoList')), 'Error');
239 }
240 $def = $totalElements[$element];
241 if (!$user->hasRight($def['right'][0], $def['right'][1], $def['right'][2] ?? '')) {
242 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('NotEnoughPermissions')), 'Error');
243 }
244 $scope = 'ticked';
245 $ids = array_values(array_filter(array_map('intval', (array) ($context['selected'] ?? array()))));
246 if (empty($ids)) {
247 $scope = 'shown';
248 $ids = array_values(array_filter(array_map('intval', (array) ($context['ids'] ?? array()))));
249 }
250 $ids = array_slice(array_unique($ids), 0, 500);
251 if (empty($ids)) {
252 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AICmdTotalNoList')), 'Error');
253 }
254 // One query for all the rows (no per-row fetch); the same entity and
255 // sales-representative restrictions as the list itself.
256 $sql = "SELECT COUNT(t.rowid) as nb, SUM(t.total_ht) as ht, SUM(t.total_tva) as tva, SUM(t.total_ttc) as ttc";
257 if (!empty($def['paid'])) {
258 $sql .= ", SUM((SELECT COALESCE(SUM(p.amount), 0) FROM ".$db->prefix().$db->sanitize($def['paid'][0])." as p WHERE p.".$db->sanitize($def['paid'][1])." = t.rowid)) as paid";
259 }
260 $sql .= " FROM ".$db->prefix().$db->sanitize($def['table'])." as t";
261 $sql .= " WHERE t.rowid IN (".$db->sanitize(implode(',', $ids)).")";
262 $sql .= " AND t.entity IN (".getEntity($element).")";
263 if ($user->socid > 0) {
264 $sql .= " AND t.fk_soc = ".((int) $user->socid); // an external user: their own company only
265 } elseif (!$user->hasRight('societe', 'client', 'voir')) {
266 $sql .= " AND t.fk_soc IN (SELECT sc.fk_soc FROM ".$db->prefix()."societe_commerciaux as sc WHERE sc.fk_user = ".((int) $user->id).")";
267 }
268 $resql = $db->query($sql);
269 $obj = $resql ? $db->fetch_object($resql) : null;
270 if (!$obj) {
271 dol_syslog('command.php total '.$db->lasterror(), LOG_ERR);
272 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('Error')), 'Error');
273 }
274 $rows = array(
275 array($langs->transnoentitiesnoconv('AmountHT'), price((float) $obj->ht, 0, $langs, 1, -1, -1, $conf->currency)),
276 array($langs->transnoentitiesnoconv('AmountVAT'), price((float) $obj->tva, 0, $langs, 1, -1, -1, $conf->currency)),
277 array($langs->transnoentitiesnoconv('AmountTTC'), price((float) $obj->ttc, 0, $langs, 1, -1, -1, $conf->currency)),
278 );
279 if (!empty($def['paid'])) {
280 $rows[] = array($langs->transnoentitiesnoconv('AlreadyPaid'), price((float) $obj->paid, 0, $langs, 1, -1, -1, $conf->currency));
281 $rows[] = array($langs->transnoentitiesnoconv('RemainderToPay'), price((float) $obj->ttc - (float) $obj->paid, 0, $langs, 1, -1, -1, $conf->currency));
282 }
283 aiCommandAnswer($db, $user, $typedQuery, $startTime, array(
284 'totals' => array(
285 'title' => $langs->transnoentitiesnoconv($scope === 'ticked' ? 'AICmdTotalTicked' : 'AICmdTotalShown', (string) ((int) $obj->nb)),
286 'rows' => $rows
287 )
288 ));
289}
290
291// --- Document commands -----------------------------------------------------
292if (!isset($documentCommands[$command]) || !isset($allowedTools[$documentCommands[$command]['tool']])) {
293 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AICmdUnknown', $command)), 'Error');
294}
295$def = $documentCommands[$command];
296$side = (strpos($command, 'supplier') === 0) ? 'buy' : 'sell';
297$parsed = aiParseDocumentCommand($db, $text, $user, $side);
298if ($parsed['error'] === 'nolines') {
299 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AICmdNoLines', '/'.$command.' '.$langs->transnoentitiesnoconv('AICmdSyntaxDocument', dol_strtolower($langs->transnoentitiesnoconv($def['who']))))), 'Error');
300}
301if (!empty($def['ref']) && $parsed['ref'] === '') {
302 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AICmdNeedRefSupplier')), 'Error');
303}
304
305// The third party: named in the line, or the one of the card being viewed.
306// Never guessed: several fit -> the user chooses, as in the chat.
307$socid = 0;
308if ($parsed['name'] !== '') {
309 // The longest phrase of the name that matched (one name, one phrase).
310 $best = array('phrase' => '', 'raw' => $parsed['name'], 'words' => 0, 'candidates' => array());
311 foreach (aiFindThirdpartiesInText($db, $user, $parsed['name']) as $mt) {
312 if ($mt['words'] > $best['words']) {
313 $best = $mt;
314 }
315 }
316 $visible = array();
317 foreach ($best['candidates'] as $cid => $c) {
318 if ($c['visible']) {
319 $visible[(int) $cid] = $c;
320 }
321 }
322 if (empty($visible)) {
323 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AIWriteThirdpartyNotFound', $parsed['name'])), 'Error');
324 }
325 $chosen = isset($choices[$best['phrase']]) ? (int) $choices[$best['phrase']] : 0;
326 if ($chosen > 0 && isset($visible[$chosen])) {
327 $socid = $chosen;
328 } elseif (count($visible) === 1) {
329 $socid = (int) key($visible);
330 } else {
331 $langs->load('companies');
332 $options = array();
333 foreach ($visible as $cid => $c) {
334 $nat = array();
335 if (in_array($c['client'], array(1, 3))) {
336 $nat[] = $langs->transnoentitiesnoconv('Customer');
337 }
338 if (in_array($c['client'], array(2, 3))) {
339 $nat[] = $langs->transnoentitiesnoconv('Prospect');
340 }
341 if ($c['fournisseur'] == 1) {
342 $nat[] = $langs->transnoentitiesnoconv('Supplier');
343 }
344 $options[] = array('id' => $cid, 'label' => $c['name'].($c['name_alias'] !== '' ? ' ('.$c['name_alias'].')' : '').(!empty($nat) ? ' - '.implode(', ', $nat) : '').($c['town'] !== '' ? ' - '.$c['town'] : ''));
345 }
346 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('tool' => 'ask_for_clarification', 'arguments' => array(
347 'question' => $langs->transnoentitiesnoconv('AIWhichThirdparty', $best['raw']),
348 'thirdparty_choice' => array('phrase' => $best['phrase'], 'options' => $options)
349 )), 'Confirm');
350 }
351} else {
352 $element = (string) ($context['element'] ?? '');
353 $socid = ($element === 'societe') ? (int) ($context['id'] ?? 0) : (int) ($context['socid'] ?? 0);
354 if ($socid <= 0) {
355 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AICmdNeedThirdparty', dol_strtolower($langs->transnoentitiesnoconv($def['who'])))), 'Error');
356 }
357 // The page's third party comes from the browser: the user must be allowed to see it.
358 if (!checkUserAccessToObject($user, array('societe'), $socid, '', '', 'fk_soc', 'rowid')) {
359 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => $langs->transnoentitiesnoconv('AICmdNeedThirdparty', dol_strtolower($langs->transnoentitiesnoconv($def['who'])))), 'Error');
360 }
361}
362
363// Each product: the one typed when it is unique, otherwise the user picks it
364// (or keeps the words as a free-text line). A line is never written with a
365// product guessed from a few letters.
366foreach ($parsed['lines'] as $li => $line) {
367 $typed = (string) ($line['product_ref'] ?? '');
368 $key = $li.':'.$typed;
369 $pick = 0;
370 if (isset($productChoices[$key]) && is_numeric($productChoices[$key])) {
371 $pick = (int) $productChoices[$key];
372 if ($pick === 0) {
373 $parsed['lines'][$li]['desc'] = $typed; // kept as free text, as the user chose
374 unset($parsed['lines'][$li]['product_ref']);
375 continue;
376 }
377 }
378 // "#" only says "a product": what follows is its name or its ref, never a
379 // rowid. Quotes, as a picked suggestion writes a name, only group the words.
380 $search = trim(str_replace('"', ' ', ltrim($typed, '#')));
381 if ($pick > 0) {
382 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
383 $prod = new Product($db);
384 if ($prod->fetch($pick) > 0 && ($side === 'buy' ? $prod->status_buy : $prod->status) && $user->hasRight($prod->type == 1 ? 'service' : 'produit', 'lire')) {
385 $parsed['lines'][$li]['product_ref'] = $prod->ref;
386 continue;
387 }
388 }
389 $found = aiFindProducts($db, $user, $search, $side, 10);
390 $exact = array();
391 foreach ($found as $pr) {
392 if (!empty($pr['exact'])) {
393 $exact[] = $pr;
394 }
395 }
396 if (count($exact) === 1 || count($found) === 1) {
397 $parsed['lines'][$li]['product_ref'] = (count($exact) === 1 ? $exact[0]['ref'] : $found[0]['ref']);
398 continue;
399 }
400 $options = array();
401 foreach ($found as $pr) {
402 $options[] = array('id' => $pr['id'], 'label' => $pr['ref'].' - '.$pr['label'].' - '.price($pr['price'], 0, $langs, 1, -1, -1, $conf->currency));
403 }
404 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('tool' => 'ask_for_clarification', 'arguments' => array(
405 'question' => $langs->transnoentitiesnoconv(empty($options) ? 'AICmdProductNotFound' : 'AICmdWhichProduct', $search),
406 'product_choice' => array('key' => $key, 'options' => $options)
407 )), 'Confirm');
408}
409
410$args = array('socid' => $socid, 'lines' => $parsed['lines']);
411if ($parsed['ref'] !== '') {
412 $args['ref_supplier'] = $parsed['ref'];
413}
414// Through the tool, as the chat would call it: rights, refusal and the
415// confirmation all apply. The first call only prepares the confirmation.
416$result = $mcp->executeTool($def['tool'], $args);
417if (isset($result['error'])) {
418 aiCommandAnswer($db, $user, $typedQuery, $startTime, array('error' => (string) $result['error']), 'Error');
419}
420aiCommandAnswer($db, $user, $typedQuery, $startTime, array('result' => $result, 'tool' => $def['tool'], 'arguments' => $args), (($result['resultType'] ?? '') === 'input_required') ? 'Confirm' : 'Success');
$propal type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition propal.php:281
aiFindProducts($db, $user, $text, $side='sell', $limit=10)
Products of the catalogue matching what a user typed: every word must be in the ref or the label,...
Definition ai.lib.php:2018
aiUnitIdFromName($db, $name)
Unit id from the word a user used for it: code, short label or label, in the user's language,...
Definition ai.lib.php:1816
aiFindThirdpartiesInText($db, $user, $text, $nature='', $stopwords=array(), $maxwords=80)
Third parties named in a text, by the words of their name or trade name (name_alias),...
Definition ai.lib.php:1490
aiParseDocumentCommand($db, $text, $user=null, $side='sell')
Read a one-line document command of the chat palette, e.g.
Definition ai.lib.php:1874
ai_log_request($db, $user, $query, array $response, $provider, float $time, float $confidence, $status, $error='', $rawReq='', $rawRes='', array $context=array(), &$logId=null)
Log AI Request with Raw Payloads.
Definition ai.lib.php:416
aiCheckCsrfToken($context='')
Check the anti-CSRF token of a request sent to one of the AI Assistant endpoints.
Definition ai.lib.php:1260
aiRecentProducts($db, $user, $socid, $side='sell', $limit=8)
Products of a third party's latest documents, newest first: what is most likely to be sold (or bought...
Definition ai.lib.php:2075
$c
Definition line.php:353
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class to handle MCP (Model Context Protocol).
Definition mcp.class.php:40
Class to manage products or services.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:169
aiCommandAnswer($db, $user, $query, $startTime, array $response, $status='Success')
Answer the browser, log the command like the other assistant requests, and stop.
Definition command.php:225
$context
@method int call_trigger(string $triggerName, ?User $user)
Definition command.php:209
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_strtolower($string, $encoding="UTF-8")
Convert a string to lower.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
checkUserAccessToObject($user, array $featuresarray, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='', $dbt_select='rowid', $parenttableforentity='')
Check that access by a given user to an object is ok.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.