/** * List available tokens for this form. * * @return array */ public function listTokens() { $tokens = CRM_Core_SelectValues::contactTokens(); foreach ($this->_caseIds as $key => $caseId) { $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseId, 'case_type_id'); $tokens += CRM_Core_SelectValues::caseTokens($caseTypeId); } return $tokens; }
/** * Build the form object. */ public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); $this->addFormRule(array('CRM_Admin_Form_Preferences_Address', 'formRule')); //get the tokens for Mailing Label field $tokens = CRM_Core_SelectValues::contactTokens(); $this->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens)); parent::buildQuickForm(); }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel')))); return; } $config = CRM_Core_Config::singleton(); $resources = CRM_Core_Resources::singleton(); $resources->addSetting(array('kcfinderPath' => $config->userFrameworkResourceURL . 'packages' . DIRECTORY_SEPARATOR)); $resources->addScriptFile('civicrm', 'templates/CRM/Badge/Form/Layout.js'); $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'), true); $labelStyle = CRM_Core_BAO_LabelFormat::getList(TRUE, 'name_badge'); $this->add('select', 'label_format_name', ts('Label Format'), array('' => ts('- select -')) + $labelStyle, TRUE); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title')); // get the tokens $contactTokens = CRM_Core_SelectValues::contactTokens(); $eventTokens = array('{event.event_id}' => ts('Event ID'), '{event.title}' => ts('Event Title'), '{event.start_date}' => ts('Event Start Date'), '{event.end_date}' => ts('Event End Date')); $participantTokens = CRM_Core_SelectValues::participantTokens(); $tokens = array_merge($contactTokens, $eventTokens, $participantTokens); asort($tokens); $tokens = array_merge(array('spacer' => ts('- spacer -')) + $tokens); $fontSizes = CRM_Core_BAO_LabelFormat::getFontSizes(); $fontStyles = CRM_Core_BAO_LabelFormat::getFontStyles(); $fontNames = CRM_Core_BAO_LabelFormat::getFontNames('name_badge'); $textAlignment = CRM_Core_BAO_LabelFormat::getTextAlignments(); $rowCount = self::FIELD_ROWCOUNT; for ($i = 1; $i <= $rowCount; $i++) { $this->add('select', "token[{$i}]", ts('Token'), array('' => ts('- skip -')) + $tokens); $this->add('select', "font_name[{$i}]", ts('Font Name'), $fontNames); $this->add('select', "font_size[{$i}]", ts('Font Size'), $fontSizes); $this->add('select', "font_style[{$i}]", ts('Font Style'), $fontStyles); $this->add('select', "text_alignment[{$i}]", ts('Alignment'), $textAlignment); } $rowCount++; $this->assign('rowCount', $rowCount); $barcodeTypes = CRM_Core_SelectValues::getBarcodeTypes(); $this->add('checkbox', 'add_barcode', ts('Barcode?')); $this->add('select', "barcode_type", ts('Type'), $barcodeTypes); $this->add('select', "barcode_alignment", ts('Alignment'), $textAlignment); $attributes = array('readonly' => true); $this->add('text', 'image_1', ts('Image (top left)'), $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title')); $this->add('text', 'width_image_1', ts('Width (mm)'), array('size' => 6)); $this->add('text', 'height_image_1', ts('Height (mm)'), array('size' => 6)); $this->add('text', 'image_2', ts('Image (top right)'), $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title')); $this->add('text', 'width_image_2', ts('Width (mm)'), array('size' => 6)); $this->add('text', 'height_image_2', ts('Height (mm)'), array('size' => 6)); $this->add('checkbox', 'is_default', ts('Default?')); $this->add('checkbox', 'is_active', ts('Enabled?')); $this->add('checkbox', 'is_reserved', ts('Reserved?')); $this->addRule('width_image_1', ts('Enter valid width'), 'positiveInteger'); $this->addRule('width_image_2', ts('Enter valid width'), 'positiveInteger'); $this->addRule('height_image_1', ts('Enter valid height'), 'positiveInteger'); $this->addRule('height_image_2', ts('Enter valid height'), 'positiveInteger'); $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'refresh', 'name' => ts('Save and Preview')), array('type' => 'cancel', 'name' => ts('Cancel')))); }
/** * Function to build the form * * @return void * @access public */ public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); // Address Standardization $addrProviders = CRM_Core_SelectValues::addressProvider(); $this->addElement('select', 'address_standardization_provider', ts('Address Provider'), array('' => '- select -') + $addrProviders); $this->addFormRule(array('CRM_Admin_Form_Preferences_Address', 'formRule')); //get the tokens for Mailing Label field $tokens = CRM_Core_SelectValues::contactTokens(); natcasesort($tokens); $this->assign('tokens', json_encode($tokens)); $this->add('select', 'token1', ts('Insert Token'), $tokens, FALSE, array('size' => "5", 'multiple' => TRUE, 'onclick' => "return tokenReplText(this);")); parent::buildQuickForm(); }
function preProcess() { //get all preProcessCommon Values self::preProcessCommon($this); $token = CRM_Core_SelectValues::contactTokens(); //Membership Tokens if ($this->_searchFrom == 'member') { $token = $token + CRM_Core_SelectValues::membershipTokens(); } $tokenMerge = array(); foreach ($token as $key => $label) { $tokenMerge[] = array('id' => $key, 'text' => $label); } //construct array to manage token name and label foreach ($tokenMerge as $tmKey => $tmValue) { $tokenFullName = str_replace(array('{', '}'), "", $tmValue['id']); $explodedTokenName = explode('.', $tokenFullName); $tokenMerge[$tmKey]['token_name'] = $explodedTokenName[0] != 'contact' ? $tokenFullName : $explodedTokenName[1]; if ($explodedTokenName[0] != 'civiqrcode') { if ($explodedTokenName[0] != 'contact') { $tokenMerge[$tmKey]['var_name'] = '[' . self::TOKEN_VAR_NAME . '.' . $tokenFullName . ';block=w:tr]'; $tokenMerge[$tmKey]['var_name_table'] = '[' . self::TOKEN_VAR_NAME . '.' . $tokenFullName . ';block=w:tbl]'; } else { //need to do proper fix seems token named as contact.address_block $explodedTokenName[1] = $explodedTokenName[1] == 'address_block' ? 'contact.' . $explodedTokenName[1] : $explodedTokenName[1]; $tokenMerge[$tmKey]['var_name'] = '[' . self::TOKEN_VAR_NAME . '.' . $explodedTokenName[1] . ';block=w:tr]'; $tokenMerge[$tmKey]['var_name_table'] = '[' . self::TOKEN_VAR_NAME . '.' . $explodedTokenName[1] . ';block=w:tbl]'; } } else { $tokenMerge[$tmKey]['var_name'] = '[' . self::TOKEN_VAR_NAME . '.' . $tokenFullName . ';block=w:image;ope=changepic]'; $tokenMerge[$tmKey]['var_name_table'] = '[' . self::TOKEN_VAR_NAME . '.' . $tokenFullName . ';block=w:image;ope=changepic]'; } $this->_allTokens[$explodedTokenName[0]][] = $explodedTokenName[1]; $this->_returnProperties[$explodedTokenName[1]] = 1; } $this->_tokenMerge = $tokenMerge; $this->assign('availableTokens', $this->_tokenMerge); }
/** * Function to build the form * * @return None * @access public */ public function buildQuickForm() { // For VIEW we only want Done button if ($this->_action & CRM_Core_Action::VIEW) { // currently, the above action is used solely for previewing default workflow templates $cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'); $cancelURL = str_replace('&', '&', $cancelURL); $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"), 'isDefault' => true))); } else { parent::buildQuickForm(); } if ($this->_action & CRM_Core_Action::DELETE) { return; } require_once 'CRM/Utils/System.php'; $breadCrumb = array(array('title' => ts('Message Templates'), 'url' => CRM_Utils_System::url('civicrm/admin/messageTemplates', 'action=browse&reset=1'))); CRM_Utils_System::appendBreadCrumb($breadCrumb); $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'msg_title', ts('Message Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_MessageTemplates', 'msg_title'), true); $this->add('text', 'msg_subject', ts('Message Subject'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_MessageTemplates', 'msg_subject')); //get the tokens. $tokens = CRM_Core_SelectValues::contactTokens(); //sorted in ascending order tokens by ignoring word case natcasesort($tokens); $this->assign('tokens', $tokens); $this->add('select', 'token1', ts('Insert Tokens'), $tokens, false, array('size' => "5", 'multiple' => true, 'onchange' => "return tokenReplText(this);")); $this->add('select', 'token2', ts('Insert Tokens'), $tokens, false, array('size' => "5", 'multiple' => true, 'onchange' => "return tokenReplHtml(this);")); $this->add('select', 'token3', ts('Insert Tokens'), $tokens, false, array('size' => "5", 'multiple' => true, 'onchange' => "return tokenReplText(this);")); $this->add('textarea', 'msg_text', ts('Text Message'), "cols=50 rows=6"); $this->add('textarea', 'msg_html', ts('HTML Message'), "cols=50 rows=6"); $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); CRM_Utils_System::setTitle(ts('View System Default Message Template')); } }
/** * List available tokens for this form. * * @return array */ public function listTokens() { $tokens = CRM_Core_SelectValues::contactTokens(); return $tokens; }
public static function updatePledgeStatus($params) { $returnMessages = array(); $sendReminders = CRM_Utils_Array::value('send_reminders', $params, FALSE); $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); //unset statues that we never use for pledges foreach (array('Completed', 'Cancelled', 'Failed') as $statusKey) { if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) { unset($allStatus[$key]); } } $statusIds = implode(',', array_keys($allStatus)); $updateCnt = 0; $query = "\nSELECT pledge.contact_id as contact_id,\n pledge.id as pledge_id,\n pledge.amount as amount,\n payment.scheduled_date as scheduled_date,\n pledge.create_date as create_date,\n payment.id as payment_id,\n pledge.currency as currency,\n pledge.contribution_page_id as contribution_page_id,\n payment.reminder_count as reminder_count,\n pledge.max_reminders as max_reminders,\n payment.reminder_date as reminder_date,\n pledge.initial_reminder_day as initial_reminder_day,\n pledge.additional_reminder_day as additional_reminder_day,\n pledge.status_id as pledge_status,\n payment.status_id as payment_status,\n pledge.is_test as is_test,\n pledge.campaign_id as campaign_id,\n SUM(payment.scheduled_amount) as amount_due,\n ( SELECT sum(civicrm_pledge_payment.actual_amount)\n FROM civicrm_pledge_payment\n WHERE civicrm_pledge_payment.status_id = 1\n AND civicrm_pledge_payment.pledge_id = pledge.id\n ) as amount_paid\n FROM civicrm_pledge pledge, civicrm_pledge_payment payment\n WHERE pledge.id = payment.pledge_id\n AND payment.status_id IN ( {$statusIds} ) AND pledge.status_id IN ( {$statusIds} )\n GROUP By payment.id\n "; $dao = CRM_Core_DAO::executeQuery($query); $now = date('Ymd'); $pledgeDetails = $contactIds = $pledgePayments = $pledgeStatus = array(); while ($dao->fetch()) { $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($dao->contact_id); $pledgeDetails[$dao->payment_id] = array('scheduled_date' => $dao->scheduled_date, 'amount_due' => $dao->amount_due, 'amount' => $dao->amount, 'amount_paid' => $dao->amount_paid, 'create_date' => $dao->create_date, 'contact_id' => $dao->contact_id, 'pledge_id' => $dao->pledge_id, 'checksumValue' => $checksumValue, 'contribution_page_id' => $dao->contribution_page_id, 'reminder_count' => $dao->reminder_count, 'max_reminders' => $dao->max_reminders, 'reminder_date' => $dao->reminder_date, 'initial_reminder_day' => $dao->initial_reminder_day, 'additional_reminder_day' => $dao->additional_reminder_day, 'pledge_status' => $dao->pledge_status, 'payment_status' => $dao->payment_status, 'is_test' => $dao->is_test, 'currency' => $dao->currency, 'campaign_id' => $dao->campaign_id); $contactIds[$dao->contact_id] = $dao->contact_id; $pledgeStatus[$dao->pledge_id] = $dao->pledge_status; if (CRM_Utils_Date::overdue(CRM_Utils_Date::customFormat($dao->scheduled_date, '%Y%m%d'), $now) && $dao->payment_status != array_search('Overdue', $allStatus)) { $pledgePayments[$dao->pledge_id][$dao->payment_id] = $dao->payment_id; } } // process the updating script... foreach ($pledgePayments as $pledgeId => $paymentIds) { // 1. update the pledge /pledge payment status. returns new status when an update happens $returnMessages[] = "Checking if status update is needed for Pledge Id: {$pledgeId} (current status is {$allStatus[$pledgeStatus[$pledgeId]]})"; $newStatus = CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, $paymentIds, array_search('Overdue', $allStatus), NULL, 0, FALSE, TRUE); if ($newStatus != $pledgeStatus[$pledgeId]) { $returnMessages[] = "- status updated to: {$allStatus[$newStatus]}"; $updateCnt += 1; } } if ($sendReminders) { // retrieve domain tokens $domain = CRM_Core_BAO_Domain::getDomain(); $tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens()); $domainValues = array(); foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } //get the domain email address, since we don't carry w/ object. $domainValue = CRM_Core_BAO_Domain::getNameAndEmail(); $domainValues['email'] = $domainValue[1]; // retrieve contact tokens // this function does NOT return Deceased contacts since we don't want to send them email list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, $tokens, 'CRM_UpdatePledgeRecord'); // assign domain values to template $template = CRM_Core_Smarty::singleton(); $template->assign('domain', $domainValues); //set receipt from $receiptFrom = '"' . $domainValues['name'] . '" <' . $domainValues['email'] . '>'; foreach ($pledgeDetails as $paymentId => $details) { if (array_key_exists($details['contact_id'], $contactDetails)) { $contactId = $details['contact_id']; $pledgerName = $contactDetails[$contactId]['display_name']; } else { continue; } if (empty($details['reminder_date'])) { $nextReminderDate = new DateTime($details['scheduled_date']); $nextReminderDate->modify("-" . $details['initial_reminder_day'] . "day"); $nextReminderDate = $nextReminderDate->format("Ymd"); } else { $nextReminderDate = new DateTime($details['reminder_date']); $nextReminderDate->modify("+" . $details['additional_reminder_day'] . "day"); $nextReminderDate = $nextReminderDate->format("Ymd"); } if ($details['reminder_count'] < $details['max_reminders'] && $nextReminderDate <= $now) { $toEmail = $doNotEmail = $onHold = NULL; if (!empty($contactDetails[$contactId]['email'])) { $toEmail = $contactDetails[$contactId]['email']; } if (!empty($contactDetails[$contactId]['do_not_email'])) { $doNotEmail = $contactDetails[$contactId]['do_not_email']; } if (!empty($contactDetails[$contactId]['on_hold'])) { $onHold = $contactDetails[$contactId]['on_hold']; } // 2. send acknowledgement mail if ($toEmail && !($doNotEmail || $onHold)) { //assign value to template $template->assign('amount_paid', $details['amount_paid'] ? $details['amount_paid'] : 0); $template->assign('contact', $contactDetails[$contactId]); $template->assign('next_payment', $details['scheduled_date']); $template->assign('amount_due', $details['amount_due']); $template->assign('checksumValue', $details['checksumValue']); $template->assign('contribution_page_id', $details['contribution_page_id']); $template->assign('pledge_id', $details['pledge_id']); $template->assign('scheduled_payment_date', $details['scheduled_date']); $template->assign('amount', $details['amount']); $template->assign('create_date', $details['create_date']); $template->assign('currency', $details['currency']); list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate(array('groupName' => 'msg_tpl_workflow_pledge', 'valueName' => 'pledge_reminder', 'contactId' => $contactId, 'from' => $receiptFrom, 'toName' => $pledgerName, 'toEmail' => $toEmail)); // 3. update pledge payment details if ($mailSent) { CRM_Pledge_BAO_PledgePayment::updateReminderDetails($paymentId); $activityType = 'Pledge Reminder'; $activityParams = array('subject' => $subject, 'source_contact_id' => $contactId, 'source_record_id' => $paymentId, 'assignee_contact_id' => $contactId, 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'activity_date_time' => CRM_Utils_Date::isoToMysql($now), 'due_date_time' => CRM_Utils_Date::isoToMysql($details['scheduled_date']), 'is_test' => $details['is_test'], 'status_id' => 2, 'campaign_id' => $details['campaign_id']); if (is_a(civicrm_api('activity', 'create', $activityParams), 'CRM_Core_Error')) { $returnMessages[] = "Failed creating Activity for acknowledgment"; return array('is_error' => 1, 'message' => $returnMessages); } $returnMessages[] = "Payment reminder sent to: {$pledgerName} - {$toEmail}"; } } } } // end foreach on $pledgeDetails } // end if ( $sendReminders ) $returnMessages[] = "{$updateCnt} records updated."; return array('is_error' => 0, 'messages' => implode("\n\r", $returnMessages)); }
/** * List available tokens for this form. * * @return array */ public function listTokens() { $tokens = CRM_Core_SelectValues::contactTokens(); $tokens = array_merge(CRM_Core_SelectValues::activityTokens(), $tokens); $tokens = array_merge(CRM_Core_SelectValues::eventTokens(), $tokens); $tokens = array_merge(CRM_Core_SelectValues::membershipTokens(), $tokens); $tokens = array_merge(CRM_Core_SelectValues::contributionTokens(), $tokens); return $tokens; }
/** * Cancel this participant and finish, send cancellation email. At this point no * auto-cancellation of payment is handled, so payment needs to be manually cancelled * * return @void */ public function cancelParticipant($params) { //set participant record status to Cancelled, refund payment if possible // send email to participant and admin, and log Activity $value = array(); $value['id'] = $this->_participant_id; $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")); $value['status_id'] = $cancelledId; CRM_Event_BAO_Participant::create($value); $domainValues = array(); $domain = CRM_Core_BAO_Domain::getDomain(); $tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens()); foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } $participantRoles = array(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $participantDetails = array(); $query = "SELECT * FROM civicrm_participant WHERE id = {$this->_participant_id}"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $participantDetails[$dao->id] = array('id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, 'fee_amount' => $dao->fee_amount, 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id); } $eventDetails = array(); $eventParams = array('id' => $this->_event_id); CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$this->_event_id]); //get default participant role. $eventDetails[$this->_event_id]['participant_role'] = CRM_Utils_Array::value($eventDetails[$this->_event_id]['default_role_id'], $participantRoles); //get the location info $locParams = array('entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event'); $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); //get contact details $contactIds[$this->_contact_id] = $this->_contact_id; list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant'); foreach ($currentContactDetails as $contactId => $contactValues) { $contactDetails[$this->_contact_id] = $contactValues; } //send a 'cancelled' email to user, and cc the event's cc_confirm email $mail = CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_participant_id, $participantDetails[$this->_participant_id], $eventDetails[$this->_event_id], $contactDetails[$this->_contact_id], $domainValues, "Cancelled", ""); $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name)); $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email)); CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success'); $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$this->_event_id}&noFullMsg=true"); CRM_Utils_System::redirect($url); }
/** * List available tokens for this form. * * @return array */ public function listTokens() { $tokens = CRM_Core_SelectValues::contactTokens(); $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens); return $tokens; }
/** * Function to build the compose PDF letter form * * @param $form * * @return None * @access public */ public static function commonLetterCompose(&$form) { //get the tokens. $tokens = CRM_Core_SelectValues::contactTokens(); if (CRM_Utils_System::getClassName($form) == 'CRM_Mailing_Form_Upload') { $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens); } //@todo move this fn onto the form if (CRM_Utils_System::getClassName($form) == 'CRM_Contribute_Form_Task_PDFLetter') { $tokens = array_merge(CRM_Core_SelectValues::contributionTokens(), $tokens); } if (method_exists($form, 'listTokens')) { $tokens = array_merge($form->listTokens(), $tokens); } //sorted in ascending order tokens by ignoring word case natcasesort($tokens); $form->assign('tokens', json_encode($tokens)); $form->add('select', 'token1', ts('Insert Tokens'), $tokens, FALSE, array('size' => "5", 'multiple' => TRUE, 'onchange' => "return tokenReplHtml(this);")); $form->_templates = CRM_Core_BAO_MessageTemplate::getMessageTemplates(FALSE); if (!empty($form->_templates)) { $form->assign('templates', TRUE); $form->add('select', 'template', ts('Select Template'), array('' => ts('- select -')) + $form->_templates, FALSE, array('onChange' => "selectValue( this.value );")); $form->add('checkbox', 'updateTemplate', ts('Update Template'), NULL); } $form->add('checkbox', 'saveTemplate', ts('Save As New Template'), NULL, FALSE, array('onclick' => "showSaveDetails(this);")); $form->add('text', 'saveTemplateName', ts('Template Title')); $form->addWysiwyg('html_message', ts('Your Letter'), array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)")); $action = CRM_Utils_Request::retrieve('action', 'String', $form, FALSE); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Task_PDF' && $action == CRM_Core_Action::VIEW) { $form->freeze('html_message'); } }
/** * Build the compose mail form. * * @param CRM_Core_Form $form * * @return void */ public static function commonCompose(&$form) { //get the tokens. $tokens = CRM_Core_SelectValues::contactTokens(); $className = CRM_Utils_System::getClassName($form); if ($className == 'CRM_Mailing_Form_Upload') { $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens); } elseif ($className == 'CRM_Admin_Form_ScheduleReminders') { $tokens = array_merge(CRM_Core_SelectValues::activityTokens(), $tokens); $tokens = array_merge(CRM_Core_SelectValues::eventTokens(), $tokens); $tokens = array_merge(CRM_Core_SelectValues::membershipTokens(), $tokens); } elseif ($className == 'CRM_Event_Form_ManageEvent_ScheduleReminders') { $tokens = array_merge(CRM_Core_SelectValues::eventTokens(), $tokens); } //TODO standardize on this method if (method_exists($form, 'listTokens')) { $tokens = array_merge($form->listTokens(), $tokens); } //sorted in ascending order tokens by ignoring word case $form->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens)); $templates = array(); $textFields = array('text_message' => ts('HTML Format'), 'sms_text_message' => ts('SMS Message')); $modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS'); if ($className != 'CRM_SMS_Form_Upload' && $className != 'CRM_Contact_Form_Task_SMS' && $className != 'CRM_Contact_Form_Task_SMS') { $form->add('wysiwyg', 'html_message', ts('HTML Format'), array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)")); if ($className != 'CRM_Admin_Form_ScheduleReminders') { unset($modePrefixes['SMS']); } } else { unset($textFields['text_message']); unset($modePrefixes['Mail']); } //insert message Text by selecting "Select Template option" foreach ($textFields as $id => $label) { $prefix = NULL; if ($id == 'sms_text_message') { $prefix = "SMS"; $form->assign('max_sms_length', CRM_SMS_Provider::MAX_SMS_CHAR); } $form->add('textarea', $id, $label, array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this, '{$prefix}')")); } foreach ($modePrefixes as $prefix) { if ($prefix == 'SMS') { $templates[$prefix] = CRM_Core_BAO_MessageTemplate::getMessageTemplates(FALSE, TRUE); } else { $templates[$prefix] = CRM_Core_BAO_MessageTemplate::getMessageTemplates(FALSE); } if (!empty($templates[$prefix])) { $form->assign('templates', TRUE); $form->add('select', "{$prefix}template", ts('Use Template'), array('' => ts('- select -')) + $templates[$prefix], FALSE, array('onChange' => "selectValue( this.value, '{$prefix}');")); } $form->add('checkbox', "{$prefix}updateTemplate", ts('Update Template'), NULL); $form->add('checkbox', "{$prefix}saveTemplate", ts('Save As New Template'), NULL, FALSE, array('onclick' => "showSaveDetails(this, '{$prefix}');")); $form->add('text', "{$prefix}saveTemplateName", ts('Template Title')); } // I'm not sure this is ever called. $action = CRM_Utils_Request::retrieve('action', 'String', $form, FALSE); if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Task_PDF' && $action == CRM_Core_Action::VIEW) { $form->freeze('html_message'); } }
/** * Send confirmation of cancellation to source participant * * return @ void */ public function sendCancellation() { $domainValues = array(); $domain = CRM_Core_BAO_Domain::getDomain(); $tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens()); foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } $participantRoles = array(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $participantDetails = array(); $query = "SELECT * FROM civicrm_participant WHERE id = {$this->_from_participant_id}"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $participantDetails[$dao->id] = array('id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, 'fee_amount' => $dao->fee_amount, 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id); } $eventDetails = array(); $eventParams = array('id' => $this->_event_id); CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$this->_event_id]); //get default participant role. $eventDetails[$this->_event_id]['participant_role'] = CRM_Utils_Array::value($eventDetails[$this->_event_id]['default_role_id'], $participantRoles); //get the location info $locParams = array('entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event'); $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); //get contact details $contactIds[$this->_from_contact_id] = $this->_from_contact_id; list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant'); foreach ($currentContactDetails as $contactId => $contactValues) { $contactDetails[$this->_from_contact_id] = $contactValues; } //send a 'cancelled' email to user, and cc the event's cc_confirm email $mail = CRM_Event_BAO_Participant::sendTransitionParticipantMail($this->_from_participant_id, $participantDetails[$this->_from_participant_id], $eventDetails[$this->_event_id], $contactDetails[$this->_from_contact_id], $domainValues, "Transferred", ""); $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name)); $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email)); CRM_Core_Session::setStatus($statusMsg, ts('Thanks'), 'success'); }
/** * Build the form object. * * @return void */ public function buildQuickForm() { // For VIEW we only want Done button if ($this->_action & CRM_Core_Action::VIEW) { // currently, the above action is used solely for previewing default workflow templates $cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'); $cancelURL = str_replace('&', '&', $cancelURL); $this->addButtons(array(array('type' => 'cancel', 'name' => ts('Done'), 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"), 'isDefault' => TRUE))); } else { parent::buildQuickForm(); } if ($this->_action & CRM_Core_Action::DELETE) { return; } $breadCrumb = array(array('title' => ts('Message Templates'), 'url' => CRM_Utils_System::url('civicrm/admin/messageTemplates', 'action=browse&reset=1'))); CRM_Utils_System::appendBreadCrumb($breadCrumb); $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'msg_title', ts('Message Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_MessageTemplate', 'msg_title'), TRUE); $this->add('text', 'msg_subject', ts('Message Subject'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_MessageTemplate', 'msg_subject')); //get the tokens. $tokens = CRM_Core_SelectValues::contactTokens(); $this->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens)); // if not a system message use a wysiwyg editor, CRM-5971 if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_MessageTemplate', $this->_id, 'workflow_id')) { $this->add('textarea', 'msg_html', ts('HTML Message'), "cols=50 rows=6"); } else { $this->addWysiwyg('msg_html', ts('HTML Message'), array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)")); } $this->add('textarea', 'msg_text', ts('Text Message'), "cols=50 rows=6"); $this->add('select', 'pdf_format_id', ts('PDF Page Format'), array('null' => ts('- default -')) + CRM_Core_BAO_PdfFormat::getList(TRUE), FALSE); $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); CRM_Utils_System::setTitle(ts('View System Default Message Template')); } }
/** * Function to send Acknowledgment and create activity. * * @param object $form form object. * @param array $params (reference ) an assoc array of name/value pairs. * @access public * @return None. */ function sendAcknowledgment(&$form, $params) { //handle Acknowledgment. $allPayments = $payments = array(); //get All Payments status types. require_once 'CRM/Contribute/PseudoConstant.php'; $paymentStatusTypes = CRM_Contribute_PseudoConstant::contributionStatus(null, 'name'); $returnProperties = array('status_id', 'scheduled_amount', 'scheduled_date', 'contribution_id'); //get all paymnets details. CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_Payment', 'pledge_id', $params['id'], $allPayments, $returnProperties); if (!empty($allPayments)) { foreach ($allPayments as $payID => $values) { $contributionValue = $contributionStatus = array(); if (isset($values['contribution_id'])) { $contributionParams = array('id' => $values['contribution_id']); $returnProperties = array('contribution_status_id', 'receive_date'); CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_Contribution', $contributionParams, $contributionStatus, $returnProperties); $contributionValue = array('status' => CRM_Utils_Array::value('contribution_status_id', $contributionStatus), 'receive_date' => CRM_Utils_Array::value('receive_date', $contributionStatus)); } $payments[$payID] = array_merge($contributionValue, array('amount' => CRM_Utils_Array::value('scheduled_amount', $values), 'due_date' => CRM_Utils_Array::value('scheduled_date', $values))); //get the first valid payment id. if (!$form->paymentId && ($paymentStatusTypes[$values['status_id']] == 'Pending' || $paymentStatusTypes[$values['status_id']] == 'Overdue')) { $form->paymentId = $values['id']; } } } //end //assign pledge fields value to template. $pledgeFields = array('create_date', 'total_pledge_amount', 'frequency_interval', 'frequency_unit', 'installments', 'frequency_day', 'scheduled_amount'); foreach ($pledgeFields as $field) { if (CRM_Utils_Array::value($field, $params)) { $form->assign($field, $params[$field]); } } //assign all payments details. if ($payments) { $form->assign('payments', $payments); } //assign honor fields. $honor_block_is_active = false; //make sure we have values for it if (CRM_Utils_Array::value('honor_type_id', $params) && (!empty($params["honor_first_name"]) && !empty($params["honor_last_name"]) || !empty($params["honor_email"]))) { $honor_block_is_active = true; require_once "CRM/Core/PseudoConstant.php"; $prefix = CRM_Core_PseudoConstant::individualPrefix(); $honor = CRM_Core_PseudoConstant::honor(); $form->assign("honor_type", $honor[$params["honor_type_id"]]); $form->assign("honor_prefix", $prefix[$params["honor_prefix_id"]]); $form->assign("honor_first_name", $params["honor_first_name"]); $form->assign("honor_last_name", $params["honor_last_name"]); $form->assign("honor_email", $params["honor_email"]); } $form->assign('honor_block_is_active', $honor_block_is_active); //handle domain token values require_once 'CRM/Core/BAO/Domain.php'; $domain =& CRM_Core_BAO_Domain::getDomain(); $tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens()); require_once 'CRM/Utils/Token.php'; $domainValues = array(); foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } $form->assign('domain', $domainValues); //handle contact token values. require_once 'CRM/Contact/BAO/Contact.php'; require_once 'CRM/Mailing/BAO/Mailing.php'; $ids = array($params['contact_id']); $fields = array_merge(array_keys(CRM_Contact_BAO_Contact::importableFields()), array('display_name', 'checksum', 'contact_id')); foreach ($fields as $key => $val) { $returnProperties[$val] = true; } $details = CRM_Mailing_BAO_Mailing::getDetails($ids, $returnProperties); $form->assign('contact', $details[0][$params['contact_id']]); //handle custom data. if (CRM_Utils_Array::value('hidden_custom', $params)) { require_once 'CRM/Core/BAO/CustomGroup.php'; $groupTree =& CRM_Core_BAO_CustomGroup::getTree('Pledge', CRM_Core_DAO::$_nullObject, $params['id']); $pledgeParams = array(array('pledge_id', '=', $params['id'], 0, 0)); $customGroup = array(); // retrieve custom data require_once "CRM/Core/BAO/UFGroup.php"; foreach ($groupTree as $groupID => $group) { $customFields = $customValues = array(); if ($groupID == 'info') { continue; } foreach ($group['fields'] as $k => $field) { $field['title'] = $field['label']; $customFields["custom_{$k}"] = $field; } //to build array of customgroup & customfields in it CRM_Core_BAO_UFGroup::getValues($params['contact_id'], $customFields, $customValues, false, $pledgeParams); $customGroup[$group['title']] = $customValues; } $form->assign('customGroup', $customGroup); } //handle acknowledgment email stuff. require_once 'CRM/Contact/BAO/Contact.php'; require_once 'CRM/Contact/BAO/Contact/Location.php'; list($pledgerDisplayName, $pledgerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($params['contact_id']); //check for online pledge. $session = CRM_Core_Session::singleton(); if (CRM_Utils_Array::value('receipt_from_email', $params)) { $userName = CRM_Utils_Array::value('receipt_from_name', $params); $userEmail = CRM_Utils_Array::value('receipt_from_email', $params); } else { if ($userID = $session->get('userID')) { //check for loged in user. list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID); } else { //set the domain values. $userName = CRM_Utils_Array::value('name', $domainValues); $userEmail = CRM_Utils_Array::value('email', $domainValues); } } $receiptFrom = "{$userName} <{$userEmail}>"; require_once 'CRM/Core/BAO/MessageTemplates.php'; list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplates::sendTemplate(array('groupName' => 'msg_tpl_workflow_pledge', 'valueName' => 'pledge_acknowledge', 'contactId' => $params['contact_id'], 'from' => $receiptFrom, 'toName' => $pledgerDisplayName, 'toEmail' => $pledgerEmail)); //check if activity record exist for this pledge //Acknowledgment, if exist do not add activity. require_once "CRM/Activity/DAO/Activity.php"; $activityType = 'Pledge Acknowledgment'; $activity = new CRM_Activity_DAO_Activity(); $activity->source_record_id = $params['id']; $activity->activity_type_id = CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'); $config = CRM_Core_Config::singleton(); $money = $config->defaultCurrencySymbol; $details = 'Total Amount ' . $money . $params['total_pledge_amount'] . ' To be paid in ' . $params['installments'] . ' installments of ' . $money . $params['scheduled_amount'] . ' every ' . $params['frequency_interval'] . ' ' . $params['frequency_unit'] . '(s)'; if (!$activity->find()) { $activityParams = array('subject' => $subject, 'source_contact_id' => $params['contact_id'], 'source_record_id' => $params['id'], 'activity_type_id' => CRM_Core_OptionGroup::getValue('activity_type', $activityType, 'name'), 'activity_date_time' => CRM_Utils_Date::isoToMysql($params['acknowledge_date']), 'is_test' => $params['is_test'], 'status_id' => 2, 'details' => $details); require_once 'api/v2/Activity.php'; if (is_a(civicrm_activity_create($activityParams), 'CRM_Core_Error')) { CRM_Core_Error::fatal("Failed creating Activity for acknowledgment"); } } }
/** * Function takes participant ids and statuses * update status from $fromStatusId to $toStatusId * and send mail + create activities. * * @param array $participantIds * Participant ids. * @param int $toStatusId * Update status id. * @param int $fromStatusId * From status id. * @param bool $returnResult * @param bool $skipCascadeRule * * @return array|NULL */ public static function transitionParticipants($participantIds, $toStatusId, $fromStatusId = NULL, $returnResult = FALSE, $skipCascadeRule = FALSE) { if (!is_array($participantIds) || empty($participantIds) || !$toStatusId) { return NULL; } //thumb rule is if we triggering primary participant need to triggered additional $allParticipantIds = $primaryANDAdditonalIds = array(); foreach ($participantIds as $id) { $allParticipantIds[] = $id; if (self::isPrimaryParticipant($id)) { //filter additional as per status transition rules, CRM-5403 if ($skipCascadeRule) { $additionalIds = self::getAdditionalParticipantIds($id); } else { $additionalIds = self::getValidAdditionalIds($id, $fromStatusId, $toStatusId); } if (!empty($additionalIds)) { $allParticipantIds = array_merge($allParticipantIds, $additionalIds); $primaryANDAdditonalIds[$id] = $additionalIds; } } } //get the unique participant ids, $allParticipantIds = array_unique($allParticipantIds); //pull required participants, contacts, events data, if not in hand static $eventDetails = array(); static $domainValues = array(); static $contactDetails = array(); $contactIds = $eventIds = $participantDetails = array(); $statusTypes = CRM_Event_PseudoConstant::participantStatus(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'"); //first thing is pull all necessory data from db. $participantIdClause = '(' . implode(',', $allParticipantIds) . ')'; //get all participants data. $query = "SELECT * FROM civicrm_participant WHERE id IN {$participantIdClause}"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $participantDetails[$dao->id] = array('id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, 'fee_amount' => $dao->fee_amount, 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id); if (!array_key_exists($dao->contact_id, $contactDetails)) { $contactIds[$dao->contact_id] = $dao->contact_id; } if (!array_key_exists($dao->event_id, $eventDetails)) { $eventIds[$dao->event_id] = $dao->event_id; } } //get the domain values. if (empty($domainValues)) { // making all tokens available to templates. $domain = CRM_Core_BAO_Domain::getDomain(); $tokens = array('domain' => array('name', 'phone', 'address', 'email'), 'contact' => CRM_Core_SelectValues::contactTokens()); foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } } //get all required contacts detail. if (!empty($contactIds)) { // get the contact details. list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant'); foreach ($currentContactDetails as $contactId => $contactValues) { $contactDetails[$contactId] = $contactValues; } } //get all required events detail. if (!empty($eventIds)) { foreach ($eventIds as $eventId) { //retrieve event information $eventParams = array('id' => $eventId); CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$eventId]); //get default participant role. $eventDetails[$eventId]['participant_role'] = CRM_Utils_Array::value($eventDetails[$eventId]['default_role_id'], $participantRoles); //get the location info $locParams = array('entity_id' => $eventId, 'entity_table' => 'civicrm_event'); $eventDetails[$eventId]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); } } //now we are ready w/ all required data. //take a decision as per statuses. $emailType = NULL; $toStatus = $statusTypes[$toStatusId]; $fromStatus = CRM_Utils_Array::value($fromStatusId, $statusTypes); switch ($toStatus) { case 'Pending from waitlist': case 'Pending from approval': switch ($fromStatus) { case 'On waitlist': case 'Awaiting approval': $emailType = 'Confirm'; break; } break; case 'Expired': //no matter from where u come send expired mail. $emailType = $toStatus; break; case 'Cancelled': //no matter from where u come send cancel mail. $emailType = $toStatus; break; } //as we process additional w/ primary, there might be case if user //select primary as well as additionals, so avoid double processing. $processedParticipantIds = array(); $mailedParticipants = array(); //send mails and update status. foreach ($participantDetails as $participantId => $participantValues) { $updateParticipantIds = array(); if (in_array($participantId, $processedParticipantIds)) { continue; } //check is it primary and has additional. if (array_key_exists($participantId, $primaryANDAdditonalIds)) { foreach ($primaryANDAdditonalIds[$participantId] as $additonalId) { if ($emailType) { $mail = self::sendTransitionParticipantMail($additonalId, $participantDetails[$additonalId], $eventDetails[$participantDetails[$additonalId]['event_id']], $contactDetails[$participantDetails[$additonalId]['contact_id']], $domainValues, $emailType); //get the mail participant ids if ($mail) { $mailedParticipants[$additonalId] = $contactDetails[$participantDetails[$additonalId]['contact_id']]['display_name']; } } $updateParticipantIds[] = $additonalId; $processedParticipantIds[] = $additonalId; } } //now send email appropriate mail to primary. if ($emailType) { $mail = self::sendTransitionParticipantMail($participantId, $participantValues, $eventDetails[$participantValues['event_id']], $contactDetails[$participantValues['contact_id']], $domainValues, $emailType); //get the mail participant ids if ($mail) { $mailedParticipants[$participantId] = $contactDetails[$participantValues['contact_id']]['display_name']; } } //now update status of group/one at once. $updateParticipantIds[] = $participantId; //update the register date only when we, //move participant to pending class, CRM-6496 $updateRegisterDate = FALSE; if (array_key_exists($toStatusId, $pendingStatuses)) { $updateRegisterDate = TRUE; } self::updateStatus($updateParticipantIds, $toStatusId, $updateRegisterDate); $processedParticipantIds[] = $participantId; } //return result for cron. if ($returnResult) { $results = array('mailedParticipants' => $mailedParticipants, 'updatedParticipantIds' => $processedParticipantIds); return $results; } }
/** * Function to build the compose PDF letter form * @param $form * @return None * @access public */ public function commonLetterCompose(&$form) { //get the tokens. $tokens = CRM_Core_SelectValues::contactTokens(); if (CRM_Utils_System::getClassName($form) == 'CRM_Mailing_Form_Upload') { $tokens = array_merge(CRM_Core_SelectValues::mailingTokens(), $tokens); } //sorted in ascending order tokens by ignoring word case natcasesort($tokens); $form->assign('tokens', $tokens); $form->add('select', 'token1', ts('Insert Tokens'), $tokens, false, array('size' => "5", 'multiple' => true, 'onchange' => "return tokenReplHtml(this);")); require_once 'CRM/Core/BAO/MessageTemplates.php'; $form->_templates = CRM_Core_BAO_MessageTemplates::getMessageTemplates(); if (!empty($form->_templates)) { $form->assign('templates', true); $form->add('select', 'template', ts('Select Template'), array('' => ts('- select -')) + $form->_templates, false, array('onChange' => "selectValue( this.value );")); $form->add('checkbox', 'updateTemplate', ts('Update Template'), null); } $form->add('checkbox', 'saveTemplate', ts('Save As New Template'), null, false, array('onclick' => "showSaveDetails(this);")); $form->add('text', 'saveTemplateName', ts('Template Title')); $form->addWysiwyg('html_message', ts('HTML Message'), array('cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)")); }