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
101if (!empty($showlinktoai)) {
103 $out .=
'<a href="#" id="linkforaiprompt'.$showlinktoai.
'" class="notasortlink inline-block alink '.$morecss.
'">';
104 $out .=
img_picto($showlinktoailabel,
'ai',
'class="paddingrightonly"');
105 $out .=
'<span class="hideobject hideonsmartphone">'.$showlinktoailabel.
'...</span>';
109 $(document).ready(function() {
110 $("#linkforaiprompt'.$showlinktoai.
'").click(function() {
111 console.log("formlayoutai.tpl: We click on linkforaiprompt'.$showlinktoai.
', we toggle .ai_input'.$showlinktoai.
'");
112 event.preventDefault();
113 jQuery(".ai_dropdown'.$htmlname.
'").toggle();
114 jQuery(".template-selector").hide();
115 jQuery(".email-layout-container").hide();
116 if (!jQuery("#ai_dropdown'.$htmlname.
'").is(":hidden")) {
117 console.log("Set focus on input field #ai_instructions'.$htmlname.
'");
118 jQuery("#ai_instructions'.$htmlname.
'").focus();
119 if (!jQuery("pageContent").is(":hidden")) { // May exists for website page only
120 jQuery("#pageContent").show();
124 $(document).on("click", function (event) {
125 aidropdown = $(".ai_dropdown'.$htmlname.
'");
126 aidropdownbutton = $("#linkforaiprompt'.$showlinktoai.
'");
127 if (!aidropdown.is(event.target) && !aidropdownbutton.is(event.target) && $(event.target).closest(aidropdown).length === 0 && $(event.target).closest(aidropdownbutton).length === 0 && aidropdown.is(":visible")) {
128 console.log("You clicked outside of ai_dropdown - we close it");
129 $(".ai_dropdown'.$htmlname.
'").hide();
137if (!empty($showlinktolayout)) {
138 if (!empty($formwebsite) && is_object($formwebsite)) {
139 $out .= $formwebsite->getContentPageTemplate($htmlname);
141 if (!is_object($formmail)) {
143 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
146 $out .= $formmail->getEmailLayoutSelector($htmlname, $showlinktolayout);
149 $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 -->';
154if (!empty($showlinktoai)) {
155 if (empty($formai) || $formai instanceof
FormAI) {
156 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formai.class.php';
159 $out .= $formai->getAjaxAICallFunction();
161 if (empty($onlyenhancements)) {
162 $onlyenhancements =
'';
164 if (!empty($aiprompt) && !empty(
$object)) {
165 $formai->setSubstitFromObject(
$object, $langs);
169 if (is_object($formmail) && !empty($formmail->withaiprompt)) {
170 $format = $formmail->withaiprompt;
172 $out .= $formai->getSectionForAIEnhancement($showlinktoai, $format, $htmlname, $onlyenhancements, $aiprompt);
174 $out .=
'<!-- No link to the AI feature, $formmail->withaiprompt must be set to the ai feature and module ai must be enabled -->';
178<!-- END PHP TEMPLATE htdocs/core/tpl/formlayoutai.tpl.php -->
if(! $sortfield) if(! $sortorder) $object
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)
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...