43 print
"Error, template page can't be called as URL";
48 print
'Parameter langs not defined.';
51if (empty($htmlname)) {
52 print
'Parameter htmlname not defined.';
57@phan-var-force ?FormWebSite $formwebsite
58@phan-var-force ?FormMail $formmail
59@phan-var-force ?FormAI $formai
60@phan-var-force string $showlinktolayout
61@phan-var-force string $showlinktolayoutlabel
62@phan-var-force string $showlinktoai
63@phan-var-force string $showlinktoailabel
64@phan-var-force ?string $out
65@phan-var-force ?string $morecss
66@phan-var-force string $aiprompt
72if (!isset($morecss)) {
75if (!isset($aiprompt)) {
79$out .=
'<!-- BEGIN PHP TEMPLATE htdocs/core/tpl/formlayoutai.tpl.php -->'.
"\n";
82if (!empty($showlinktolayout)) {
83 $out .=
'<a href="#" id="linkforlayouttemplates" class="notasortlink inline-block alink marginrightonly">';
84 $out .= img_picto($showlinktolayoutlabel,
'layout',
'class="paddingrightonly"');
85 $out .=
'<span class="hideobject hideonsmartphone">'.$showlinktolayoutlabel.
'...</span>';
86 $out .=
'</a> ';
89 $(document).ready(function() {
90 $("#linkforlayouttemplates").click(function() {
91 console.log("We click on linkforlayouttemplates, we toggle .template-selector");
92 event.preventDefault();
93 jQuery(".template-selector").toggle();
94 jQuery(".ai_input'.$htmlname.
'").hide();
95 jQuery("#pageContent").show(); // May exists for website page only
97 jQuery(document).on("click", function (event) {
98 templateselector = jQuery(".template-selector");
99 templateselectorbutton = jQuery("#linkforlayouttemplates");
100 if (!templateselector.is(event.target) && !templateselectorbutton.is(event.target) && jQuery(event.target).closest(templateselector).length === 0 && jQuery(event.target).closest(templateselectorbutton).length === 0 && templateselector.is(":visible")) {
101 console.log("You clicked outside of template-selector - we close it");
102 jQuery(".template-selector").hide();
110if (!empty($showlinktoai)) {
112 $out .=
'<a href="#" id="linkforaiprompt'.$showlinktoai.
'" class="notasortlink inline-block alink '.$morecss.
'">';
113 $out .= img_picto($showlinktoailabel,
'ai',
'class="paddingrightonly"');
114 $out .=
'<span class="hideobject hideonsmartphone">'.$showlinktoailabel.
'...</span>';
118 $(document).ready(function() {
119 $("#linkforaiprompt'.$showlinktoai.
'").click(function() {
120 console.log("formlayoutai.tpl: We click on linkforaiprompt'.$showlinktoai.
', we toggle .ai_input'.$showlinktoai.
'");
121 event.preventDefault();
122 jQuery(".ai_dropdown'.$htmlname.
'").toggle();
123 jQuery(".template-selector").hide();
124 jQuery(".email-layout-container").hide();
125 if (!jQuery("#ai_dropdown'.$htmlname.
'").is(":hidden")) {
126 console.log("Set focus on input field #ai_instructions'.$htmlname.
'");
127 jQuery("#ai_instructions'.$htmlname.
'").focus();
128 if (!jQuery("pageContent").is(":hidden")) { // May exists for website page only
129 jQuery("#pageContent").show();
133 $(document).on("click", function (event) {
134 aidropdown = $(".ai_dropdown'.$htmlname.
'");
135 aidropdownbutton = $("#linkforaiprompt'.$showlinktoai.
'");
136 if (!aidropdown.is(event.target) && !aidropdownbutton.is(event.target) && $(event.target).closest(aidropdown).length === 0 && $(event.target).closest(aidropdownbutton).length === 0 && aidropdown.is(":visible")) {
137 console.log("You clicked outside of ai_dropdown - we close it");
138 $(".ai_dropdown'.$htmlname.
'").hide();
146if (!empty($showlinktolayout)) {
147 if (!empty($formwebsite) && is_object($formwebsite)) {
148 $out .= $formwebsite->getContentPageTemplate($htmlname);
150 if (!is_object($formmail)) {
152 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
155 $out .= $formmail->getEmailLayoutSelector($htmlname, $showlinktolayout);
158 $out .=
'<!-- No link to the layout feature, $formmail->withlayout must be set to a string use case, module WYSIWYG must be enabled and MAIN_EMAIL_USE_LAYOUT must be set -->';
163if (!empty($showlinktoai)) {
164 if (empty($formai) || $formai instanceof
FormAI) {
165 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
166 $formai =
new FormAI($db);
168 $out .= $formai->getAjaxAICallFunction();
170 if (empty($onlyenhancements)) {
171 $onlyenhancements =
'';
173 if (!empty($aiprompt) && !empty(
$object)) {
174 $formai->setSubstitFromObject(
$object, $langs);
178 if (is_object($formmail) && !empty($formmail->withaiprompt)) {
179 $format = $formmail->withaiprompt;
181 $out .= $formai->getSectionForAIEnhancement($showlinktoai, $format, $htmlname, $onlyenhancements, $aiprompt);
183 $out .=
'<!-- No link to the AI feature, $formmail->withaiprompt must be set to the ai feature and module ai must be enabled -->';
186$out .=
'<!-- END PHP TEMPLATE htdocs/core/tpl/formlayoutai.tpl.php -->'.
"\n";
if(! $sortfield) if(! $sortorder) $object
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...