From afbab1953dddb6ce44162a2757c27c5c67d2a028 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 21 Feb 2025 12:36:16 +0100 Subject: [PATCH 1/3] Fix formai class to make ai prompt code to be more general --- htdocs/core/class/html.formai.class.php | 216 +++++++++++++----------- htdocs/core/tpl/formlayoutai.tpl.php | 1 + 2 files changed, 119 insertions(+), 98 deletions(-) diff --git a/htdocs/core/class/html.formai.class.php b/htdocs/core/class/html.formai.class.php index 46b5cabe6bd..8c599f6353d 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,114 @@ 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 .= ''; From 7c0c238812d700cfdda5ccdbc33619cbba407039 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 21 Feb 2025 12:41:39 +0100 Subject: [PATCH 2/3] new: add table to prerapre bank records in Dolibarr --- .../install/mysql/migration/21.0.0-22.0.0.sql | 25 ++++++++++++++ .../mysql/tables/llx_bank_record-bank.key.sql | 23 +++++++++++++ .../mysql/tables/llx_bank_record-bank.sql | 33 +++++++++++++++++++ .../tables/llx_bank_record_link-bank.key.sql | 21 ++++++++++++ .../tables/llx_bank_record_link-bank.sql | 28 ++++++++++++++++ 5 files changed, 130 insertions(+) create mode 100644 htdocs/install/mysql/tables/llx_bank_record-bank.key.sql create mode 100644 htdocs/install/mysql/tables/llx_bank_record-bank.sql create mode 100644 htdocs/install/mysql/tables/llx_bank_record_link-bank.key.sql create mode 100644 htdocs/install/mysql/tables/llx_bank_record_link-bank.sql 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 7b9c19450b4..73fd28f066c 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 @@ -131,3 +131,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; From 540364050e001a3f99ef5596e26cfdd4162074ff Mon Sep 17 00:00:00 2001 From: Hystepik Date: Fri, 21 Feb 2025 12:45:02 +0100 Subject: [PATCH 3/3] fix ci --- htdocs/core/class/html.formai.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formai.class.php b/htdocs/core/class/html.formai.class.php index 8c599f6353d..f317c2d1be2 100644 --- a/htdocs/core/class/html.formai.class.php +++ b/htdocs/core/class/html.formai.class.php @@ -157,7 +157,8 @@ class FormAI extends Form * * @return string HTML code to ask AI instruction and autofill result */ - public function getAjaxAICallFunction(){ + public function getAjaxAICallFunction() + { $out = ""; if ($this->aicallfunctioncalled) { return $out;