Commit 846b1a9d authored by lobo's avatar lobo
Browse files

Merge pull request #40 from eileenmcnaughton/master

minor tidy ups
parents f5637cd5 92e4beb9
......@@ -58,8 +58,7 @@ class CRM_CiviDiscount_BAO_Item extends CRM_CiviDiscount_DAO_Item {
* @access public
* @static
*/
static function &add(&$params) {
require_once 'CRM/Utils/Date.php';
static function add(&$params) {
$item = new CRM_CiviDiscount_DAO_Item();
$item->code = $params['code'];
......
......@@ -49,7 +49,6 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
function preProcess() {
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, false, 0);
$this->_cloneID = CRM_Utils_Request::retrieve('cloneID', 'Positive', $this, false, 0);
require_once 'CRM/CiviDiscount/BAO/Item.php';
$this->set('BAOName', 'CRM_CiviDiscount_BAO_Item');
parent::preProcess();
......@@ -59,7 +58,6 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$session->pushUserContext($url);
// check and ensure that update / delete have a valid id
require_once 'CRM/Utils/Rule.php';
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::DELETE)) {
if (! CRM_Utils_Rule::positiveInteger($this->_id)) {
CRM_Core_Error::fatal(ts('We need a valid discount ID for update and/or delete'));
......@@ -149,11 +147,12 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
}
$this->applyFilter('__ALL__', 'trim');
$element =& $this->add('text',
$element = $this->add('text',
'code',
ts('Code'),
CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'code'),
true);
true
);
$this->addRule('code',
ts('Code already exists in Database.'),
'objectExists',
......@@ -194,7 +193,6 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
$this->add('text', 'discount_msg', ts('Message to users not eligible for discount'), CRM_Core_DAO::getAttribute('CRM_CiviDiscount_DAO_Item', 'discount_msg'));
// add memberships, events, pricesets
require_once 'CRM/Member/BAO/MembershipType.php';
$membershipTypes = CRM_Member_BAO_MembershipType::getMembershipTypes(false);
$autodiscount = $mTypes = array();
if (! empty($membershipTypes)) {
......@@ -220,7 +218,6 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
);
}
require_once 'CRM/CiviDiscount/Utils.php';
$events = CRM_CiviDiscount_Utils::getEvents();
if (! empty($events)) {
$this->_multiValued['events'] = $events;
......@@ -263,7 +260,6 @@ class CRM_CiviDiscount_Form_Admin extends CRM_Admin_Form {
if ($this->_action & CRM_Core_Action::COPY) {
$params = $this->exportValues();
require_once 'CRM/CiviDiscount/Utils.php';
$newCode = CRM_CiviDiscount_Utils::randomString('abcdefghjklmnpqrstwxyz23456789', 8);
CRM_CiviDiscount_BAO_Item::copy($this->_cloneID, $params, $newCode);
CRM_Core_Session::setStatus(ts('Selected Discount has been duplicated.'));
......
......@@ -39,10 +39,8 @@ class CRM_CiviDiscount_Utils {
static function getEvents() {
// lets include all events instead of only public events
// quite a few folks want this!
require_once 'CRM/Event/BAO/Event.php';
$eventInfo =
CRM_Event_BAO_Event::getCompleteInfo(NULL, NULL, NULL, NULL, FALSE);
if (! empty($eventInfo)) {
$events = array();
foreach ($eventInfo as $info) {
......
......@@ -104,9 +104,9 @@
<tr class="crm-discount-item-form-block-events">
<td class="label">{$form.events.label} {help id="events" title=$form.events.label}</td>
<td>{$form.events.html}<br/>
{if $form.pricesets}
<span
class="description"><strong><em>{ts}If you use price sets for your events, you also need to select any discountable price sets below.{/ts}</em></strong>
{if $form.pricesets}
<span
class="description"><strong><em>{ts}If you use price sets for your events, you also need to select any discountable price sets below.{/ts}</em></strong>
</span>
{/if}
</td>
......@@ -115,22 +115,19 @@
{if $form.pricesets}
<tr class="crm-discount-item-form-block-price-set">
<td class="label">{$form.pricesets.label} {help id="pricesets" title=$form.pricesets.label}</td>
<td>{$form.pricesets.html}<br/>
<span class="description">{ts}{/ts}
</td>
<td>{$form.pricesets.html}</td>
</tr>
{/if}
{if $form.memberships}
<tr class="crm-discount-item-form-block-memberships">
<td class="label">{$form.memberships.label} {help id="memberships" title=$form.memberships.label}</td>
<td>{$form.memberships.html}<br/>
<span class="description">{ts}{/ts}
</td>
</tr>
{/if}
<tr>
<td>&nbsp;</td>
<td>{$form.discount_msg_enabled.html} {$form.discount_msg_enabled.label}</td>
<td>{$form.discount_msg_enabled.html} {$form.discount_msg_enabled.label}</td>
</tr>
<tr class="crm-discount-item-form-block-discount-message">
<td class="label">{$form.discount_msg.label} {help id="discount-message" title=$form.discount_msg.label}</td>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment