diff --git a/htdocs/core/class/html.formai.class.php b/htdocs/core/class/html.formai.class.php index 46b5cabe6bd..f317c2d1be2 100644 --- a/htdocs/core/class/html.formai.class.php +++ b/htdocs/core/class/html.formai.class.php @@ -75,6 +75,10 @@ class FormAI extends Form */ public $withoptiononeemailperrecipient; + /** + * @var bool + */ + public $aicallfunctioncalled = false; /** * Constructor @@ -114,7 +118,6 @@ class FormAI extends Form } $out .= "\n"; - $out .= " @@ -240,6 +152,115 @@ class FormAI extends Form return $out; } + /** + * Return javascript code for call to AI function callAIGenerator() + * + * @return string HTML code to ask AI instruction and autofill result + */ + public function getAjaxAICallFunction() + { + $out = ""; + if ($this->aicallfunctioncalled) { + return $out; + } + + $out .= " + "; + $this->aicallfunctioncalled = true; + return $out; + } + /** * Set ->substit (and ->substit_line) array from object. This is call when suggesting the email template into forms before sending email. * diff --git a/htdocs/core/tpl/formlayoutai.tpl.php b/htdocs/core/tpl/formlayoutai.tpl.php index 31709d692d9..1baf28721b9 100644 --- a/htdocs/core/tpl/formlayoutai.tpl.php +++ b/htdocs/core/tpl/formlayoutai.tpl.php @@ -118,6 +118,7 @@ if ($showlinktolayout) { $out .= ''; } if ($showlinktoai) { + $out .= $formai->getAjaxAICallFunction(); $out .= $formai->getSectionForAIPrompt($showlinktoai, $formmail->withaiprompt, $htmlname); } else { $out .= ''; diff --git a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql index 51175810165..a71b346fce7 100644 --- a/htdocs/install/mysql/migration/21.0.0-22.0.0.sql +++ b/htdocs/install/mysql/migration/21.0.0-22.0.0.sql @@ -136,3 +136,28 @@ ALTER TABLE llx_categorie_supplier_invoice ADD INDEX idx_categorie_supplier_invo ALTER TABLE llx_categorie_supplier_invoice ADD CONSTRAINT fk_categorie_supplier_invoice_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); ALTER TABLE llx_categorie_supplier_invoice ADD CONSTRAINT fk_categorie_supplier_invoice_fk_supplier_invoice_rowid FOREIGN KEY (fk_supplier_invoice) REFERENCES llx_facture_fourn (rowid); + + +CREATE TABLE llx_bank_record +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + ref varchar(50) NOT NULL, + fk_bank integer NOT NULL, + dt_from date NOT NULL, + dt_to date NOT NULL, + date_creation datetime NOT NULL, + date_valid datetime NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +)ENGINE=innodb; + +ALTER TABLE llx_bank_record ADD CONSTRAINT bank_record_fk_bank FOREIGN KEY (fk_bank) REFERENCES llx_bank_account (rowid); + +CREATE TABLE llx_bank_record_link +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_bank_record integer NOT NULL, + fk_bank_import integer NOT NULL +)ENGINE=innodb; + +ALTER TABLE llx_bank_record_link ADD CONSTRAINT fk_bank_record_bank_record FOREIGN KEY (llx_bank_record) REFERENCES llx_bank_record (rowid); +ALTER TABLE llx_bank_record_link ADD CONSTRAINT fk_bank_import_bank_import FOREIGN KEY (fk_bank_import) REFERENCES llx_bank_import (rowid); diff --git a/htdocs/install/mysql/tables/llx_bank_record-bank.key.sql b/htdocs/install/mysql/tables/llx_bank_record-bank.key.sql new file mode 100644 index 00000000000..d7dc328c4ac --- /dev/null +++ b/htdocs/install/mysql/tables/llx_bank_record-bank.key.sql @@ -0,0 +1,23 @@ +-- =================================================================== +-- Copyright (C) 2025 Florian HENRY +-- Copyright (C) 2025 Laurent MAGNIN +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + +-- Table to receive manual import of a bank statement +-- Try to match compatibility with external module banking to capitalize on knowledge but removed fields for advanced features. + +ALTER TABLE llx_bank_record ADD CONSTRAINT bank_record_fk_bank FOREIGN KEY (fk_bank) REFERENCES llx_bank_account (rowid); diff --git a/htdocs/install/mysql/tables/llx_bank_record-bank.sql b/htdocs/install/mysql/tables/llx_bank_record-bank.sql new file mode 100644 index 00000000000..c5c51bcd555 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_bank_record-bank.sql @@ -0,0 +1,33 @@ +-- =================================================================== +-- Copyright (C) 2025 Florian HENRY +-- Copyright (C) 2025 Laurent MAGNIN +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + +-- Table to receive manual import of a bank statement +-- Try to match compatibility with external module banking to capitalize on knowledge but removed fields for advanced features. + +CREATE TABLE llx_bank_record +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + ref varchar(50) NOT NULL, + fk_bank integer NOT NULL, + dt_from date NOT NULL, + dt_to date NOT NULL, + date_creation datetime NOT NULL, + date_valid datetime NULL, + tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +)ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_bank_record_link-bank.key.sql b/htdocs/install/mysql/tables/llx_bank_record_link-bank.key.sql new file mode 100644 index 00000000000..abf41d7047e --- /dev/null +++ b/htdocs/install/mysql/tables/llx_bank_record_link-bank.key.sql @@ -0,0 +1,21 @@ +-- =================================================================== +-- Copyright (C) 2025 Florian HENRY +-- Copyright (C) 2025 Laurent MAGNIN +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + +ALTER TABLE llx_bank_record_link ADD CONSTRAINT fk_bank_record_bank_record FOREIGN KEY (llx_bank_record) REFERENCES llx_bank_record (rowid); +ALTER TABLE llx_bank_record_link ADD CONSTRAINT fk_bank_import_bank_import FOREIGN KEY (fk_bank_import) REFERENCES llx_bank_import (rowid); diff --git a/htdocs/install/mysql/tables/llx_bank_record_link-bank.sql b/htdocs/install/mysql/tables/llx_bank_record_link-bank.sql new file mode 100644 index 00000000000..53a5a3facca --- /dev/null +++ b/htdocs/install/mysql/tables/llx_bank_record_link-bank.sql @@ -0,0 +1,28 @@ +-- =================================================================== +-- Copyright (C) 2025 Florian HENRY +-- Copyright (C) 2025 Laurent MAGNIN +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + +-- Table to receive manual import of a bank statement +-- Try to match compatibility with external module banking to capitalize on knowledge but removed fields for advanced features. + +CREATE TABLE llx_bank_record_link +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_bank_record integer NOT NULL, + fk_bank_import integer NOT NULL +)ENGINE=innodb;