public function getConfigurations($moduleName) { $availableAttachments = \Workflow\InterfaceFiles::getAvailableFiles($moduleName); $selectHTML = '<select id="attachFromExternalModuleValue" name="attachFromExternalModuleValue" class="select2" style="width:300px;">'; foreach ($availableAttachments as $title => $group) { $selectHTML .= '<optgroup label="' . $title . '">'; foreach ($group as $key => $name) { $selectHTML .= '<option value="' . $key . '">' . $name . '</option>'; } $selectHTML .= '</optgroup>'; } $selectHTML .= '</select>'; $configuration = array('html' => '<a href="#" class="attachmentsConfigLink" data-type="external" title="like PDFMaker/SQLReports">use external Module to generate File</a> <div class="attachmentsConfig" data-type="external" id="attachFromExternalModuleContainer" style="display: none;">' . $selectHTML . ' </div> ', 'script' => "\nAttachments.registerCallback('external', function() {\n jQuery('#urlAttachmentContainer').hide();\n\n var value = jQuery('#attachFromExternalModuleValue').val();\n var title = jQuery('#attachFromExternalModuleValue option:selected').text();\n\n return [\n {\n 'id' : 's#external#' + value,\n 'label' : title,\n 'filename' : '',\n 'options' : {\n 'val' : value\n }\n }\n ];\n});"); $return = array($configuration); return $return; }
public function getConfigurations($moduleName) { $availableAttachments = \Workflow\InterfaceFiles::getAvailableFiles($moduleName); $selectHTML = '<select id="attachFromExternalModuleValue" name="attachFromExternalModuleValue" class="select2" style="width:300px;">'; foreach ($availableAttachments as $title => $group) { $selectHTML .= '<optgroup label="' . $title . '">'; foreach ($group as $key => $name) { $selectHTML .= '<option value="' . $key . '">' . $name . '</option>'; } $selectHTML .= '</optgroup>'; } $selectHTML .= '</select>'; $configuration = array('html' => '<a href="#" onclick="attachFromExternalModuleStart();" title="like PDFMaker/SQLReports">use external Module to generate File</a> <div id="attachFromExternalModuleContainer" style="display: none;">' . $selectHTML . ' <br/><button type="button" class="btn btn-primary" onclick="attachFromExternalModuleFinish();">add</button><input type="button" class="btn btn-warning" onclick="jQuery(\'#attachFromExternalModuleContainer\').hide();" value="Cancel"> </div> ', 'script' => "\n function attachFromExternalModuleStart() {\n jQuery('#attachFromExternalModuleContainer').show();\n }\n function attachFromExternalModuleFinish() {\n var value = jQuery('#attachFromExternalModuleValue').val();\n var title = jQuery('#attachFromExternalModuleValue option:selected').text();\n\n Attachments.addAttachment('s#external#' + value, title, '',{val: value});\n jQuery('#attachFromExternalModuleContainer').hide();\n } "); $return = array($configuration); return $return; }
public function beforeGetTaskform($viewer) { global $adb; $connected = $this->getConnectedObjects("Absender"); if (count($connected) > 0) { $viewer->assign("from", array("from_mail" => $connected[0]->get("email1"), "from_name" => trim($connected[0]->get("first_name") . " " . $connected[0]->get("last_name")), "from_readonly" => true)); } // $smtpServer = \Workflow\ConnectionProvider::getAvailableConfigurations('smtp'); // var_dump($smtpServer);exit(); $connected = $this->getConnectedObjects("BCC"); $bccs = $connected->get("email1"); $viewer->assign("bccs", $bccs); $from_email = $this->get("from_mail"); if ($from_email === -1) { global $current_user; $from_email = $current_user->column_fields["email1"]; $from_name = $current_user->column_fields["first_name"] . " " . $current_user->column_fields["last_name"]; $this->set("from_mail", $from_email); $this->set("from_name", $from_name); } $availableSpecialAttachments = \Workflow\Attachment::getAvailableOptions($this->getModuleName()); $attachmentHTML = array(); $attachmentJAVASCRIPT = array(); foreach ($availableSpecialAttachments as $item) { $attachmentHTML[] = '<div>' . $item['html'] . '</div>'; $attachmentJAVASCRIPT[] = !empty($item['script']) ? $item['script'] : ''; } // implode the array to one string $viewer->assign('attachmentsHTML', implode("\n", $attachmentHTML)); // transmit array to create single script tags $viewer->assign('attachmentsJAVASCRIPT', $attachmentJAVASCRIPT); if (vtlib_isModuleActive('Emails')) { $availableAttachments = \Workflow\InterfaceFiles::getAvailableFiles($this->getModuleName()); } else { throw new \Exception('To use this task, you need to activate the "Emails" module.'); } $jsList = array(); foreach ($availableAttachments as $title => $group) { foreach ($group as $index => $value) { $jsList[$index] = $value; } } $viewer->assign("jsAttachmentsList", $jsList); $viewer->assign("available_attachments", $availableAttachments); if ($this->get("attachments") == -1) { $this->set("attachments", '{}'); } if ($this->get("attachments") == "") { $this->set("attachments", '{}'); } $sql = "SELECT * FROM vtiger_emailtemplates WHERE deleted = 0"; $result = $adb->query($sql); $mailtemplates = array(); while ($row = $adb->fetchByAssoc($result)) { $mailtemplates['Email Templates'][$row["templateid"]] = $row["templatename"]; } if (vtlib_isModuleActive('EMAILMaker') && class_exists('EMAILMaker_Module_Model')) { $emailmaker = new \EMAILMaker_Module_Model(); if (method_exists($emailmaker, 'GetAvailableTemplates')) { $templates = $emailmaker->GetAvailableTemplates($this->getModuleName()); foreach ($templates as $categoryTitle => $category) { if (!is_array($category)) { $mailtemplates['EMAILMaker']['s#emailmaker#' . $categoryTitle] = $category; } else { foreach ($category as $templateid => $template) { $mailtemplates['EMAILMaker ' . $categoryTitle]['s#emailmaker#' . $templateid] = $template; } } } } } $viewer->assign("MAIL_TEMPLATES", $mailtemplates); $viewer->assign("fields", \VtUtils::getFieldsWithBlocksForModule($this->getModuleName(), true)); if (defined("WF_DEMO_MODE") && constant("WF_DEMO_MODE") == true) { echo "<p style='text-align:center;margin:0;padding:5px 0;background-color:#fbcb09;font-weight:bold;'>The sendmail Task won't work on demo.stefanwarnat.de</p>"; } }