41 print
"Error, template page can't be called as URL";
46 print
'Parameter langs not defined.';
49if (empty($htmlname)) {
50 print
'Parameter htmlname not defined.';
55<!-- BEGIN PHP TEMPLATE htdocs/core/tpl/formlayoutai.tpl.php -->
59@phan-var-force ?FormWebSite $formwebsite
60@phan-var-force ?FormMail $formmail
61@phan-var-force ?FormAI $formai
62@phan-var-force string $showlinktolayout
63@phan-var-force string $showlinktolayoutlabel
64@phan-var-force string $showlinktoai
65@phan-var-force string $showlinktoailabel
66@phan-var-force ?string $out
67@phan-var-force ?string $morecss
68@phan-var-force string $aiprompt
74if (!isset($morecss)) {
77if (!isset($aiprompt)) {
81if (!empty($showlinktolayout)) {
82 $out .=
'<a href="#" id="linkforlayouttemplates" class="notasortlink inline-block alink marginrightonly">';
83 $out .=
img_picto($showlinktolayoutlabel,
'layout',
'class="paddingrightonly"');
84 $out .=
'<span class="hideobject hideonsmartphone">'.$showlinktolayoutlabel.
'...</span>';
85 $out .=
'</a> ';
88 $(document).ready(function() {
89 $("#linkforlayouttemplates").click(function() {
90 console.log("We click on linkforlayouttemplates, we toggle .template-selector");
91 event.preventDefault();
92 jQuery(".template-selector").toggle();
93 jQuery(".ai_input'.$htmlname.
'").hide();
94 jQuery("#pageContent").show(); // May exists for website page only
96 jQuery(document).on("click", function (event) {
97 templateselector = jQuery(".template-selector");
98 templateselectorbutton = jQuery("#linkforlayouttemplates");
99 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")) {
100 console.log("You clicked outside of template-selector - we close it");
101 jQuery(".template-selector").hide();
109if (!empty($showlinktoai)) {
111 $out .=
'<a href="#" id="linkforaiprompt'.$showlinktoai.
'" class="notasortlink inline-block alink '.$morecss.
'">';
112 $out .=
img_picto($showlinktoailabel,
'ai',
'class="paddingrightonly"');
113 $out .=
'<span class="hideobject hideonsmartphone">'.$showlinktoailabel.
'...</span>';
117 $(document).ready(function() {
118 $("#linkforaiprompt'.$showlinktoai.
'").click(function() {
119 console.log("formlayoutai.tpl: We click on linkforaiprompt'.$showlinktoai.
', we toggle .ai_input'.$showlinktoai.
'");
120 event.preventDefault();
121 jQuery(".ai_dropdown'.$htmlname.
'").toggle();
122 jQuery(".template-selector").hide();
123 jQuery(".email-layout-container").hide();
124 if (!jQuery("#ai_dropdown'.$htmlname.
'").is(":hidden")) {
125 console.log("Set focus on input field #ai_instructions'.$htmlname.
'");
126 jQuery("#ai_instructions'.$htmlname.
'").focus();
127 if (!jQuery("pageContent").is(":hidden")) { // May exists for website page only
128 jQuery("#pageContent").show();
132 $(document).on("click", function (event) {
133 aidropdown = $(".ai_dropdown'.$htmlname.
'");
134 aidropdownbutton = $("#linkforaiprompt'.$showlinktoai.
'");
135 if (!aidropdown.is(event.target) && !aidropdownbutton.is(event.target) && $(event.target).closest(aidropdown).length === 0 && $(event.target).closest(aidropdownbutton).length === 0 && aidropdown.is(":visible")) {
136 console.log("You clicked outside of ai_dropdown - we close it");
137 $(".ai_dropdown'.$htmlname.
'").hide();
145if (!empty($showlinktolayout)) {
146 if (!empty($formwebsite) && is_object($formwebsite)) {
147 $out .= $formwebsite->getContentPageTemplate($htmlname);
149 if (!is_object($formmail)) {
151 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
154 $out .= $formmail->getEmailLayoutSelector($htmlname, $showlinktolayout);
157 $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 -->';
162if (!empty($showlinktoai)) {
163 if (empty($formai) || $formai instanceof
FormAI) {
164 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
167 $out .= $formai->getAjaxAICallFunction();
169 if (empty($onlyenhancements)) {
170 $onlyenhancements =
'';
172 if (!empty($aiprompt) && !empty(
$object)) {
173 $formai->setSubstitFromObject(
$object, $langs);
177 if (is_object($formmail) && !empty($formmail->withaiprompt)) {
178 $format = $formmail->withaiprompt;
180 $out .= $formai->getSectionForAIEnhancement($showlinktoai, $format, $htmlname, $onlyenhancements, $aiprompt);
182 $out .=
'<!-- No link to the AI feature, $formmail->withaiprompt must be set to the ai feature and module ai must be enabled -->';
186<!-- END PHP TEMPLATE htdocs/core/tpl/formlayoutai.tpl.php -->
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...
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)