/**
  * Adds elements from the model to the bridge that creates the form.
  *
  * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge
  * @param \MUtil_Model_ModelAbstract $model
  */
 protected function addFormElements(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model)
 {
     $this->mailElements->setForm($bridge->getForm());
     $this->initItems();
     $this->addItems($bridge, 'gct_name');
     $this->addItems($bridge, 'gct_id_template', 'gct_target');
     $this->addItems($bridge, 'gct_code');
     $bridge->getForm()->getElement('gct_target')->setAttrib('onchange', 'this.form.submit()');
     $defaultTab = $this->project->getLocaleDefault();
     $this->mailElements->addFormTabs($bridge, 'gctt', 'active', $defaultTab, 'tabcolumn', 'gctt_lang', 'selectedTabElement', 'send_language');
     $config = array('extraPlugins' => 'bbcode,availablefields', 'toolbar' => array(array('Source', '-', 'Undo', 'Redo'), array('Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'), array('Link', 'Unlink', 'Image', 'SpecialChar'), '/', array('Bold', 'Italic', 'Underline'), array('NumberedList', 'BulletedList', '-', 'Blockquote'), array('Maximize'), array('availablefields')));
     $mailfields = $this->mailer->getMailFields();
     foreach ($mailfields as $field => $value) {
         $mailfields[$field] = utf8_encode($value);
     }
     $config['availablefields'] = $mailfields;
     $config['availablefieldsLabel'] = $this->_('Fields');
     $this->view->inlineScript()->prependScript("\n            CKEditorConfig = " . \Zend_Json::encode($config) . ";\n            ");
     $bridge->addFakeSubmit('preview', array('label' => $this->_('Preview')));
     $bridge->addElement($this->mailElements->createEmailElement('to', $this->_('To (test)'), false));
     $bridge->addElement($this->mailElements->createEmailElement('from', $this->_('From'), false));
     //$bridge->addRadio('send_language', array('label' => $this->_('Test language'), 'multiOptions' => ))
     $bridge->addHidden('send_language');
     $bridge->addFakeSubmit('sendtest', array('label' => $this->_('Send (test)')));
     $bridge->addElement($this->getSaveButton($bridge->getForm()));
     $bridge->addElement($this->mailElements->createPreviewHtmlElement('Preview HTML'));
     $bridge->addElement($this->mailElements->createPreviewTextElement('Preview Text'));
     $bridge->addHtml('available_fields', array('label' => $this->_('Available fields')));
 }
 /**
  * Set those settings needed for the detailed display
  *
  * @return \Gems_Model_RespondentModel
  */
 public function applyDetailSettings()
 {
     $dbLookup = $this->util->getDbLookup();
     $localized = $this->util->getLocalized();
     $translated = $this->util->getTranslated();
     if ($this->loginCheck) {
         $this->addLoginCheck();
     }
     $this->resetOrder();
     if ($this->has('gr2o_id_organization')) {
         $this->set('gr2o_id_organization', 'label', $this->_('Organization'), 'tab', $this->_('Identification'), 'multiOptions', $this->currentUser->getRespondentOrganizations());
         $this->set('gr2o_id_organization', 'default', $this->currentUser->getCurrentOrganizationId());
         if (count($this->currentUser->getAllowedOrganizations()) == 1) {
             $this->set('gr2o_id_organization', 'elementClass', 'Exhibitor');
         }
     }
     // The SSN
     if ($this->hashSsn !== self::SSN_HIDE) {
         $this->set('grs_ssn', 'label', $this->_('SSN'), 'tab', $this->_('Identification'));
     }
     $this->setIfExists('gr2o_patient_nr', 'label', $this->_('Respondent number'), 'tab', $this->_('Identification'));
     $this->setIfExists('grs_initials_name', 'label', $this->_('Initials'));
     $this->setIfExists('grs_first_name', 'label', $this->_('First name'));
     $this->setIfExists('grs_surname_prefix', 'label', $this->_('Surname prefix'), 'description', $this->_('de, ibn, Le, Mac, von, etc...'));
     $this->setIfExists('grs_last_name', 'label', $this->_('Last name'));
     $this->setIfExists('grs_partner_surname_prefix', 'label', $this->_('Partner surname prefix'), 'description', $this->_('de, ibn, Le, Mac, von, etc...'));
     $this->setIfExists('grs_partner_last_name', 'label', $this->_('Partner last name'));
     $this->setIfExists('grs_gender', 'label', $this->_('Gender'), 'multiOptions', $translated->getGenderHello());
     $this->setIfExists('grs_birthday', 'label', $this->_('Birthday'), 'dateFormat', \Zend_Date::DATE_MEDIUM);
     $this->setIfExists('grs_email', 'label', $this->_('E-Mail'), 'tab', $this->_('Contact information'));
     $this->setIfExists('gr2o_mailable', 'label', $this->_('May be mailed'), 'elementClass', 'radio', 'separator', ' ', 'multiOptions', $translated->getYesNo());
     $this->setIfExists('gr2o_treatment', 'label', $this->_('Treatment'));
     $this->setIfExists('gr2o_comments', 'label', $this->_('Comments'));
     $this->setIfExists('grs_address_1', 'label', $this->_('Street'));
     $this->setIfExists('grs_address_2', 'label', ' ');
     // \MUtil_Echo::track($this->getItemsOrdered(), $this->getOrder('grs_email'));
     $this->setIfExists('grs_zipcode', 'label', $this->_('Zipcode'));
     $this->setIfExists('grs_city', 'label', $this->_('City'));
     $this->setIfExists('grs_iso_country', 'label', $this->_('Country'), 'multiOptions', $localized->getCountries());
     $this->setIfExists('grs_phone_1', 'label', $this->_('Phone'));
     $this->setIfExists('grs_phone_2', 'label', $this->_('Phone 2'));
     $this->setIfExists('grs_phone_3', 'label', $this->_('Phone 3'));
     $this->setIfExists('grs_phone_4', 'label', $this->_('Phone 4'));
     $this->setIfExists('grs_iso_lang', 'label', $this->_('Language'), 'multiOptions', $localized->getLanguages(), 'tab', $this->_('Settings'), 'default', $this->project->getLocaleDefault());
     $this->setIfExists('gr2o_consent', 'label', $this->_('Consent'), 'default', $this->util->getDefaultConsent(), 'description', $this->_('Has the respondent signed the informed consent letter?'), 'multiOptions', $dbLookup->getUserConsents());
     $changers = $this->getChangersList();
     $this->setIfExists('gr2o_opened', 'label', $this->_('Opened'), 'dateFormat', \Zend_Date::DATE_MEDIUM, 'default', '', 'elementClass', 'None', 'formatFunction', array($translated, 'formatDateTime'));
     $this->setIfExists('gr2o_opened_by', 'label', $this->_('Opened'), 'elementClass', 'None', 'multiOptions', $changers);
     $this->setIfExists('gr2o_changed', 'label', $this->_('Changed on'), 'dateFormat', \Zend_Date::DATE_MEDIUM, 'default', '', 'formatFunction', array($translated, 'formatDateTime'));
     $this->setIfExists('gr2o_changed_by', 'label', $this->_('Changed by'), 'multiOptions', $changers);
     $this->setIfExists('gr2o_created', 'label', $this->_('Creation date'), 'dateFormat', \Zend_Date::DATE_MEDIUM, 'default', '', 'formatFunction', array($translated, 'formatDateTime'));
     $this->setIfExists('gr2o_created_by', 'label', $this->_('Creation by'), 'multiOptions', $changers);
     return $this;
 }
 /**
  * Set those values needed for editing
  *
  * @return \Gems_Model_OrganizationModel
  */
 public function applyEditSettings()
 {
     $this->applyDetailSettings();
     $this->resetOrder();
     // GENERAL TAB
     $this->set('general', 'tab', 'general', 'elementClass', 'Tab', 'value', $this->_('General'));
     $this->set('gor_name', 'tab', 'general', 'size', 25, 'validator', $this->createUniqueValidator('gor_name'));
     $this->set('gor_location', 'tab', 'general', 'size', 50, 'maxlength', 255);
     $this->set('gor_task', 'tab', 'general', 'size', 25);
     $this->set('gor_url', 'tab', 'general', 'size', 50);
     $this->setIfExists('gor_url_base', 'tab', 'general', 'size', 50, 'filter', 'TrailingSlash');
     $this->setIfExists('gor_code', 'tab', 'general', 'size', 10);
     $this->set('gor_provider_id', 'tab', 'general');
     $this->setIfExists('gor_active', 'tab', 'general', 'elementClass', 'Checkbox');
     // EMAIL TAB
     $this->set('email', 'tab', 'email', 'elementClass', 'Tab', 'order', $this->getOrder('gor_active') + 1000, 'value', $this->_('Email') . ' & ' . $this->_('Token'));
     $this->set('gor_contact_name', 'tab', 'email', 'size', 25);
     $this->set('gor_contact_email', 'tab', 'email', 'size', 50, 'validator', 'SimpleEmail');
     $this->set('gor_welcome', 'tab', 'email', 'elementClass', 'Textarea', 'rows', 5);
     $this->set('gor_signature', 'tab', 'email', 'elementClass', 'Textarea', 'rows', 5);
     $this->set('gor_create_account_template', 'tab', 'email');
     $this->set('gor_reset_pass_template', 'tab', 'email');
     // ACCESS TAB
     $this->set('access', 'tab', 'access', 'elementClass', 'Tab', 'order', $this->getOrder('gor_reset_pass_template') + 1000, 'value', $this->_('Access'));
     $this->set('gor_has_login', 'tab', 'access', 'elementClass', 'CheckBox');
     $this->set('gor_add_respondents', 'tab', 'access', 'elementClass', 'CheckBox');
     $this->set('gor_has_respondents', 'tab', 'access', 'elementClass', 'Exhibitor');
     $this->set('gor_respondent_group', 'tab', 'access');
     $this->set('gor_accessible_by', 'tab', 'access', 'elementClass', 'MultiCheckbox');
     $this->set('allowed', 'tab', 'access', 'label', $this->_('Can access'), 'elementClass', 'Html');
     $this->setIfExists('gor_allowed_ip_ranges', 'tab', 'access', 'size', 50, 'validator', new \Gems_Validate_IPRanges(), 'maxlength', 500);
     $this->setIfExists('gor_user_class', 'tab', 'access');
     $definitions = $this->get('gor_user_class', 'multiOptions');
     if ($definitions && count($definitions) > 1) {
         reset($definitions);
         $this->setIfExists('gor_user_class', 'default', key($definitions), 'required', true);
     }
     // OTHER TAB
     $this->set('other', 'tab', 'other', 'elementClass', 'Tab', 'order', $this->getOrder('gor_user_class') + 1000, 'value', $this->_('Other'));
     $this->setIfExists('gor_iso_lang', 'tab', 'other', 'default', $this->project->getLocaleDefault());
     if ($this->_styles) {
         $this->setIfExists('gor_style', 'tab', 'other');
     }
     return $this;
 }
 /**
  * Start the cron mail monitor
  *
  * @return boolean True when the job was started
  */
 public function startCronMailMonitor()
 {
     $to = $this->_getMailTo('cronmail', 'gsf_mail_watcher = 1');
     if (!$to) {
         return false;
     }
     $job = $this->getCronMailMonitor();
     switch ($this->project->getLocaleDefault()) {
         case 'nl':
             $subject = "{name} opdracht draait al meer dan {periodHours} uur niet";
             $messageBbText = "L.S.,\n\nDe [b]{name}[/b] opdracht heeft op {setTime} voor het laatst gedraait en zou voor {firstCheck} opnieuw gedraait moeten hebben.\n\nDit is waarschuwing nummer [b]{mailCount}[/b]. Controleer s.v.p. wat verkeerd gegaan is.\n\nDit is een automatische waarschuwing.";
             break;
         default:
             $subject = "{name} job has not run for over {periodHours} hours";
             $messageBbText = "L.S.,\n\nThe [b]{name}[/b] job ran at {setTime} for the last time and should have run again before {firstCheck}.\n\nThis is notice number {mailCount}. Please check what went wrong.\n\nThis messages was send automatically.";
             break;
     }
     $job->setFrom($this->project->getMonitorFrom('cronmail'))->setMessage($messageBbText)->setPeriod($this->project->getMonitorPeriod('cronmail'))->setSubject($subject)->setTo($to)->start();
     return true;
 }