Skip to content
Snippets Groups Projects
Commit fc4ac57f authored by Erik Hommel's avatar Erik Hommel
Browse files

Merge branch 'issue#33'

parents 7b6b8e75 21c51e1d
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Class for CiviRules Contribution Thank You Date Form
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license AGPL-3.0
*/
class CRM_CivirulesActions_Contribution_Form_ThankYouDate extends CRM_CivirulesActions_Form_Form {
/**
* Overridden parent method to build the form
*
* @access public
*/
public function buildQuickForm() {
$this->add('hidden', 'rule_action_id');
$this->addDate('thank_you_date', ts('Thank You Date'), FALSE, array('formatType' => 'custom'));
$this->addButtons(array(
array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE,),
array('type' => 'cancel', 'name' => ts('Cancel'))));
}
/**
* Overridden parent method to set default values
*
* @return array $defaultValues
* @access public
*/
public function setDefaultValues() {
$defaultValues = parent::setDefaultValues();
$defaultValues['rule_action_id'] = $this->ruleActionId;
if (!empty($this->ruleAction->action_params)) {
$data = unserialize($this->ruleAction->action_params);
}
if (empty($data['thank_you_date'])) {
list($defaultValues['thank_you_date']) = CRM_Utils_Date::setDateDefaults(date('Y-m-d'));
} else {
list($defaultValues['thank_you_date']) = CRM_Utils_Date::setDateDefaults($data['thank_you_date']);
}
return $defaultValues;
}
/**
* Overridden parent method to process form data after submitting
*
* @access public
*/
public function postProcess() {
$data['thank_you_date'] = $this->_submitValues['thank_you_date'];
$this->ruleAction->action_params = serialize($data);
$this->ruleAction->save();
parent::postProcess();
}
}
\ No newline at end of file
<?php
return array (
0 =>
array (
'name' => 'Civirules:Action.ThankYouDate',
'entity' => 'CiviRuleAction',
'params' =>
array (
'version' => 3,
'name' => 'ThankYouDate',
'label' => 'Set Thank You Date for Contribution',
'class_name' => 'CRM_CivirulesActions_Contribution_ThankYouDate',
'is_active' => 1
),
),
);
\ No newline at end of file
<?php
/**
* Class for CiviRules Set Thank You Date for Contribution Action
*
* @author Erik Hommel (CiviCooP) <erik.hommel@civicoop.org>
* @license AGPL-3.0
*/
class CRM_CivirulesActions_Contribution_ThankYouDate extends CRM_Civirules_Action {
/**
* Method processAction to execute the action
*
* @param CRM_Civirules_EventData_EventData $eventData
* @access public
*
*/
public function processAction(CRM_Civirules_EventData_EventData $eventData) {
$contribution = $eventData->getEntityData('Contribution');
$actionParams = $this->getActionParameters();
$params = array(
'id' => $contribution['id'],
'thankyou_date' => date('Ymd', strtotime($actionParams['thank_you_date']))
);
try {
civicrm_api3('Contribution', 'Create', $params);
} catch (CiviCRM_API3_Exception $ex) {}
}
/**
* Returns a redirect url to extra data input from the user after adding a action
*
* Return false if you do not need extra data input
*
* @param int $ruleActionId
* @return bool|string
* @access public
*/
public function getExtraDataInputUrl($ruleActionId) {
return CRM_Utils_System::url('civicrm/civirule/form/action/contribution/thankyoudate', 'rule_action_id='.$ruleActionId);
}
/**
* Returns a user friendly text explaining the condition params
* e.g. 'Older than 65'
*
* @return string
* @access public
*/
public function userFriendlyConditionParams() {
$return = '';
$params = $this->getActionParameters();
if (!empty($params['thank_you_date'])) {
$return = 'Thank You Date for Contribution will be set to : '.date('d M Y', strtotime($params['thank_you_date']));
}
return $return;
}
}
\ No newline at end of file
<h3>{$ruleActionHeader}</h3>
<div class="crm-block crm-form-block crm-civirule-rule_action-block-contribution-thank-you-date">
<div class="crm-section">
<div class="label">{$form.thank_you_date.label}</div>
<div class="content">{include file="CRM/common/jcalendar.tpl" elementName=thank_you_date}</div>
<div class="clear"></div>
</div>
</div>
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="bottom"}
</div>
......@@ -5,149 +5,181 @@
<page_callback>CRM_Civirules_Page_Rule</page_callback>
<title>Rule</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/rule</path>
<page_callback>CRM_Civirules_Form_Rule</page_callback>
<title>Rule</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/rule_condition</path>
<page_callback>CRM_Civirules_Form_RuleCondition</page_callback>
<title>RuleCondition</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/rule_action</path>
<page_callback>CRM_Civirules_Form_RuleAction</page_callback>
<title>RuleAction</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/datacomparison</path>
<page_callback>CRM_CivirulesConditions_Form_ValueComparison</page_callback>
<title>Value comparison</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/fieldvaluecomparison</path>
<page_callback>CRM_CivirulesConditions_Form_FieldValueComparison</page_callback>
<title>Value comparison</title>
<access_arguments>access CiviCRM</access_arguments>
<path>civicrm/civirule/form/condition/fieldvaluecomparison</path>
<page_callback>CRM_CivirulesConditions_Form_FieldValueComparison</page_callback>
<title>Value comparison</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/groupcontact/groupid</path>
<page_callback>CRM_CivirulesConditions_Form_GroupContact_GroupId</page_callback>
<title>Group Id</title>
<access_arguments>access CiviCRM</access_arguments>
<path>civicrm/civirule/form/condition/groupcontact/groupid</path>
<page_callback>CRM_CivirulesConditions_Form_GroupContact_GroupId</page_callback>
<title>Group Id</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contributionstatus</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_Status</page_callback>
<title>contribution status</title>
<access_arguments>access CiviCRM</access_arguments>
<path>civicrm/civirule/form/condition/contributionstatus</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_Status</page_callback>
<title>contribution status</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_totalcontributedamount</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_TotalContributedAmount</page_callback>
<title>Total contributed amount</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_financialtype</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_FinancialType</page_callback>
<title>financial type</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_distinctcontributingday</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_DistinctContributingDay</page_callback>
<title>distinct contributing days</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_countrecurring</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_CountRecurring</page_callback>
<title>recurring contribution collections</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_donorisrecurring</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_DonorIsRecurring</page_callback>
<title>donor has recurring contributions</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_recurringenddate</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_RecurringEndDate</page_callback>
<title>end date recurring contribution</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_specificamount</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_SpecificAmount</page_callback>
<title>specific amount count</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contact_ingroup</path>
<page_callback>CRM_CivirulesConditions_Form_Contact_InGroup</page_callback>
<title>In Group</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contact_hastag</path>
<page_callback>CRM_CivirulesConditions_Form_Contact_HasTag</page_callback>
<title>Has Tag</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/contribution_paidby</path>
<page_callback>CRM_CivirulesConditions_Form_Contribution_PaidBy</page_callback>
<title>paid by</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/action/groupcontact</path>
<page_callback>CRM_CivirulesActions_GroupContact_Form_GroupId</page_callback>
<title>Group contact</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/action/contribution/thankyoudate</path>
<page_callback>CRM_CivirulesActions_Contribution_Form_ThankYouDate</page_callback>
<title>Contribution Thank You Date</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/event/groupmembership</path>
<page_callback>CRM_CivirulesCronEvent_Form_GroupMembership</page_callback>
<title>Group membership</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/action/tag</path>
<page_callback>CRM_CivirulesActions_Tag_Form_TagId</page_callback>
<title>Tag</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/action/contact/subtype</path>
<page_callback>CRM_CivirulesActions_Contact_Form_Subtype</page_callback>
<title>Set contact subtype</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/action/activity</path>
<page_callback>CRM_CivirulesActions_Activity_Form_Activity</page_callback>
<title>Activity</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/activity_type</path>
<page_callback>CRM_CivirulesConditions_Form_Activity_Type</page_callback>
<title>Activity Type</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
<item>
<path>civicrm/civirule/form/condition/activity_contact_record_type</path>
<page_callback>CRM_CivirulesConditions_Form_Activity_RecordType</page_callback>
<title>Activity Contact Record Type</title>
<access_arguments>access CiviCRM</access_arguments>
<access_arguments>administer CiviCRM</access_arguments>
</item>
</menu>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment