} $mainData = \Workflow\VtUtils::getMainRecordData($relmod, $ids); uasort($mainData, function ($a, $b) { return strcmp($a["number"], $b["number"]); }); $html = ''; $script = ''; $fieldId = 'field_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $data['name']); $field = '<select style="width:410px;" name="' . $data['name'] . '" id="' . $fieldId . '" class="select2" data-placeholder="' . vtranslate('choose Reference', 'Workflow2') . '">'; if (!empty($data['config']['nullable'])) { $field .= '<option value="" selected="selected"><em>- ' . vtranslate('no Selection', 'Workflow2') . '</em></option>'; } if (count($mainData) > 0) { foreach ($mainData as $crmid => $record) { $field .= '<option value="' . $crmid . '" data-url="' . $record['link'] . '">[' . $record['number'] . '] ' . $record['label'] . '</option>'; } } $field .= '</select>'; $html = "<label><div style='min-height:26px;padding:2px 0;'><div style=''><strong>" . $data['label'] . "</strong></div><div style='text-align:right;'>" . $field . "<div style='display:none;margin-top:5px;' id='url_" . $data['name'] . "'></div></div></div></label>"; $script = ''; if (!empty($data['config']['nullable'])) { $script .= 'jQuery("#' . $fieldId . '").select2("val", "");'; } $script .= 'jQuery("#' . $fieldId . '").on("change", function(e) {var selected = jQuery("#' . $fieldId . ' option:selected"); if(selected.val() == "") { jQuery("#url_' . $data['name'] . '").html("");return;}; jQuery("#url_' . $data['name'] . '").show().html("Link: <a href=\'" + selected.data("url") + "\' target=\'_blank\'><strong>" + selected.text() + "</strong></a>"); });'; return array('html' => $html, 'javascript' => $script); } } // The class neeeds to be registered \Workflow\Fieldtype::register('records', '\\Workflow\\Plugins\\Fieldtypes\\Records');
break; case 'text': default: $field = '<input type="text" id="reqfield_' . $data['name'] . '" style="width:400px;" name="' . $data['name'] . '" value="' . $data['config']["default"] . '">'; break; } $html = "<label><div style='min-height:26px;padding:2px 0;'><div style=''><strong>" . $data['label'] . "</strong></div><div style='text-align:right;'>" . $field . "</div></div></label>"; return array('html' => $html, 'javascript' => $script); } /** * @param $value * @param $name * @param $type * @param \Workflow\VTEntity $context * @return \type */ public function getValue($value, $name, $type, $context) { if ($type == 'date') { $value = \DateTimeField::convertToDBFormat($value); } if ($type == 'file') { // var_dump($value, $name, $type, $_FILES, $this); $context->addTempFile($_FILES['fileUpload']['tmp_name'][$name], $value, $_FILES['fileUpload']['name'][$name]); return '1'; } return $value; } } \Workflow\Fieldtype::register('core', '\\Workflow\\Plugins\\Fieldtypes\\Core');
$script = ''; $fieldId = 'field_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $data['name']); $field1 = '<div class="insertReferencefield" style="float:right;" data-name="' . $data['name'] . '][accountid" data-module="Accounts"></div>'; $field2 = '<div class="insertReferencefield" style="float:right;" data-name="' . $data['name'] . '][contactid" data-module="Contacts" data-parentfield="' . $data['name'] . '][accountid"></div>'; $html .= "<label><div style='min-height:26px;padding:2px 0;'><div style=''><strong>" . $data['label'] . "</strong></div><div style='text-align:right;'><div style='overflow:hidden;'><strong>Organization</strong><br/>" . $field1 . "</div><div style='overflow:hidden;'><strong>Contact</strong><br/>" . $field2 . "</div></div></div></label>"; $script = ''; if (!empty($data['config']['nullable'])) { $script .= 'jQuery("#' . $fieldId . '").select2("val", "");'; } $script .= 'jQuery(function() { jQuery("#contactid_contactid_display").attr("readonly", "readonly"); });'; return array('html' => $html, 'javascript' => $script); } /** * @param $value * @param $name * @param $type * @param $context VTEntity * @param $allValues * @param $fieldConfig * @return mixed */ public function getValue($value, $name, $type, $context, $allValues, $fieldConfig) { $orgaField = $fieldConfig['orgaid']; $context->setEnvironment($orgaField, $value['accountid']); return $value['contactid']; } } // The class neeeds to be registered \Workflow\Fieldtype::register('contact', '\\Workflow\\Plugins\\Fieldtypes\\Contact');
$mainData = \Workflow\VtUtils::getMainRecordData($relmod, $records); $fieldId = 'field_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $data['name']); uasort($mainData, function ($a, $b) { return strcmp($a["number"], $b["number"]); }); } $html = ''; $script = ''; $field = '<select style="width:410px;" name="' . $data['name'] . '" id="' . $fieldId . '" class="select2" data-placeholder="' . vtranslate('choose Reference', 'Workflow2') . '">'; if (!empty($data['config']['nullable'])) { $field .= '<option value="" selected="selected"><em>- ' . vtranslate('no Selection', 'Workflow2') . '</em></option>'; } if (count($mainData) > 0) { foreach ($mainData as $crmid => $record) { $field .= '<option value="' . $crmid . '" data-url="' . $record['link'] . '">[' . $record['number'] . '] ' . $record['label'] . '</option>'; } } $field .= '</select>'; $html = "<label><div style='min-height:26px;padding:2px 0;'><div style=''><strong>" . $data['label'] . "</strong></div><div style='text-align:right;'>" . $field . "<div style='display:none;margin-top:5px;' id='url_" . $data['name'] . "'></div></div></div></label>"; $script = ''; if (!empty($data['config']['nullable'])) { $script .= 'jQuery("#' . $fieldId . '").select2("val", "");'; } $script .= 'jQuery("#' . $fieldId . '").on("change", function(e) {var selected = jQuery("#' . $fieldId . ' option:selected"); if(selected.val() == "") { jQuery("#url_' . $data['name'] . '").html("");return;}; jQuery("#url_' . $data['name'] . '").show().html("Link: <a href=\'" + selected.data("url") + "\' target=\'_blank\'><strong>" + selected.text() + "</strong></a>"); });'; return array('html' => $html, 'javascript' => $script); } } // The class neeeds to be registered \Workflow\Fieldtype::register('reference', '\\Workflow\\Plugins\\Fieldtypes\\Reference');