* @param array $params
*/
public function setApiFilter(&$params) {
- if (CRM_Utils_Array::value('target_contact_id', $params)) {
+ if (!empty($params['target_contact_id'])) {
$this->selectAdd();
$activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
return CRM_Custom_Form_CustomData::setDefaultValues($this);
}
- $defaults = $this->_values;
+ $defaults = $this->_values + CRM_Core_Form_RecurringEntity::setDefaultValues();
// if we're editing...
if (isset($this->_activityId)) {
if (empty($defaults['activity_date_time'])) {
$defaults['activity_date_time_time']
) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($defaults['activity_date_time'], 'activityDateTime');
- $recurringEntityDefaults = array();
- $recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues();
- $defaults = array_merge($defaults, $recurringEntityDefaults);
}
if ($this->_context != 'standalone') {
$this->assign('suppressForm', FALSE);
$element = &$this->add('select', 'activity_type_id', ts('Activity Type'),
- $this->_fields['followup_activity_type_id']['attributes'],
+ array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'],
FALSE, array(
'onchange' => "CRM.buildCustomData( 'Activity', this.value );",
- 'class' => 'crm-select2',
+ 'class' => 'crm-select2 required',
)
);
return TRUE;
}
$errors = array();
- if (!$self->_single && !$fields['activity_type_id']) {
+ if ((array_key_exists('activity_type_id', $fields) || !$self->_single) && empty($fields['activity_type_id'])) {
$errors['activity_type_id'] = ts('Activity Type is a required field');
}
- //Activity type is mandatory if creating new activity, CRM-4515
- if (array_key_exists('activity_type_id', $fields) && empty($fields['activity_type_id'])) {
- $errors['activity_type_id'] = ts('Activity Type is required field.');
- }
-
if (CRM_Utils_Array::value('activity_type_id', $fields) == 3 &&
CRM_Utils_Array::value('status_id', $fields) == 1
) {
// set params for repeat configuration in create mode
$params['entity_id'] = $activityId;
$params['entity_table'] = 'civicrm_activity';
- $scheduleReminderDetails = array();
if (!empty($params['entity_id']) && !empty($params['entity_table'])) {
$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($params['entity_id'], $params['entity_table']);
if ($checkParentExistsForThisId) {
}
$params['dateColumns'] = array('activity_date_time');
+ // Set default repetition start if it was not provided.
+ if (empty($params['repetition_start_date'])) {
+ $params['repetition_start_date'] = $params['activity_date_time'];
+ }
+
// unset activity id
unset($params['id']);
$linkedEntities = array(
foreach ($activities as $key => $value) {
//Check if recurring activity
- if (CRM_Utils_Array::value('is_recurring_activity', $value)) {
+ if (!empty($value['is_recurring_activity'])) {
if ($key == $value['is_recurring_activity']) {
$activities[$key]['activity_type'] = $activities[$key]['activity_type'] . '<br/><span class="bold">Recurring Activity - (Parent)</span>';
}
}
//get the frequency units.
- $this->_freqUnits = CRM_Core_SelectValues::getScheduleReminderFrequencyUnits();
+ $this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits();
//pass the mapping ID in UPDATE mode
$mappings = CRM_Core_BAO_ActionSchedule::getMapping($mappingID);
$startOffset = CRM_Utils_Array::value('height_image_2', $formattedRow);
}
- if (CRM_Utils_Array::value('participant_image', $formattedRow)) {
+ if (!empty($formattedRow['participant_image'])) {
$imageAlign = 0;
switch (CRM_Utils_Array::value('alignment_participant_image', $formattedRow)) {
case 'R':
$surveysData[$sid]['campaign'] = CRM_Utils_Array::value($campaignId, $campaigns);
$surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']];
if (!empty($survey['release_frequency'])) {
- $surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' Day(s)';
+ $surveysData[$sid]['release_frequency'] = $survey['release_frequency'] . ' ' . ts('Day(s)');
}
$action = array_sum(array_keys(self::surveyActionLinks($surveysData[$sid]['activity_type'])));
$commPreff[] = $form->createElement('advcheckbox', $k, NULL, $v);
}
- $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, ts(''));
+ $onHold[] = $form->createElement('advcheckbox', 'on_hold', NULL, '');
$form->addGroup($onHold, 'email_on_hold', ts('Email On Hold'));
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
ts('Activity Subject') => 'activity_subject',
ts('Scheduled By') => 'source_contact',
ts('Scheduled Date') => 'activity_date',
- ts(' ') => 'activity_id',
- ts(' ') => 'activity_type_id',
- ts(' ') => 'case_id',
+ ' ' => 'activity_id',
+ ' ' => 'activity_type_id',
+ ' ' => 'case_id',
ts('Location') => 'location',
ts('Duration') => 'duration',
ts('Details') => 'details',
$this->normalize();
$this->_columns = array(
- ts('') => 'contact_type',
+ '' => 'contact_type',
ts('Name') => 'sort_name',
ts('Address') => 'street_address',
ts('City') => 'city',
$this->assign('dataArray', $taxRate);
}
else {
- if (CRM_Utils_Array::value('price_set_id', $submittedValues)) {
+ if (!empty($submittedValues['price_set_id'])) {
$this->assign('totalTaxAmount', $submittedValues['tax_amount']);
$this->assign('getTaxDetails', $getTaxDetails);
$this->assign('dataArray', $taxRate);
$options = array();
$options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1);
$options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2);
- $this->addGroup($options, 'is_for_organization', ts(''));
+ $this->addGroup($options, 'is_for_organization', '');
$this->add('textarea', 'for_organization', ts('On behalf of Label'), $attributes['for_organization']);
// collect goal amount
$contactID = CRM_Core_Session::singleton()->get('userID');
$allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']);
$defaultDashlets = array();
- if (CRM_Utils_Array::value('blog', $allDashlets)) {
+ if (!empty($allDashlets['blog'])) {
$defaultDashlets['blog'] = array(
'dashboard_id' => $allDashlets['blog']['id'],
'is_active' => 1,
* @return object
*/
public static function add(&$params) {
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
CRM_Utils_Hook::pre('edit', 'RecurringEntity', $params['id'], $params);
}
else {
$daoRecurringEntity->find(TRUE);
$result = $daoRecurringEntity->save();
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
CRM_Utils_Hook::post('edit', 'RecurringEntity', $daoRecurringEntity->id, $daoRecurringEntity);
}
else {
$recursionDates[$count][$col] = CRM_Utils_Date::processDate($newDate->format('Y-m-d H:i:s'));
}
if ($exRangeStart) {
- $exRangeStartDate = CRM_Utils_Date::processDate($recursionDates[$count][$exRangeStart], NULL, FALSE, 'Ymd');
- $exRangeEndDate = CRM_Utils_Date::processDate($recursionDates[$count][$exRangeEnd], NULL, FALSE, 'Ymd');
+ $exRangeStartDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value($exRangeStart, $recursionDates[$count]), NULL, FALSE, 'Ymd');
+ $exRangeEndDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value($exRangeEnd, $recursionDates[$count]), NULL, FALSE, 'Ymd');
}
foreach ($this->excludeDates as $exDate) {
*/
public function mapFormValuesToDB($formParams = array()) {
$dbParams = array();
- if (CRM_Utils_Array::value('used_for', $formParams)) {
+ if (!empty($formParams['used_for'])) {
$dbParams['used_for'] = $formParams['used_for'];
}
- if (CRM_Utils_Array::value('entity_id', $formParams)) {
+ if (!empty($formParams['entity_id'])) {
$dbParams['entity_value'] = $formParams['entity_id'];
}
- if (CRM_Utils_Array::value('repetition_start_date', $formParams)) {
- if (CRM_Utils_Array::value('repetition_start_date_display', $formParams)) {
+ if (!empty($formParams['repetition_start_date'])) {
+ if (!empty($formParams['repetition_start_date_display'])) {
$repetitionStartDate = $formParams['repetition_start_date_display'];
}
else {
$repetitionStartDate = $formParams['repetition_start_date'];
}
- if (CRM_Utils_Array::value('repetition_start_date_time', $formParams)) {
+ if (!empty($formParams['repetition_start_date_time'])) {
$repetitionStartDate = $repetitionStartDate . " " . $formParams['repetition_start_date_time'];
}
$repetition_start_date = new DateTime($repetitionStartDate);
$dbParams['start_action_date'] = CRM_Utils_Date::processDate($repetition_start_date->format('Y-m-d H:i:s'));
}
- if (CRM_Utils_Array::value('repetition_frequency_unit', $formParams)) {
+ if (!empty($formParams['repetition_frequency_unit'])) {
$dbParams['repetition_frequency_unit'] = $formParams['repetition_frequency_unit'];
}
- if (CRM_Utils_Array::value('repetition_frequency_interval', $formParams)) {
+ if (!empty($formParams['repetition_frequency_interval'])) {
$dbParams['repetition_frequency_interval'] = $formParams['repetition_frequency_interval'];
}
//For Repeats on:(weekly case)
if ($formParams['repetition_frequency_unit'] == 'week') {
- if (CRM_Utils_Array::value('start_action_condition', $formParams)) {
+ if (!empty($formParams['start_action_condition'])) {
$repeats_on = CRM_Utils_Array::value('start_action_condition', $formParams);
$dbParams['start_action_condition'] = implode(",", array_keys($repeats_on));
}
//For Repeats By:(monthly case)
if ($formParams['repetition_frequency_unit'] == 'month') {
if ($formParams['repeats_by'] == 1) {
- if (CRM_Utils_Array::value('limit_to', $formParams)) {
+ if (!empty($formParams['limit_to'])) {
$dbParams['limit_to'] = $formParams['limit_to'];
}
}
//For "Ends" - After:
if ($formParams['ends'] == 1) {
- if (CRM_Utils_Array::value('start_action_offset', $formParams)) {
+ if (!empty($formParams['start_action_offset'])) {
$dbParams['start_action_offset'] = $formParams['start_action_offset'];
}
}
//For "Ends" - On:
if ($formParams['ends'] == 2) {
- if (CRM_Utils_Array::value('repeat_absolute_date', $formParams)) {
+ if (!empty($formParams['repeat_absolute_date'])) {
$dbParams['absolute_date'] = CRM_Utils_Date::processDate($formParams['repeat_absolute_date']);
}
}
$r->count($scheduleReminderDetails['start_action_offset']);
}
- if (CRM_Utils_Array::value('absolute_date', $scheduleReminderDetails)) {
+ if (!empty($scheduleReminderDetails['absolute_date'])) {
$absoluteDate = CRM_Utils_Date::setDateDefaults($scheduleReminderDetails['absolute_date']);
$endDate = new DateTime($absoluteDate[0] . ' ' . $absoluteDate[1]);
$endDate->modify('+1 day');
);
$defaults = array();
CRM_Core_DAO::commonRetrieve($dao, $params, $defaults);
- if (CRM_Utils_Array::value('id', $defaults)) {
+ if (!empty($defaults['id'])) {
$result['entityId'] = $defaults['id'];
$result['entityTable'] = $entityTable;
}
self::CREATE_NEW => array(
'template' => 'CreateNew.tpl',
'info' => ts('CiviCRM Create New Record'),
- 'subject' => ts(''),
+ 'subject' => '',
'active' => TRUE,
'cache' => BLOCK_CACHE_GLOBAL,
'visibility' => 1,
self::$_scheduleReminderID = self::$_scheduleReminderDetails->id;
}
}
- if ($entityTable) {
- CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue);
- $excludeOptionValues = array();
- if (!empty($optionValue)) {
- foreach ($optionValue as $key => $val) {
- $excludeOptionValues[$val['value']] = date('m/d/Y', strtotime($val['value']));
- }
- self::$_excludeDateInfo = $excludeOptionValues;
+ CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue);
+ $excludeOptionValues = array();
+ if (!empty($optionValue)) {
+ foreach ($optionValue as $key => $val) {
+ $excludeOptionValues[$val['value']] = CRM_Utils_Date::customFormat($val['value']);
}
+ self::$_excludeDateInfo = $excludeOptionValues;
}
+
+ // Assign variables
+ $entityType = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($entityTable));
+ $tpl = CRM_Core_Smarty::singleton();
+ $tpl->assign('recurringEntityType', ts($entityType));
+ $tpl->assign('currentEntityId', self::$_entityId);
+ $tpl->assign('entityTable', self::$_entityTable);
+ $tpl->assign('scheduleReminderId', self::$_scheduleReminderID);
+ $tpl->assign('hasParent', self::$_hasParent);
}
/**
* @return array
*/
public static function setDefaultValues() {
- $defaults = array();
+ // Defaults for new entity
+ $defaults = array(
+ 'repetition_frequency_unit' => 'week',
+ );
+
+ // Default for existing entity
if (self::$_scheduleReminderID) {
$defaults['repetition_frequency_unit'] = self::$_scheduleReminderDetails->repetition_frequency_unit;
$defaults['repetition_frequency_interval'] = self::$_scheduleReminderDetails->repetition_frequency_interval;
if (self::$_scheduleReminderDetails->limit_to) {
$defaults['repeats_by'] = 1;
}
- $explodeStartActionCondition = array();
if (self::$_scheduleReminderDetails->entity_status) {
$explodeStartActionCondition = explode(" ", self::$_scheduleReminderDetails->entity_status);
$defaults['entity_status_1'] = $explodeStartActionCondition[0];
if (self::$_scheduleReminderDetails->entity_status) {
$defaults['repeats_by'] = 2;
}
+ if (self::$_excludeDateInfo) {
+ $defaults['exclude_date_list'] = implode(',', self::$_excludeDateInfo);
+ }
}
return $defaults;
}
/**
* Build form.
*
- * @param $form
+ * @param CRM_Core_Form $form
*/
public static function buildQuickForm(&$form) {
- if (self::$_entityTable) {
- $entityType = explode("_", self::$_entityTable);
- if ($entityType[1]) {
- $form->assign('entityType', ucwords($entityType[1]));
- }
- }
- $form->assign('currentEntityId', self::$_entityId);
- $form->assign('entityTable', self::$_entityTable);
- $form->assign('scheduleReminderId', self::$_scheduleReminderID);
- $form->assign('hasParent', self::$_hasParent);
-
- $form->_freqUnits = array('hour' => 'hour') + CRM_Core_OptionGroup::values('recur_frequency_units');
- foreach ($form->_freqUnits as $val => $label) {
- if ($label == "day") {
- $label = "dai";
- }
- $freqUnitsDisplay[$val] = ts('%1ly', array(1 => $label));
- }
- // echo "<pre>";print_r($freqUnitsDisplay);
+ // For some reason this is using the following as keys rather than the standard numeric keys returned by CRM_Utils_Date
$dayOfTheWeek = array(
- 'monday' => 'Monday',
- 'tuesday' => 'Tuesday',
- 'wednesday' => 'Wednesday',
- 'thursday' => 'Thursday',
- 'friday' => 'Friday',
- 'saturday' => 'Saturday',
- 'sunday' => 'Sunday',
+ 'sunday',
+ 'monday',
+ 'tuesday',
+ 'wednesday',
+ 'thursday',
+ 'friday',
+ 'saturday',
);
- $form->add('select', 'repetition_frequency_unit', ts('Repeats:'), $freqUnitsDisplay);
+ $dayOfTheWeek = array_combine($dayOfTheWeek, CRM_Utils_Date::getAbbrWeekdayNames());
+ $form->add('select', 'repetition_frequency_unit', ts('Repeats every'), CRM_Core_SelectValues::getRecurringFrequencyUnits(), FALSE, array('class' => 'required'));
$numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30);
- $form->add('select', 'repetition_frequency_interval', ts('Repeats every:'), $numericOptions, '', array('style' => 'width:55px;'));
+ $form->add('select', 'repetition_frequency_interval', NULL, $numericOptions, FALSE, array('class' => 'required'));
$form->addDateTime('repetition_start_date', ts('Repetition Start Date'), FALSE, array('formatType' => 'activityDateTime'));
foreach ($dayOfTheWeek as $key => $val) {
- $startActionCondition[] = $form->createElement('checkbox', $key, NULL, substr($val . " ", 0, 3));
+ $startActionCondition[] = $form->createElement('checkbox', $key, NULL, $val);
}
$form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on'));
$roptionTypes = array(
'1' => ts('day of the month'),
'2' => ts('day of the week'),
);
- $form->addRadio('repeats_by', ts("Repeats By:"), $roptionTypes, array(), NULL);
- $getMonths = CRM_Core_SelectValues::getNumericOptions(1, 31);
- $form->add('select', 'limit_to', '', $getMonths, FALSE, array('style' => 'width:55px;'));
+ $form->addRadio('repeats_by', ts("Repeats by"), $roptionTypes, array('required' => TRUE), NULL);
+ $form->add('select', 'limit_to', '', CRM_Core_SelectValues::getNumericOptions(1, 31));
$dayOfTheWeekNo = array(
- 'first' => 'First',
- 'second' => 'Second',
- 'third' => 'Third',
- 'fourth' => 'Fourth',
- 'last' => 'Last',
+ 'first' => ts('First'),
+ 'second' => ts('Second'),
+ 'third' => ts('Third'),
+ 'fourth' => ts('Fourth'),
+ 'last' => ts('Last'),
);
- $form->add('select', 'entity_status_1', ts(''), $dayOfTheWeekNo);
- $form->add('select', 'entity_status_2', ts(''), $dayOfTheWeek);
+ $form->add('select', 'entity_status_1', '', $dayOfTheWeekNo);
+ $form->add('select', 'entity_status_2', '', $dayOfTheWeek);
$eoptionTypes = array(
'1' => ts('After'),
'2' => ts('On'),
);
- $form->addRadio('ends', ts("Ends:"), $eoptionTypes, array(), NULL);
- $form->add('text', 'start_action_offset', ts(''), array('size' => 3, 'maxlength' => 2));
+ $form->addRadio('ends', ts("Ends"), $eoptionTypes, array('class' => 'required'), NULL);
+ $form->add('select', 'start_action_offset', NULL, CRM_Core_SelectValues::getNumericOptions(1, 30), FALSE);
$form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule'));
$form->addDate('repeat_absolute_date', ts('On'), FALSE, array('formatType' => 'mailing'));
- $form->addDate('exclude_date', ts('Exclude Date(s)'), FALSE);
- $select = $form->add('select', 'exclude_date_list', ts(''), self::$_excludeDateInfo, FALSE, array(
- 'style' => 'width:150px;',
- 'size' => 4,
+ $form->add('text', 'exclude_date_list', ts('Exclude Dates'), array(
+ 'class' => 'twenty',
));
- $select->setMultiple(TRUE);
- $form->addElement('button', 'add_to_exclude_list', '>>', 'onClick="addToExcludeList(document.getElementById(\'exclude_date\').value);"');
- $form->addElement('button', 'remove_from_exclude_list', '<<', 'onClick="removeFromExcludeList(\'exclude_date_list\')"');
- $form->addElement('hidden', 'copyExcludeDates', '', array('id' => 'copyExcludeDates'));
$form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit'));
$form->addButtons(array(
array(
),
)
);
+ // For client-side pluralization
+ $form->assign('recurringFrequencyOptions', array(
+ 'single' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits()),
+ 'plural' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits(2)),
+ ));
}
/**
if ($values['allowRepeatConfigToSubmit'] == 1) {
$dayOfTheWeek = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
//Repeats
- if (!CRM_Utils_Array::value('repetition_frequency_unit', $values)) {
+ if (empty($values['repetition_frequency_unit'])) {
$errors['repetition_frequency_unit'] = ts('This is a required field');
}
//Repeats every
- if (!CRM_Utils_Array::value('repetition_frequency_interval', $values)) {
+ if (empty($values['repetition_frequency_interval'])) {
$errors['repetition_frequency_interval'] = ts('This is a required field');
}
//Ends
- if (CRM_Utils_Array::value('ends', $values)) {
+ if (!empty($values['ends'])) {
if ($values['ends'] == 1) {
if (empty($values['start_action_offset'])) {
$errors['start_action_offset'] = ts('This is a required field');
}
}
if ($values['ends'] == 2) {
- if (CRM_Utils_Array::value('repeat_absolute_date', $values)) {
+ if (!empty($values['repeat_absolute_date'])) {
$entityStartDate = CRM_Utils_Date::processDate($values['repetition_start_date']);
$end = CRM_Utils_Date::processDate($values['repeat_absolute_date']);
if (($end < $entityStartDate) && ($end != 0)) {
}
//Repeats BY
- if (CRM_Utils_Array::value('repeats_by', $values)) {
+ if (!empty($values['repeats_by'])) {
if ($values['repeats_by'] == 1) {
- if (CRM_Utils_Array::value('limit_to', $values)) {
+ if (!empty($values['limit_to'])) {
if ($values['limit_to'] < 1 && $values['limit_to'] > 31) {
$errors['limit_to'] = ts('Invalid day of the month');
}
}
}
if ($values['repeats_by'] == 2) {
- if (CRM_Utils_Array::value('entity_status_1', $values)) {
+ if (!empty($values['entity_status_1'])) {
$dayOfTheWeekNo = array('first', 'second', 'third', 'fourth', 'last');
if (!in_array($values['entity_status_1'], $dayOfTheWeekNo)) {
$errors['entity_status_1'] = ts('Invalid option');
else {
$errors['entity_status_1'] = ts('Invalid option');
}
- if (CRM_Utils_Array::value('entity_status_2', $values)) {
+ if (!empty($values['entity_status_2'])) {
if (!in_array($values['entity_status_2'], $dayOfTheWeek)) {
$errors['entity_status_2'] = ts('Invalid day name');
}
*/
public static function postProcess($params = array(), $type, $linkedEntities = array()) {
//Check entity_id not present in params take it from class variable
- if (!CRM_Utils_Array::value('entity_id', $params)) {
+ if (empty($params['entity_id'])) {
$params['entity_id'] = self::$_entityId;
}
//Process this function only when you get this variable
if ($params['allowRepeatConfigToSubmit'] == 1) {
if (CRM_Utils_Array::value('entity_table', $params) && CRM_Utils_Array::value('entity_id', $params) && $type) {
$params['used_for'] = $type;
- if (!CRM_Utils_Array::value('parent_entity_id', $params)) {
+ if (empty($params['parent_entity_id'])) {
$params['parent_entity_id'] = self::$_parentEntityId;
}
- if (CRM_Utils_Array::value('schedule_reminder_id', $params)) {
+ if (!empty($params['schedule_reminder_id'])) {
$params['id'] = $params['schedule_reminder_id'];
}
else {
$dbParams = $recurobj->mapFormValuesToDB($params);
//Delete repeat configuration and rebuild
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
CRM_Core_BAO_ActionSchedule::del($params['id']);
unset($params['id']);
}
//exclude dates
$excludeDateList = array();
- if (CRM_Utils_Array::value('copyExcludeDates', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) {
+ if (CRM_Utils_Array::value('exclude_date_list', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) {
//Since we get comma separated values lets get them in array
- $excludeDates = array();
- $excludeDates = explode(",", $params['copyExcludeDates']);
+ $excludeDates = explode(",", $params['exclude_date_list']);
//Check if there exists any values for this option group
$optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
'is_active' => 1,
);
$excludeDateList[] = $optionGroupValue['value'];
- CRM_Core_BAO_OptionValue::add($optionGroupValue);
+ CRM_Core_BAO_OptionValue::create($optionGroupValue);
}
}
}
//Set type for API
- $apiEntityType = array();
$apiEntityType = explode("_", $type);
if (!empty($apiEntityType[1])) {
$apiType = $apiEntityType[1];
$recursion->excludeDates = $excludeDateList;
$recursion->excludeDateRangeColumns = $params['excludeDateRangeColumns'];
}
- if (CRM_Utils_Array::value('intervalDateColumns', $params)) {
+ if (!empty($params['intervalDateColumns'])) {
$recursion->intervalDateColumns = $params['intervalDateColumns'];
}
$recursion->entity_id = $params['entity_id'];
$recursion->linkedEntities = $linkedEntities;
}
- $recurResult = $recursion->generate();
+ $recursion->generate();
$status = ts('Repeat Configuration has been saved');
CRM_Core_Session::setStatus($status, ts('Saved'), 'success');
class CRM_Core_Page_AJAX_RecurringEntity {
public static function updateMode() {
+ $finalResult = array();
if (CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST) && CRM_Utils_Array::value('entityTable', $_REQUEST)) {
- $finalResult = array();
$mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer');
$entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer');
$entityTable = CRM_Utils_Type::escape($_REQUEST['entityTable'], 'String');
- if (CRM_Utils_Array::value('linkedEntityTable', $_REQUEST)) {
- $result = array();
+ if (!empty($_REQUEST['linkedEntityTable'])) {
$result = CRM_Core_BAO_RecurringEntity::updateModeLinkedEntity($entityId, $_REQUEST['linkedEntityTable'], $entityTable);
}
$finalResult['status'] = 'Error';
}
}
- echo json_encode($finalResult);
- CRM_Utils_System::civiExit();
- }
-
- public static function generatePreview() {
- $params = $formValues = $genericResult = array();
- $formValues = $_REQUEST;
- if (!empty($formValues) &&
- CRM_Utils_Array::value('entity_table', $formValues)
- ) {
- $startDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'][0];
- $endDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['intervalDateColumns'][0];
-
- $recursion = new CRM_Core_BAO_RecurringEntity();
- if (CRM_Utils_Array::value('dateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
- $recursion->dateColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'];
- }
- $recursion->scheduleFormValues = $formValues;
- if (!empty($formValues['exclude_date_list'])) {
- $recursion->excludeDates = $formValues['exclude_date_list'];
- }
- if (CRM_Utils_Array::value('excludeDateRangeColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
- $recursion->excludeDateRangeColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['excludeDateRangeColumns'];
- }
-
- if (CRM_Utils_Array::value('entity_id', $formValues)) {
- $parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['entity_id'], $formValues['entity_table']);
- }
-
- //Check if there is any enddate column defined to find out the interval between the two range
- if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
- $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
- if ($parentEventId) {
- $startDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
- $endDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName);
- }
- if ($endDate) {
- $interval = $recursion->getInterval($startDate, $endDate);
- $recursion->intervalDateColumns = array($endDateColumnName => $interval);
- }
- }
-
- $result = $recursion->generateRecursiveDates();
-
- foreach ($result as $key => $value) {
- if ($startDateColumnName) {
- $result[$key]['start_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$startDateColumnName]));
- }
- if ($value[$endDateColumnName]) {
- if ($endDateColumnName) {
- $result[$key]['end_date'] = date('M d, Y h:i:s A \o\n l', strtotime($value[$endDateColumnName]));
- }
- }
- }
-
- //Show the list of participants registered for the events if any
- if ($formValues['entity_table'] == "civicrm_event" && !empty($parentEventId)) {
- $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
- if ($getConnectedEntities) {
- $participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getConnectedEntities);
- if (!empty($participantDetails['countByName'])) {
- $result['participantData'] = $participantDetails['countByName'];
- }
- }
- }
- }
- echo json_encode($result);
- CRM_Utils_System::civiExit();
+ CRM_Utils_JSON::output($finalResult);
}
}
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2014
+ * $Id$
+ *
+ */
+class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page {
+
+ /**
+ * Run the basic page (run essentially starts execution for that page).
+ *
+ * @return void
+ */
+ public function run() {
+ $parentEventId = $startDate = $endDate = NULL;
+ $dates = array();
+ $formValues = $_REQUEST;
+ if (!empty($formValues['entity_table'])) {
+ $startDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'][0];
+ $endDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['intervalDateColumns'][0];
+
+ $recursion = new CRM_Core_BAO_RecurringEntity();
+ if (CRM_Utils_Array::value('dateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
+ $recursion->dateColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'];
+ }
+ $recursion->scheduleFormValues = $formValues;
+ if (!empty($formValues['exclude_date_list'])) {
+ $recursion->excludeDates = explode(',', $formValues['exclude_date_list']);
+ }
+ if (CRM_Utils_Array::value('excludeDateRangeColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
+ $recursion->excludeDateRangeColumns = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['excludeDateRangeColumns'];
+ }
+
+ if (!empty($formValues['entity_id'])) {
+ $parentEventId = CRM_Core_BAO_RecurringEntity::getParentFor($formValues['entity_id'], $formValues['entity_table']);
+ }
+
+ //Check if there is any enddate column defined to find out the interval between the two range
+ if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) {
+ $daoName = CRM_Core_BAO_RecurringEntity::$_tableDAOMapper[$formValues['entity_table']];
+ if ($parentEventId) {
+ $startDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $startDateColumnName);
+ $endDate = CRM_Core_DAO::getFieldValue($daoName, $parentEventId, $endDateColumnName);
+ }
+ if ($endDate) {
+ $interval = $recursion->getInterval($startDate, $endDate);
+ $recursion->intervalDateColumns = array($endDateColumnName => $interval);
+ }
+ }
+
+ $dates = $recursion->generateRecursiveDates();
+
+ foreach ($dates as $key => &$value) {
+ if ($startDateColumnName) {
+ $value['start_date'] = CRM_Utils_Date::customFormat($value[$startDateColumnName]);
+ }
+ if ($endDateColumnName && !empty($value[$endDateColumnName])) {
+ $value['end_date'] = CRM_Utils_Date::customFormat($value[$endDateColumnName]);
+ $endDates = TRUE;
+ }
+ }
+
+ //Show the list of participants registered for the events if any
+ if ($formValues['entity_table'] == "civicrm_event" && !empty($parentEventId)) {
+ $getConnectedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($parentEventId, 'civicrm_event', TRUE);
+ if ($getConnectedEntities) {
+ $participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getConnectedEntities);
+ if (!empty($participantDetails['countByName'])) {
+ $this->assign('participantData', $participantDetails['countByName']);
+ }
+ }
+ }
+ }
+ $this->assign('dates', $dates);
+ $this->assign('endDates', !empty($endDates));
+
+ return parent::run();
+ }
+
+}
/**
* Frequency unit for schedule reminders.
*
+ * @param int $count
+ * For pluralization
* @return array
*/
- public static function getScheduleReminderFrequencyUnits() {
- //@todo update schema to refer to option group direct & remove this
- static $scheduleReminderFrequencyUnits = NULL;
- if (!$scheduleReminderFrequencyUnits) {
- $scheduleReminderFrequencyUnits = array(
- 'hour' => ts('hour'),
- ) + CRM_Core_OptionGroup::values('recur_frequency_units');
- }
-
- return $scheduleReminderFrequencyUnits;
+ public static function getRecurringFrequencyUnits($count = 1) {
+ // @todo this used to refer to the 'recur_frequency_unit' option_values which
+ // is for recurring payments and probably not good to re-use for recurring entities.
+ // If something other than a hard-coded list is desired, add a new option_group.
+ return array(
+ 'hour' => ts('hour', array('plural' => 'hours', 'count' => $count)),
+ 'day' => ts('day', array('plural' => 'days', 'count' => $count)),
+ 'week' => ts('week', array('plural' => 'weeks', 'count' => $count)),
+ 'month' => ts('month', array('plural' => 'months', 'count' => $count)),
+ 'year' => ts('year', array('plural' => 'years', 'count' => $count)),
+ );
}
}
$params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
if (empty($params['title'])) {
- // Avod overwriting existing vars CRM-11900
- $oldID = $smarty->get_template_vars('id');
+ $vars = $smarty->get_template_vars();
$smarty->assign('id', $params['id'] . '-title');
$name = trim($smarty->fetch($params['file'] . '.hlp'));
$additionalTPLFile = $params['file'] . '.extra.hlp';
if ($smarty->template_exists($additionalTPLFile)) {
$name .= trim($smarty->fetch($additionalTPLFile));
}
- $smarty->assign('id', $oldID);
+ // Ensure we didn't change any existing vars CRM-11900
+ foreach ($vars as $key => $value) {
+ if ($smarty->get_template_vars($key) !== $value) {
+ $smarty->assign($key, $value);
+ }
+ }
}
else {
$name = trim(strip_tags($params['title']));
<access_arguments>access CiviCRM,access CiviEvent</access_arguments>
</item>
<item>
- <path>civicrm/ajax/recurringentity/generate-preview</path>
- <page_callback>CRM_Core_Page_AJAX_RecurringEntity::generatePreview</page_callback>
+ <path>civicrm/recurringentity/preview</path>
+ <page_callback>CRM_Core_Page_RecurringEntityPreview</page_callback>
<access_arguments>access CiviCRM,access CiviEvent</access_arguments>
+ <title>Confirm dates</title>
</item>
<item>
<path>civicrm/ajax/l10n-js</path>
public static function dedupeRuleFieldsWeight($params) {
$rgBao = new CRM_Dedupe_BAO_RuleGroup();
$rgBao->contact_type = $params['contact_type'];
- if (CRM_Utils_Array::value('id', $params)) {
+ if (!empty($params['id'])) {
// accept an ID if provided
$rgBao->id = $params['id'];
}
if (in_array('CiviEvent', $config->enableComponents)) {
$this->assign('CiviEvent', TRUE);
}
+ CRM_Core_Form_RecurringEntity::preProcess('civicrm_event');
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
public function preProcess() {
parent::preProcess();
- CRM_Core_Form_RecurringEntity::preProcess('civicrm_event');
$this->assign('currentEventId', $this->_id);
$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
* the default values are retrieved from the database
*
*
- * @return void
+ * @return array
*/
public function setDefaultValues() {
$defaults = array();
//Always pass current event's start date by default
$currentEventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id');
list($defaults['repetition_start_date'], $defaults['repetition_start_date_time']) = CRM_Utils_Date::setDateDefaults($currentEventStartDate, 'activityDateTime');
- $defaults['allowRepeatConfigToSubmit'] = 1;
- $recurringEntityDefaults = array();
$recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues();
- $defaults = array_merge($defaults, $recurringEntityDefaults);
- return $defaults;
+ return array_merge($defaults, $recurringEntityDefaults);
}
public function buildQuickForm() {
CRM_Event_BAO_Participant::changeFeeSelections($params, $this->_participantId, $this->_contributionId, $feeBlock, $lineItems, $this->_paidAmount, $params['priceSetId']);
$this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount');
// email sending
- if (CRM_Utils_Array::value('send_receipt', $params)) {
+ if (!empty($params['send_receipt'])) {
$fetchParticipantVals = array('id' => $this->_participantId);
CRM_Event_BAO_Participant::getValues($fetchParticipantVals, $participantDetails, CRM_Core_DAO::$_nullArray);
$participantParams = array_merge($params, $participantDetails[$this->_participantId]);
$form->addDate('grant_application_received_date_low', ts('App. Received Date - From'), FALSE, array('formatType' => 'searchDate'));
$form->addDate('grant_application_received_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
- $form->addElement('checkbox', 'grant_application_received_notset', ts(''), NULL);
+ $form->addElement('checkbox', 'grant_application_received_notset', '', NULL);
$form->addDate('grant_money_transfer_date_low', ts('Money Sent Date - From'), FALSE, array('formatType' => 'searchDate'));
$form->addDate('grant_money_transfer_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
- $form->addElement('checkbox', 'grant_money_transfer_date_notset', ts(''), NULL);
+ $form->addElement('checkbox', 'grant_money_transfer_date_notset', '', NULL);
$form->addDate('grant_due_date_low', ts('Report Due Date - From'), FALSE, array('formatType' => 'searchDate'));
$form->addDate('grant_due_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
- $form->addElement('checkbox', 'grant_due_date_notset', ts(''), NULL);
+ $form->addElement('checkbox', 'grant_due_date_notset', '', NULL);
$form->addDate('grant_decision_date_low', ts('Grant Decision Date - From'), FALSE, array('formatType' => 'searchDate'));
$form->addDate('grant_decision_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
- $form->addElement('checkbox', 'grant_decision_date_notset', ts(''), NULL);
+ $form->addElement('checkbox', 'grant_decision_date_notset', '', NULL);
$form->addYesNo('grant_report_received', ts('Grant report received?'), TRUE);
foreach ($params['price_set_id'] as $priceSetID) {
CRM_Price_BAO_PriceSet::addTo('civicrm_' . $entityName, $entity->id, $priceSetID);
//@todo - how should we do this - copied from form
- //if (CRM_Utils_Array::value('price_field_id', $params)) {
+ //if (!empty($params['price_field_id'])) {
// $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id');
// CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0);
//}
$chart = "&charts=" . $params['charts'];
}
$limitResult = NULL;
- if (CRM_Utils_Array::value('row_count', $params)) {
+ if (!empty($params['row_count'])) {
$limitResult = '&rowCount=' . $params['row_count'];
}
$dashletParams['name'] = "report/{$instance->id}";
* @return string
*/
public function getFieldsetTitle() {
- return ts('');
+ return '';
}
/**
}
.crm-container input.crm-form-text[disabled],
+.crm-container input.dateplugin[disabled],
+.crm-container select.crm-form-select[disabled],
.crm-container input.crm-form-text[readonly] {
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #ddd), color-stop(15%, #f2f2f2));
background-image: -webkit-linear-gradient(top, #ddd 1%, #f2f2f2 15%);
background-image: linear-gradient(top, #ddd 1%, #f2f2f2 15%);
}
+.crm-container input.crm-form-text[disabled],
+.crm-container input.dateplugin[disabled],
+.crm-container select.crm-form-select[disabled] {
+ color: #a9a9a9;
+}
+
.crm-container .crm-form-submit {
margin: .25em 0.5em 0.25em 0;
}
background: url("../i/loading-overlay.gif") center center no-repeat white !important;
}
-/* Recurring Dialog */
-.crm-container .recurring-dialog-inner-wrapper {
- display: inline-block;
- width: 100%;
-}
-.crm-container .recurring-dialog-inner-left{
- width: 30%;
- float: left;
-}
-.crm-container .recurring-dialog-inner-right{
- width: 70%;
- float: left;
-}
-.crm-container .recurring-dialog-button{
- background: #f5f5f5;
- background-image: -webkit-linear-gradient(top,#f5f5f5,#f1f1f1);
- border: 1px solid rgba(0,0,0,0.1);
- padding: 5px 8px;
- text-align: center;
- border-radius: 2px;
- cursor: pointer;
- font-size: 11px !important;
-}
.crm-container table.mergecontact thead th {
width:30%;
}
message: ts('Are you sure you want to continue?'),
url: null,
width: 'auto',
- modal: true,
+ height: 'auto',
resizable: false,
dialogClass: 'crm-container crm-confirm',
close: function () {
yes: ts('Continue')
}
};
+ if (options && options.url) {
+ settings.resizable = true;
+ settings.height = '50%';
+ }
$.extend(settings, ($.isFunction(options) ? arguments[1] : options) || {});
+ settings = CRM.utils.adjustDialogDefaults(settings);
if (!settings.buttons && $.isPlainObject(settings.options)) {
$.each(settings.options, function(op, label) {
buttons.push({
// Create new dialog
if (settings.dialog) {
settings.dialog = CRM.utils.adjustDialogDefaults(settings.dialog);
- $('<div id="'+ settings.target.substring(1) +'"><div class="crm-loading-element">' + ts('Loading') + '...</div></div>').dialog(settings.dialog);
+ $('<div id="' + settings.target.substring(1) + '"></div>').dialog(settings.dialog);
+ }
+ if ($(settings.target).data('uiDialog')) {
$(settings.target)
.on('dialogclose', function() {
- if ($(this).attr('data-unsaved-changes') !== 'true') {
+ if (settings.dialog && $(this).attr('data-unsaved-changes') !== 'true') {
$(this).crmSnippet('destroy').dialog('destroy').remove();
}
})
{if $action eq 2 OR $action eq 1}
<tr class="crm-activity-form-block-recurring_activity">
<td colspan="2">
- {include file="CRM/Core/Form/RecurringEntity.tpl"}
- {literal}
- <script type="text/javascript">
- CRM.$(function($) {
- if ($('#activity_date_time').val() !== "" && $('#activity_date_time_time').val() !== "") {
- $('#repetition_start_date, input[id^="repetition_start_date_display_"]').val($('#activity_date_time').val());
- $('#repetition_start_date_time').val($('#activity_date_time_time').val());
- }
-
- $('input[id^="activity_date_time_display_"]').change(function() {
- $('#repetition_start_date, input[id^="repetition_start_date_display_"]').val($('#activity_date_time').val());
- });
-
- $('#activity_date_time_time').change(function() {
- $('#repetition_start_date_time').val($('#activity_date_time_time').val());
- });
-
- if ($('#start_action_offset').val() == "" && $('input[id^="repeat_absolute_date_display_"]').val() == "") {
- $('#recurring-entity-block').addClass('collapsed');
- }
- });
- </script>
- {/literal}
- {if $action eq 1}
- {literal}
- <script type="text/javascript">
- CRM.$(function($) {
- $('#recurring-entity-block div.crm-submit-buttons').css('display', 'none');
- });
- </script>
- {/literal}
- {/if}
+ {include file="CRM/Core/Form/RecurringEntity.tpl" recurringFormIsEmbedded=true}
</td>
</tr>
{/if}
{ts}Repeats{/ts}
{/htxt}
{htxt id="id-repeats"}
- {ts 1=$entityType}Access the drop-down menu here to select how frequently your %1 occurs. Options are:{/ts}
- <ul>
- <li>{ts}Hourly: repeats hourly or after every few hours{/ts}</li>
- <li>{ts 1=$entityType}Daily: repeats daily or after every few days{/ts}</li>
- <li>{ts 1=$entityType}Weekly: repeats on one or more days every week{/ts}</li>
- <li>{ts 1=$entityType}Monthly: repeats on one or more days every month{/ts}</li>
- <li>{ts 1=$entityType}Yearly: repeats yearly or after every few years{/ts}</li>
- </ul>
- {ts 1=$entityType}Example: You would select option "monthly", if your %1 occurs every month.{/ts}
-{/htxt}
-
-{htxt id="id-repeats-every-title"}
- {ts}Repeats every{/ts}
-{/htxt}
-{htxt id="id-repeats-every"}
- {ts}This option decides the repetition interval.{/ts}<br/>
- {ts 1=$entityType}Example: If your %1 repeats every 5 months, then you would select option 5.{/ts}
+ {ts 1=$entityType}Access the drop-down menus here to select how frequently your %1 occurs.{/ts}
+ {ts 1=$entityType}Example: You would select options "1 month", if your %1 occurs every month.{/ts}
{/htxt}
{htxt id="id-repeats-on-title"}
{/htxt}
{htxt id="id-ends-after"}
{ts 1=$entityType}Use this field to limit/end the repetition of the %1.{/ts}<br/>
- {ts 1=$entityType}Example: If you want to repeat an %1 for six months (i.e it repeats 6 times), then set 6 as a value for this field.{/ts}
+ {ts 1=$entityType}Example: If you want to repeat an %1 6 times, then set 6 as a value for this field.{/ts}
{/htxt}
{htxt id="id-ends-on-title"}
+--------------------------------------------------------------------+\r
*}\r
\r
-<div class="crm-core-form-recurringentity-block crm-accordion-wrapper" id="recurring-entity-block">\r
- <div class="crm-accordion-header">\r
- Repeat {if $entityType}{$entityType}{/if}\r
- </div>\r
- <div class="crm-accordion-body">\r
- <div class="crm-submit-buttons">\r
- {include file="CRM/common/formButtons.tpl" location="top"}\r
- </div>\r
- <table class="form-layout-compressed">\r
- <tr class="crm-core-form-recurringentity-block-repetition_start_date" id="tr-repetition_start_date">\r
- <td class="label">{$form.repetition_start_date.label}</td>\r
- <td>{include file="CRM/common/jcalendar.tpl" elementName=repetition_start_date}</td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-repetition_frequency_unit">\r
- <td class="label">{$form.repetition_frequency_unit.label} <span class="crm-marker" title="This field is required.">*</span></td>\r
- <td>{$form.repetition_frequency_unit.html} {help id="id-repeats" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-repetition_frequency_interval">\r
- <td class="label">{$form.repetition_frequency_interval.label} <span class="crm-marker" title="This field is required.">*</span></td>\r
- <td>{$form.repetition_frequency_interval.html} <span id="repeats-every-text">hour(s)</span> {help id="id-repeats-every" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
- </td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-start_action_condition">\r
- <td class="label">\r
- <label for="repeats_on">{$form.start_action_condition.label}: </label>\r
- </td>\r
- <td>\r
- {$form.start_action_condition.html} {help id="id-repeats-on" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
- </td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-repeats_by">\r
- <td class="label">{$form.repeats_by.label}</td>\r
- <td>{$form.repeats_by.1.html} {$form.limit_to.html} {help id="id-repeats-by-month" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
- </td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-repeats_by">\r
- <td class="label"></td>\r
- <td>{$form.repeats_by.2.html} {$form.entity_status_1.html} {$form.entity_status_2.html} {help id="id-repeats-by-week" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
- </td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-ends">\r
- <td class="label">{$form.ends.label} <span class="crm-marker" title="This field is required.">*</span></td>\r
- <td>{$form.ends.1.html} {$form.start_action_offset.html} occurrences {help id="id-ends-after" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-absolute_date">\r
- <td class="label"></td>\r
- <td>{$form.ends.2.html} {include file="CRM/common/jcalendar.tpl" elementName=repeat_absolute_date} {help id="id-ends-on" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
- </td>\r
- </tr>\r
- <tr class="crm-core-form-recurringentity-block-exclude_date">\r
- <td class="label">{$form.exclude_date.label}</td>\r
- <td> {include file="CRM/common/jcalendar.tpl" elementName=exclude_date}\r
- {$form.add_to_exclude_list.html} {$form.remove_from_exclude_list.html}\r
- {$form.exclude_date_list.html} {help id="id-exclude-date" entityType=$entityType file="CRM/Core/Form/RecurringEntity.hlp"}\r
- </td>\r
- </tr>\r
- <tr>\r
- <td class="label bold">{ts}Summary:{/ts}</td>\r
- <td><span id="rec-summary"></span></td>\r
- </tr>\r
- </table>\r
+<div class="crm-core-form-recurringentity-block crm-accordion-wrapper{if $recurringFormIsEmbedded && !$scheduleReminderId} collapsed{/if}" id="recurring-entity-block">\r
+ <div class="crm-accordion-header">\r
+ {ts 1=$recurringEntityType}Repeat %1{/ts}\r
+ </div>\r
+ <div class="crm-accordion-body">\r
+ {if !$recurringFormIsEmbedded}\r
+ <div class="crm-submit-buttons">\r
+ {include file="CRM/common/formButtons.tpl" location="top"}\r
+ </div>\r
+ {/if}\r
+ <table class="form-layout-compressed">\r
+ <tr class="crm-core-form-recurringentity-block-repetition_start_date" id="tr-repetition_start_date">\r
+ <td class="label">{$form.repetition_start_date.label}</td>\r
+ <td>{include file="CRM/common/jcalendar.tpl" elementName=repetition_start_date}</td>\r
+ </tr>\r
+ <tr class="crm-core-form-recurringentity-block-repetition_frequency">\r
+ <td class="label">{$form.repetition_frequency_unit.label} <span class="crm-marker">*</span> {help id="id-repeats" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+ <td>{$form.repetition_frequency_interval.html} {$form.repetition_frequency_unit.html}</td>\r
+ </tr>\r
+ <tr class="crm-core-form-recurringentity-block-start_action_condition">\r
+ <td class="label">\r
+ <label for="repeats_on">{$form.start_action_condition.label} {help id="id-repeats-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</label>\r
+ </td>\r
+ <td>\r
+ {$form.start_action_condition.html}\r
+ </td>\r
+ </tr>\r
+ <tr class="crm-core-form-recurringentity-block-repeats_by">\r
+ <td class="label">{$form.repeats_by.label} {help id="id-repeats-by-month" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+ <td>{$form.repeats_by.1.html} {$form.limit_to.html}\r
+ </td>\r
+ </tr>\r
+ <tr class="crm-core-form-recurringentity-block-repeats_by">\r
+ <td class="label">{help id="id-repeats-by-week" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+ <td>{$form.repeats_by.2.html} {$form.entity_status_1.html} {$form.entity_status_2.html}\r
+ </td>\r
+ </tr>\r
+ <tr class="crm-core-form-recurringentity-block-ends">\r
+ <td class="label">{$form.ends.label} <span class="crm-marker">*</span> {help id="id-ends-after" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+ <td>{$form.ends.1.html} {$form.start_action_offset.html} {ts}occurrences{/ts}</td>\r
+ </tr>\r
+ <tr class="crm-core-form-recurringentity-block-absolute_date">\r
+ <td class="label"> {help id="id-ends-on" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+ <td>{$form.ends.2.html} {include file="CRM/common/jcalendar.tpl" elementName=repeat_absolute_date}\r
+ </td>\r
+ </tr>\r
+ <tr class="crm-core-form-recurringentity-block-exclude_date">\r
+ <td class="label">{$form.exclude_date_list.label} {help id="id-exclude-date" entityType=$recurringEntityType file="CRM/Core/Form/RecurringEntity.hlp"}</td>\r
+ <td>{$form.exclude_date_list.html}</td>\r
+ </tr>\r
+ </table>\r
+ {if !$recurringFormIsEmbedded}\r
<div class="crm-submit-buttons">\r
{include file="CRM/common/formButtons.tpl" location="bottom"}\r
</div>\r
- </div>\r
-</div>\r
-<div id="preview-dialog" class="hiddenElement">\r
- <div id="generated_dates" class="show-block"></div>\r
+ {/if}\r
+ </div>\r
</div>\r
{literal}\r
<script type="text/javascript">\r
- cj(document).ready(function() {\r
- cj('#repetition_start_date_display').closest("tr").hide();\r
- /****** On load "Repeats By" and "Repeats On" blocks should be hidden if dropdown value is not week or month****** (Edit Mode)***/\r
- if (cj('#repetition_frequency_unit').val() == "week") {\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').show();\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
- } else if (cj('#repetition_frequency_unit').val() == "month") {\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').show();\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
- } else {\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
- }\r
- cj("#repeats-every-text").html(cj('#repetition_frequency_unit').val()+'(s)');\r
-\r
- /***********On Load Set Ends Value (Edit Mode) **********/\r
- if (cj('input:radio[name=ends]:checked').val() == 1) {\r
- cj('#start_action_offset').removeAttr('disabled').attr('enabled','enabled');\r
- cj('#repeat_absolute_date_display').removeAttr("enabled").attr('disabled','disabled');\r
- cj('#repeat_absolute_date_display').val('');\r
- } else if (cj('input:radio[name=ends]:checked').val() == 2) {\r
- cj('#repeat_absolute_date_display').removeAttr("disabled").attr('enabled','enabled');\r
- cj('#start_action_offset').removeAttr('enabled').attr('disabled','disabled');\r
- cj('#start_action_offset').val('');\r
- } else {\r
- cj('#start_action_offset').removeAttr('enabled').attr('disabled','disabled');\r
- cj('#repeat_absolute_date_display').removeAttr('enabled').attr('disabled','disabled');\r
+ CRM.$(function($) {\r
+ var $form = $('form.{/literal}{$form.formClass}{literal}');\r
+\r
+ // Prevent html5 errors\r
+ $form.attr('novalidate', 'novalidate');\r
+\r
+ function changeFrequencyUnit() {\r
+ switch ($(this).val()) {\r
+ case 'week':\r
+ //Show "Repeats On" block when week is selected\r
+ $('.crm-core-form-recurringentity-block-start_action_condition', $form).show();\r
+ $('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();\r
+ break;\r
+ case 'month':\r
+ //Show "Repeats By" block when month is selected\r
+ $('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();\r
+ $('.crm-core-form-recurringentity-block-repeats_by td', $form).show();\r
+ break;\r
+ default:\r
+ $('.crm-core-form-recurringentity-block-start_action_condition', $form).hide();\r
+ $('.crm-core-form-recurringentity-block-repeats_by td', $form).hide();\r
+ }\r
}\r
+ $('#repetition_frequency_unit', $form).each(changeFrequencyUnit).change(changeFrequencyUnit);\r
\r
- /******On Load set Repeats by section******************/\r
- if (cj('input:radio[name=repeats_by]:checked').val() == 1) {\r
- cj('#limit_to').removeAttr('disabled').attr('enabled','enabled');\r
- cj('#entity_status_1, #entity_status_2').removeAttr("enabled").attr('disabled','disabled');\r
- } else if (cj('input:radio[name=repeats_by]:checked').val() == 2) {\r
- cj('#entity_status_1, #entity_status_2').removeAttr("disabled").attr('enabled','enabled');\r
- cj('#limit_to').removeAttr('enabled').attr('disabled','disabled');\r
- } else {\r
- //Just in-case block shows up, disable it\r
- cj('#limit_to, #entity_status_1, #entity_status_2').removeAttr('enabled').attr('disabled','disabled');\r
+ function disableUnselected() {\r
+ $('input:radio[name=ends], input[name=repeats_by]', $form).not(':checked').siblings(':input').prop('disabled', true);\r
}\r
+ disableUnselected();\r
\r
- cj('#repetition_frequency_unit').change(function () {\r
- if (cj(this).val()==='hour') {\r
- cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
- } else if (cj(this).val()==='day') {\r
- cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
- } else if (cj(this).val()==='week') {\r
- cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
- //Show "Repeats On" block when week is selected\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').show();\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
- } else if (cj(this).val()==='month') {\r
- cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
- //Show "Repeats By" block when month is selected\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').show();\r
- } else if (cj(this).val()==='year') {\r
- cj('#repeats-every-text').html(cj(this).val()+'(s)');\r
- cj('.crm-core-form-recurringentity-block-start_action_condition').hide();\r
- cj('.crm-core-form-recurringentity-block-repeats_by td').hide();\r
- }\r
- });\r
-\r
- // For "Ends" block\r
- cj('input:radio[name=ends]').click(function() {\r
- if (cj(this).val() == 1) {\r
- cj('#start_action_offset').removeAttr('disabled').attr('enabled','enabled');\r
- cj('#repeat_absolute_date_display').val('');\r
- } else if (cj(this).val() == 2) {\r
- cj('#repeat_absolute_date_display').removeAttr('disabled').attr('enabled','enabled');\r
- cj('#start_action_offset').val('');\r
- } else {\r
- cj('#repeat_absolute_date_display').removeAttr('enabled').attr('disabled','disabled');\r
- }\r
- });\r
-\r
- //For "Repeats By" block\r
- cj('input:radio[name=repeats_by]').click(function() {\r
- if (cj(this).val() == 1) {\r
- cj('#limit_to').removeAttr('disabled').attr('enabled','enabled');\r
- } else {\r
- cj('#limit_to').removeAttr('enabled').attr('disabled','disabled');\r
- }\r
- if (cj(this).val() == 2) {\r
- cj('#entity_status_1').removeAttr('disabled').attr('enabled','enabled');\r
- cj('#entity_status_2').removeAttr('disabled').attr('enabled','enabled');\r
- } else {\r
- cj('#entity_status_1').removeAttr('enabled').attr('disabled','disabled');\r
- cj('#entity_status_2').removeAttr('enabled').attr('disabled','disabled');\r
- }\r
+ $('input:radio[name=ends], input[name=repeats_by]', $form).click(function() {\r
+ $(this).siblings(':input').prop('disabled', false).filter(':visible').addClass('required').focus();\r
+ disableUnselected();\r
});\r
\r
- //Select all options in selectbox before submitting\r
- cj(this).submit(function() {\r
- cj('#exclude_date_list option').attr('selected',true);\r
-\r
- //Check form for values submitted\r
- if (cj('input[name=ends]:checked').val() == 1) {\r
- if (cj('#start_action_offset').val() == "") {\r
- if (!cj('span#start_action_offset-error').length) {\r
- cj('#start_action_offset').after('<span id ="start_action_offset-error" class="crm-error"> This is a required field.</span>');\r
- //Check if other message already present, hide it\r
- cj('span#repeat_absolute_date_display-error').toggle();\r
- }\r
- return false;\r
- }\r
- } else if (cj('input[name=ends]:checked').val() == 2) {\r
- if (cj('#repeat_absolute_date_display').val() == "") {\r
- if (!cj('span#repeat_absolute_date_display-error').length) {\r
- cj('#repeat_absolute_date_display').after('<span id="repeat_absolute_date_display-error" class="crm-error"> This is a required field.</span>');\r
- //Check if other message already present, hide it\r
- cj('span#start_action_offset-error').toggle();\r
- }\r
- return false;\r
- }\r
- }\r
-\r
- });\r
+ function validate() {\r
+ var valid = $(':input', '#recurring-entity-block').valid(),\r
+ modified = CRM.utils.initialValueChanged('#recurring-entity-block');\r
+ $('#allowRepeatConfigToSubmit', $form).val(valid && modified ? '1' : '0');\r
+ return valid;\r
+ }\r
\r
- //Detect changes in Repeat configuration field\r
- var unsavedChanges = false;\r
- cj('div.crm-core-form-recurringentity-block').on('change', function() {\r
- unsavedChanges = true;\r
- });\r
+ function getDisplayDate(date) {\r
+ return $.datepicker.formatDate(CRM.config.dateInputFormat, $.datepicker.parseDate('yy-mm-dd', date));\r
+ }\r
\r
- //If there are changes in repeat configuration, enable save button\r
- //Dialog for preview repeat Configuration dates\r
- cj('#preview-dialog').dialog({ autoOpen: false });\r
- function previewDialog() {\r
- cj('#exclude_date_list option').attr('selected',true);\r
- //Copy exclude dates\r
- var dateTxt=[];\r
- cj('#exclude_date_list option:selected').each(function() {\r
- dateTxt.push(cj(this).text());\r
+ // Combine select2 and datepicker into a multi-select-date widget\r
+ $('#exclude_date_list', $form).crmSelect2({\r
+ multiple: true,\r
+ data: [],\r
+ initSelection: function(element, callback) {\r
+ var values = [];\r
+ $.each($(element).val().split(','), function(k, v) {\r
+ values.push({\r
+ text: getDisplayDate(v),\r
+ id: v\r
+ });\r
});\r
- var completeDateText = dateTxt.join(',');\r
- cj('#copyExcludeDates').val(completeDateText);\r
-\r
- cj('#generated_dates').html('').html('<div class="crm-loading-element"><span class="loading-text">{/literal}{ts escape='js'}Just a moment, generating dates{/ts}{literal}...</span></div>');\r
- cj('#preview-dialog').dialog('open');\r
- cj('#preview-dialog').dialog({\r
- title: 'Confirm dates',\r
- width: '650',\r
- position: 'center',\r
- //draggable: false,\r
- buttons: {\r
- Ok: function() {\r
- cj(this).dialog( "close" );\r
- cj('form#Repeat, form#Activity').submit();\r
- },\r
- Cancel: function() { //cancel\r
- cj(this).dialog( "close" );\r
+ callback(values);\r
+ }\r
+ })\r
+ .on('select2-opening', function(e) {\r
+ var $el = $(this);\r
+ // Prevent select2 from opening and show a datepicker instead\r
+ e.preventDefault();\r
+ $('.select2-search-field input', $el.select2('container'))\r
+ .datepicker()\r
+ .datepicker('show')\r
+ .off('.crmDate')\r
+ .on('change.crmDate', function() {\r
+ if ($(this).val()) {\r
+ var date = $(this).datepicker('getDate'),\r
+ data = $el.select2('data') || [];\r
+ data.push({\r
+ text: $.datepicker.formatDate(CRM.config.dateInputFormat, date),\r
+ id: $.datepicker.formatDate('yy-mm-dd', date)\r
+ });\r
+ $el.select2('data', data);\r
}\r
- }\r
- });\r
- var ajaxurl = CRM.url("civicrm/ajax/recurringentity/generate-preview");\r
- var entityID = parseInt('{/literal}{$currentEntityId}{literal}');\r
- var entityTable = '{/literal}{$entityTable}{literal}';\r
- if (entityTable != "") {\r
- ajaxurl += "?entity_table="+entityTable;\r
- }\r
- if (entityID != "") {\r
- ajaxurl += "&entity_id="+entityID;\r
- }\r
- var formData = cj('form').serializeArray();\r
- cj.ajax({\r
- dataType: "json",\r
- type: "POST",\r
- data: formData,\r
- url: ajaxurl,\r
- success: function (result) {\r
- if (Object.keys(result).length > 0) {\r
- var errors = [];\r
- var participantData = [];\r
- var html = 'Based on your repeat configuration, here is the list of dates. Do you wish to create a recurring set with these dates?<br/><table id="options" class="display"><thead><tr><th></th><th>Start date</th><th id="th-end-date">End date</th></tr><thead>';\r
- var count = 1;\r
- for(var i in result) {\r
- if (i != 'errors') {\r
- if (i == 'participantData') {\r
- participantData = result.participantData;\r
- break;\r
- }\r
- var start_date = result[i].start_date;\r
- var end_date = result[i].end_date;\r
+ });\r
+ });\r
\r
- var end_date_text = '';\r
- if (end_date !== undefined) {\r
- end_date_text = '<td>'+end_date+'</td>';\r
- }\r
- html += '<tr><td>'+count+'</td><td>'+start_date+'</td>'+end_date_text+'</tr>';\r
- count = count + 1;\r
- } else {\r
- errors = result.errors;\r
- }\r
- }\r
- html += '</table>';\r
- var warningHtml = '';\r
- if (Object.keys(participantData).length > 0) {\r
- warningHtml += '<div class="messages status no-popup"><div class="icon inform-icon"></div> There are registrations for the repeating events already present in the set, continuing with the process would unlink them and repeating events without registration would be trashed. </div><table id="options" class="display"><thead><tr><th>Event ID</th><th>Event</th><th>Participant Count</th></tr><thead>';\r
- for (var id in participantData) {\r
- for(var data in participantData[id]) {\r
- warningHtml += '<tr><td>'+id+'</td><td> <a href="{/literal}{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id="}{literal}'+id+'{/literal}{literal}">'+data+'</a></td><td><a href="{/literal}{crmURL p='civicrm/event/search' q="reset=1&force=1&status=true&event="}{literal}'+id+'{/literal}{literal}">'+participantData[id][data]+'</a></td></tr>';\r
- }\r
- }\r
- warningHtml += '</table><br/>';\r
- }\r
- if (errors.length > 0) {\r
- html = '';\r
- for (var j = 0; j < errors.length; j++) {\r
- html += '<span class="crm-error">* ' + errors[j] + '</span><br/>';\r
- }\r
- }\r
- if (warningHtml != "") {\r
- cj('#generated_dates').append(warningHtml).append(html);\r
- } else {\r
- cj('#generated_dates').html(html);\r
- }\r
- if (end_date_text == "") {\r
- cj('#th-end-date').hide();\r
- }\r
- if (cj("#preview-dialog").height() >= 300) {\r
- cj('#preview-dialog').css('height', '300');\r
- cj('#preview-dialog').css('overflow-y', 'auto');\r
- }\r
- } else {\r
- cj('div.ui-dialog-buttonset button span:contains(Ok)').hide();\r
- cj('#generated_dates').append("<span class='crm-error'>Sorry, no dates could be generated for the given criteria!</span>");\r
- }\r
- },\r
- complete: function() {\r
- cj('div.crm-loading-element').hide();\r
- }\r
+ // Dialog for preview repeat Configuration dates\r
+ function previewDialog() {\r
+ // Set default value for start date on activity forms before generating preview\r
+ if (!$('#repetition_start_date', $form).val() && $('#activity_date_time', $form).val()) {\r
+ $('#repetition_start_date', $form)\r
+ .val($('#activity_date_time', $form).val())\r
+ .next().val($('#activity_date_time', $form).next().val())\r
+ .siblings('.hasTimeEntry').val($('#activity_date_time', $form).siblings('.hasTimeEntry').val());\r
+ }\r
+ var payload = $form.serialize() + '{/literal}&entity_table={$entityTable}&entity_id={$currentEntityId}{literal}';\r
+ CRM.confirm({\r
+ width: '50%',\r
+ url: CRM.url("civicrm/recurringentity/preview", payload)\r
+ }).on('crmConfirm:yes', function() {\r
+ $form.submit();\r
});\r
- return false;\r
}\r
\r
- cj('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').click( function () {\r
- return previewDialog();\r
+ $('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').click(function (e) {\r
+ if (validate()) {\r
+ previewDialog();\r
+ }\r
+ e.preventDefault();\r
});\r
\r
- cj('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click( function () {\r
- //Process this only when repeat is configured. We need to do this test here as there is a common save for activity.\r
- var isRepeatConfigured = '{/literal}{$scheduleReminderId}{literal}';\r
- if (isRepeatConfigured) {\r
- if (unsavedChanges) {\r
- cj('#allowRepeatConfigToSubmit').val('1');\r
- //Set this variable to decide which dialog box to show\r
- cj.data( document.body, "preview-dialog", true );\r
- return previewDialog();\r
- }\r
- else {\r
- cj.data( document.body, "preview-dialog", false );\r
- return false;\r
- }\r
- }\r
- else {\r
- if (unsavedChanges) {\r
- cj('#allowRepeatConfigToSubmit').val('1');\r
- return previewDialog();\r
+ $('#_qf_Activity_upload-top, #_qf_Activity_upload-bottom').click(function (e) {\r
+ if (CRM.utils.initialValueChanged('#recurring-entity-block')) {\r
+ e.preventDefault();\r
+ if (validate()) {\r
+ previewDialog();\r
}\r
}\r
});\r
\r
- //Build Summary\r
- var finalSummary = '';\r
- var numberText = '';\r
- var interval = cj('#repetition_frequency_interval').val() + ' ';\r
- if (cj('#repetition_frequency_interval').val() == 1) {\r
- interval = '';\r
- } else {\r
- numberText = 's';\r
- }\r
- finalSummary = "Every " + interval + cj('#repetition_frequency_unit option:selected').val() + numberText;\r
-\r
- //Case Week\r
- var dayOfWeek = new Array();\r
- if (cj('#repetition_frequency_unit option:selected').val() == "week") {\r
- cj("input[name^='start_action_condition']:checked").each(function() {\r
- var tempArray = new Array();\r
- var thisID = cj(this).attr('id');\r
- tempArray = thisID.split('_');\r
- dayOfWeek.push(tempArray[3].substr(0, 1).toUpperCase() + tempArray[3].substr(1).toLowerCase());\r
- });\r
- finalSummary += ' on ' + dayOfWeek.join();\r
- }\r
-\r
- //Case Monthly\r
- if (cj('#repetition_frequency_unit option:selected').val() == "month") {\r
- if (cj('input:radio[name=repeats_by]:checked').val() == 1) {\r
- finalSummary += ' on day ' + cj('#limit_to').val();\r
- }\r
- if (cj('input:radio[name=repeats_by]:checked').val() == 2) {\r
- finalSummary += ' on ' + cj('#entity_status_1').val().substr(0, 1).toUpperCase() + cj('#entity_status_1').val().substr(1).toLowerCase() + ' ' + cj('#entity_status_2').val().substr(0, 1).toUpperCase() + cj('#entity_status_2').val().substr(1).toLowerCase();\r
- }\r
- }\r
+ // Enable/disable form buttons when not embedded in another form\r
+ $form.on('change', function() {\r
+ $('#_qf_Repeat_submit-top, #_qf_Repeat_submit-bottom').prop('disabled', !CRM.utils.initialValueChanged('#recurring-entity-block'));\r
+ });\r
\r
- //Case Ends\r
- if (cj('input:radio[name=ends]:checked').val() == 1) {\r
- var timeText = ''\r
- if (cj('#start_action_offset').val() != 1) {\r
- timeText = cj('#start_action_offset').val() + ' times';\r
- } else {\r
- timeText = ' once';\r
- }\r
- finalSummary += ', ' + timeText;\r
- }\r
- if (cj('input:radio[name=ends]:checked').val() == 2) {\r
- var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");\r
- var date = new Date(cj('#repeat_absolute_date_display').val());\r
- function addOrdinal(d) {\r
- if (d>3 && d<21) return 'th';\r
- switch (d % 10) {\r
- case 1: return "st";\r
- case 2: return "nd";\r
- case 3: return "rd";\r
- default: return "th";\r
- }\r
- }\r
- var newDate = monthNames[(date.getMonth())] + ' ' + date.getDate()+ addOrdinal() + ' ' + date.getFullYear();\r
- finalSummary += ', untill '+ newDate;\r
+ // Pluralize frequency options\r
+ var recurringFrequencyOptions = {/literal}{$recurringFrequencyOptions|@json_encode}{literal};\r
+ function pluralizeUnits() {\r
+ CRM.utils.setOptions($('[name=repetition_frequency_unit]', $form),\r
+ $(this).val() === '1' ? recurringFrequencyOptions.single : recurringFrequencyOptions.plural);\r
}\r
+ $('[name=repetition_frequency_interval]', $form).each(pluralizeUnits).change(pluralizeUnits);\r
\r
- //Build/Attach final Summary\r
- cj('#rec-summary').html(finalSummary);\r
-\r
-});\r
-\r
- //Exclude list function\r
- function addToExcludeList(val) {\r
- if (val !== "") {\r
- var exists = false;\r
- for(var i = 0, opts = document.getElementById('exclude_date_list').options; i < opts.length; ++i) {\r
- if (opts[i].text == val) {\r
- exists = true;\r
- break;\r
- }\r
- }\r
- if (exists == false) {\r
- cj('#exclude_date_list').append('<option>'+val+'</option>');\r
- }\r
- }\r
- }\r
+ });\r
\r
- function removeFromExcludeList(sourceID) {\r
- var src = document.getElementById(sourceID);\r
- for(var count= src.options.length-1; count >= 0; count--) {\r
- if (src.options[count].selected == true) {\r
- try{\r
- src.remove(count, null);\r
- }catch(error) {\r
- src.remove(count);\r
- }\r
- }\r
- }\r
- }\r
</script>\r
{/literal}\r
-{*Hide Summary*}\r
-{if empty($scheduleReminderId)}\r
- {literal}\r
- <script type="text/javascript">\r
- cj(document).ready(function() {\r
- if (cj('#rec-summary').length) {\r
- cj('#rec-summary').parent().parent().hide();\r
- }\r
- });\r
- </script>\r
- {/literal}\r
-{/if}\r
--- /dev/null
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.6 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*}
+{if !empty($participantData)}
+ <div class="messages status no-popup">
+ <div class="icon ui-icon-alert"></div>
+ {ts}There are participants registered for repeating events being removed from the set. Those with participants will be converted to standalone events, and those without registration will be deleted.{/ts}
+ </div>
+ <table class="display">
+ <thead><tr>
+ <th>{ts}Event ID{/ts}</th>
+ <th>{ts}Event{/ts}</th>
+ <th>{ts}Participant Count{/ts}</th>
+ </tr><thead>
+ <tbody>
+ {foreach from=$participantData item="row" key="id"}
+ {foreach from=$row item="count" key="data"}
+ <tr class="{cycle values="odd-row,even-row"}">
+ <td>{$id}</td>
+ <td><a href="{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id=$id"}">{$data}</a></td>
+ <td><a href="{crmURL p='civicrm/event/search' q="reset=1&force=1&status=true&event=$id"}">{$count}</a></td>
+ </tr>
+ {/foreach}
+ {/foreach}
+ </tbody>
+{/if}
+
+<h3>
+ {ts}A recurring set will be created with the following dates.{/ts}
+</h3>
+<table class="display row-highlight">
+ <thead><tr>
+ <th>#</th>
+ <th>{ts}Start date{/ts}</th>
+ {if $endDates}<th>{ts}End date{/ts}</th>{/if}
+ </tr><thead>
+ <tbody>
+ {foreach from=$dates item="row" key="count"}
+ <tr class="{cycle values="odd-row,even-row"}">
+ <td>{$count + 1}</td>
+ <td>{$row.start_date}</td>
+ {if $endDates}<td>{$row.end_date}</td>{/if}
+ </tr>
+ {/foreach}
+ </tbody>
+</table>
\ No newline at end of file
| see the CiviCRM license FAQ at http://civicrm.org/licensing |\r
+--------------------------------------------------------------------+\r
*}\r
+{if $hasParent || $isRepeatingEntity || $scheduleReminderId}\r
+ {capture assign='entity_type'}{$recurringEntityType|lower}{/capture}\r
+ <script type="text/template" id="recurring-dialog-tpl">\r
+ <div class="recurring-dialog">\r
+ <h4>{ts}How should this change affect others in the series?{/ts}</h4>\r
+ <div>\r
+ <input type="radio" id="recur-only-this-entity" name="recur_mode" value="1">\r
+ <label for="recur-only-this-entity">{ts 1=$entity_type}Only this %1{/ts}</label>\r
+ <div class="description">{ts}All others in the series will remain unchanged.{/ts}</div>\r
\r
-<div id="recurring-dialog" class="hiddenElement">\r
- {ts}How would you like this change to affect other entities in the repetition set?{/ts}<br/><br/>\r
- <div class="show-block">\r
- <div class="recurring-dialog-inner-wrapper">\r
- <div class="recurring-dialog-inner-left">\r
- <button class="recurring-dialog-button only-this-event">{ts}Only this entity{/ts}</button>\r
- </div>\r
- <div class="recurring-dialog-inner-right">{ts}All other entities in the series will remain same.{/ts}</div>\r
- </div>\r
- <div class="recurring-dialog-inner-wrapper">\r
- <div class="recurring-dialog-inner-left">\r
- <button class="recurring-dialog-button this-and-all-following-event">{ts}This and Following entities{/ts}</button>\r
- </div>\r
- <div class="recurring-dialog-inner-right">{ts}Change applies to this and all the following entities.{/ts}</div>\r
- </div>\r
- <div class="recurring-dialog-inner-wrapper">\r
- <div class="recurring-dialog-inner-left">\r
- <button class="recurring-dialog-button all-events">{ts}All the entities{/ts}</button>\r
- </div>\r
- <div class="recurring-dialog-inner-right">{ts}Change applies to all the entities in the series.{/ts}</div>\r
- </div>\r
+ <input type="radio" id="recur-this-and-all-following-entity" name="recur_mode" value="2">\r
+ <label for="recur-this-and-all-following-entity">{ts 1=$entity_type}This %1 onwards{/ts}</label>\r
+ <div class="description">{ts 1=$entity_type}Change applies to this %1 and all that come after it.{/ts}</div>\r
+\r
+ <input type="radio" id="recur-all-entity" name="recur_mode" value="3">\r
+ <label for="recur-all-entity">{ts 1=$entity_type}Every %1{/ts}</label>\r
+ <div class="description">{ts 1=$entity_type}Change applies to every %1 in the series.{/ts}</div>\r
+ </div>\r
+ <div class="status help"><div class="icon ui-icon-lightbulb"></div>{ts}Changes to date or time will <em>not</em> be applied to others in the series.{/ts}</div>\r
</div>\r
- <div class="status"><div class="icon ui-icon-lightbulb"></div> Changes to date or time will NOT be applied to other entities in the series.</div>\r
-</div>\r
-{if $hasParent || $isRepeatingEntity}\r
+ </script>\r
{literal}\r
<script type="text/javascript">\r
CRM.$(function($) {\r
- var $dialog;\r
- /** Add your linked entity mapper here **/\r
- var mapper = {'CRM_Event_Form_ManageEvent_EventInfo': '',\r
- 'CRM_Event_Form_ManageEvent_Location': '',\r
- 'CRM_Event_Form_ManageEvent_Fee': '',\r
- 'CRM_Event_Form_ManageEvent_Registration': '',\r
- 'CRM_Friend_Form_Event': 'civicrm_tell_friend',\r
- 'CRM_PCP_Form_Event': 'civicrm_pcp_block',\r
- 'CRM_Activity_Form_Activity': ''\r
- };\r
+ var $form, formClass,\r
+ /** Add your linked entity mapper here **/\r
+ mapper = {\r
+ 'CRM_Event_Form_ManageEvent_EventInfo': '',\r
+ 'CRM_Event_Form_ManageEvent_Location': '',\r
+ 'CRM_Event_Form_ManageEvent_Fee': '',\r
+ 'CRM_Event_Form_ManageEvent_Registration': '',\r
+ 'CRM_Friend_Form_Event': 'civicrm_tell_friend',\r
+ 'CRM_PCP_Form_Event': 'civicrm_pcp_block',\r
+ 'CRM_Activity_Form_Activity': ''\r
+ };\r
+\r
function cascadeChangesDialog() {\r
- $dialog = $("#recurring-dialog").dialog({\r
- title: 'How does this change affect other repeating entities in the set?',\r
- modal: true,\r
- width: '650',\r
- buttons: {\r
- Cancel: function() { //cancel\r
- $( this ).dialog( "close" );\r
- }\r
- }\r
- }).dialog('open');\r
+ CRM.confirm({\r
+ title: "{/literal}{ts escape='js' 1=$entity_type}Update recurring %1{/ts}{literal}",\r
+ message: $('#recurring-dialog-tpl').html()\r
+ })\r
+ .on('crmConfirm:yes', updateMode)\r
+ .on('click change', 'input[name=recur_mode]', function() {\r
+ $('button[data-op=yes]').prop('disabled', false);\r
+ })\r
+ .parent().find('button[data-op=yes]').prop('disabled', true)\r
}\r
- var form = '';\r
- $('#crm-main-content-wrapper').on('click', 'div.crm-submit-buttons span.crm-button input[value="Save"], div.crm-submit-buttons span.crm-button input[value="Save and Done"]', function() {\r
- form = $(this).parents('form:first').attr('class');\r
- if( form != "" && mapper.hasOwnProperty(form) ){\r
- cascadeChangesDialog();\r
- return false;\r
- }\r
- });\r
-\r
- $("#_qf_Activity_upload-top, #_qf_Activity_upload-bottom").click(function() {\r
- form = $(this).parents('form:first').attr('class');\r
- if( form != "" && mapper.hasOwnProperty(form) ){\r
- var showPreviewDialog = $.data( document.body, "preview-dialog");\r
- if (showPreviewDialog == false) {\r
- cascadeChangesDialog();\r
- }\r
- return false;\r
- }\r
- });\r
\r
- $(".only-this-event").click(function() {\r
- updateMode(1);\r
- });\r
-\r
- $(".this-and-all-following-event").click(function() {\r
- updateMode(2);\r
- });\r
-\r
- $(".all-events").click(function() {\r
- updateMode(3);\r
+ // Intercept form submissions and check if they will impact the recurring entity\r
+ // This ought to attach the handler to the the dialog if we're in a popup, or the page wrapper if we're not\r
+ $('#recurring-dialog-tpl').closest('.crm-container').on('click', '.crm-form-submit.validate', function(e) {\r
+ $form = $(this).closest('form');\r
+ var className = ($form.attr('class') || '').match(/CRM_\S*/);\r
+ formClass = className && className[0];\r
+ if (formClass && mapper.hasOwnProperty(formClass) &&\r
+ // For activities, only show this if the changes were not made to the recurring settings\r
+ (formClass !== 'CRM_Activity_Form_Activity' || !CRM.utils.initialValueChanged('.crm-core-form-recurringentity-block'))\r
+ ) {\r
+ cascadeChangesDialog();\r
+ e.preventDefault();\r
+ }\r
});\r
\r
- function updateMode(mode) {\r
- var entityID = parseInt('{/literal}{$entityID}{literal}');\r
- var entityTable = '{/literal}{$entityTable}{literal}';\r
- if (entityID != "" && mode && mapper.hasOwnProperty(form) && entityTable !="") {\r
- var ajaxurl = CRM.url("civicrm/ajax/recurringentity/update-mode");\r
- var data = {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[form]};\r
- $.ajax({\r
- dataType: "json",\r
- data: data,\r
- url: ajaxurl,\r
- success: function (result) {\r
+ function updateMode() {\r
+ var mode = $('input[name=recur_mode]:checked', this).val(),\r
+ entityID = parseInt('{/literal}{$entityID}{literal}'),\r
+ entityTable = '{/literal}{$entityTable}{literal}';\r
+ if (entityID != "" && mode && mapper.hasOwnProperty(formClass) && entityTable !="") {\r
+ $.getJSON(CRM.url("civicrm/ajax/recurringentity/update-mode",\r
+ {mode: mode, entityId: entityID, entityTable: entityTable, linkedEntityTable: mapper[formClass]})\r
+ ).done(function (result) {\r
if (result.status != "" && result.status == 'Done') {\r
- $('#mainTabContainer div:visible Form, form.'+form).submit();\r
- $dialog.dialog('close');\r
+ $form.submit();\r
} else if (result.status != "" && result.status == 'Error') {\r
- var errorBox = confirm(ts("Mode could not be updated, save only this event?"));\r
- if (errorBox == true) {\r
- $('#mainTabContainer div:visible Form, form.'+form).submit();\r
- $dialog.dialog('close');\r
- } else {\r
- $dialog.dialog('close');\r
- return false;\r
+ if (confirm("{/literal}{ts escape='js' 1=$entity_type}Mode could not be updated, save only this %1?{/ts}{literal}")) {\r
+ $form.submit();\r
}\r
}\r
- }\r
- });\r
+ });\r
}\r
}\r
});\r
+--------------------------------------------------------------------+
*}
<div class="crm-block crm-form-block crm-event-manage-repeat-form-block">
-{include file="CRM/Core/Form/RecurringEntity.tpl"}
+{include file="CRM/Core/Form/RecurringEntity.tpl" recurringFormIsEmbedded=false}
{if $rows}
-<div id="event_status_id" class="crm-block crm-manage-events crm-accordion-wrapper">
+<div class="crm-block crm-manage-events crm-accordion-wrapper">
<div class="crm-accordion-header">{ts}Connected Repeating Events{/ts}</div>
<div class="crm-accordion-body">
{strip}
{else}
{assign var="highlight" value=""}
{/if}
- <tr id="row_{$row.id}" class="{if NOT $row.is_active} disabled{/if}">
+ <tr class="row_{$row.id}{if NOT $row.is_active} disabled{/if}">
<td class="crm-event_{$row.id}{$highlight}">
<a href="{crmURL p='civicrm/event/info' q="id=`$row.id`&reset=1"}"
title="{ts}View event info page{/ts}" class="bold">{$row.title}</a> ({ts}ID:{/ts} {$row.id})
{if $row.is_active eq 1}{ts}Yes{/ts} {else} {ts}No{/ts} {/if}
</td>
<td class="{$highlight}">
- <a href="{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id=`$row.id`"}">Manage Event</a>
+ <a class="action-item no-popup crm-hover-button" href="{crmURL p="civicrm/event/manage/settings" q="reset=1&action=update&id=`$row.id`"}">{ts}Settings{/ts}</a>
</td>
<td class="crm-event-start_date hiddenElement">{$row.start_date|crmDate}</td>
<td class="crm-event-end_date hiddenElement">{$row.end_date|crmDate}</td>
{/if}
{/foreach}
</table>
- {include file="CRM/common/pager.tpl" location="bottom"}
{/strip}
</div>
</div>
ts('Activity Subject') => 'activity_subject',
ts('Scheduled By') => 'source_contact',
ts('Scheduled Date') => 'activity_date',
- ts(' ') => 'activity_id',
- ts(' ') => 'activity_type_id',
- ts(' ') => 'case_id',
+ ' ' => 'activity_id',
+ ' ' => 'activity_type_id',
+ ' ' => 'case_id',
ts('Location') => 'location',
ts('Duration') => 'duration',
ts('Details') => 'details',
parent::__construct($formValues);
$this->normalize();
- $this->_columns = array(ts('') => 'contact_type',
- ts('') => 'contact_sub_type',
+ $this->_columns = array(
+ '' => 'contact_type',
+ '' => 'contact_sub_type',
ts('Name') => 'sort_name',
ts('Address') => 'street_address',
ts('City') => 'city',