dolibarr 20.0.0
formlayoutai.tpl.php
1<?php
2/* Copyright (C) 2024 Laurent Destailleur <eldy@users.sourceforge.net>
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 * Need to have following variables defined:
18 * $conf
19 * $formmail
20 * $formwebsite (optional)
21 * $showlinktolayout
22 * $showlinktolayoutlabel
23 * $showlinktoai ('' or 'textgeneration', 'textgenerationemail', 'textgenerationwebpage', ...)
24 * $showlinktoailabel
25 * $htmlname
26 */
27
28// Protection to avoid direct call of template
29if (empty($conf) || !is_object($conf)) {
30 print "Error, template page can't be called as URL";
31 exit(1);
32}
33
34?>
35<!-- BEGIN PHP TEMPLATE formlayoutai.tpl.php -->
36<?php
37
38// Add link to add layout
39if ($showlinktolayout) {
40 $out .= '<a href="#" id="linkforlayouttemplates" class="reposition notasortlink inline-block alink marginrightonly">';
41 $out .= img_picto($showlinktolayoutlabel, 'layout', 'class="paddingrightonly"');
42 $out .= $showlinktolayoutlabel.'...';
43 $out .= '</a> &nbsp; &nbsp; ';
44
45 $out .= '<script>
46 $(document).ready(function() {
47 $("#linkforlayouttemplates").click(function() {
48 console.log("We click on linkforlayouttemplates");
49 event.preventDefault();
50 jQuery("#template-selector").toggle();
51 jQuery("#ai_input").hide();
52 jQuery("#pageContent").show(); // May exists for website page only
53 });
54 });
55 </script>
56 ';
57}
58// Add link to add AI content
59if ($showlinktoai) {
60 $out .= '<a href="#" id="linkforaiprompt" class="reposition notasortlink inline-block alink marginrightonly">';
61 $out .= img_picto($showlinktoailabel, 'ai', 'class="paddingrightonly"');
62 $out .= $showlinktoailabel.'...';
63 $out .= '</a>';
64
65 $out .= '<script>
66 $(document).ready(function() {
67 $("#linkforaiprompt").click(function() {
68 console.log("We click on linkforaiprompt");
69 event.preventDefault();
70 jQuery("#ai_input").toggle();
71 jQuery("#template-selector").hide();
72 if (!jQuery("ai_input").is(":hidden")) {
73 console.log("Set focus on input field");
74 jQuery("#ai_instructions").focus();
75 if (!jQuery("pageContent").is(":hidden")) { // May exists for website page only
76 jQuery("#pageContent").show();
77 }
78 }
79 });
80 });
81 </script>
82 ';
83}
84if ($showlinktolayout) {
85 if (!empty($formwebsite) && is_object($formwebsite)) {
86 $out .= $formwebsite->getContentPageTemplate($htmlname);
87 } else {
88 $out .= $formmail->getModelEmailTemplate($htmlname);
89 }
90}
91if ($showlinktoai) {
92 $out .= $formmail->getSectionForAIPrompt($showlinktoai, $formmail->withaiprompt, $htmlname);
93}
94
95?>
96<!-- END PHP TEMPLATE commonfields_edit.tpl.php -->
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)