Commit 4be79955 authored by bgm's avatar bgm Committed by Aegir user

Update cividiscount to v3.5

parent fad0ab9c
......@@ -25,6 +25,8 @@
+--------------------------------------------------------------------+
*/
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* @package CiviDiscount
*/
......@@ -225,7 +227,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'code' => array(
'name' => 'code',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Code'),
'title' => E::ts('Code'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -233,7 +235,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'description' => array(
'name' => 'description',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Description'),
'title' => E::ts('Description'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -241,7 +243,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'filters' => array(
'name' => 'filters',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Discount Filters'),
'title' => E::ts('Discount Filters'),
'required' => FALSE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -249,7 +251,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'amount' => array(
'name' => 'amount',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Amount'),
'title' => E::ts('Amount'),
'required' => TRUE,
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
......@@ -257,7 +259,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'amount_type' => array(
'name' => 'amount_type',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Amount Type'),
'title' => E::ts('Amount Type'),
'required' => TRUE,
'maxlength' => 4,
'size' => CRM_Utils_Type::FOUR,
......@@ -265,35 +267,35 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'count_max' => array(
'name' => 'count_max',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Count Max'),
'title' => E::ts('Count Max'),
'required' => TRUE,
),
'count_use' => array(
'name' => 'count_use',
'type' => CRM_Utils_Type::T_INT,
'title' => ts('Count Use'),
'title' => E::ts('Count Use'),
'required' => TRUE,
'default' => 0,
),
'events' => array(
'name' => 'events',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Events'),
'title' => E::ts('Events'),
),
'pricesets' => array(
'name' => 'pricesets',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Pricesets'),
'title' => E::ts('Pricesets'),
),
'memberships' => array(
'name' => 'memberships',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Memberships'),
'title' => E::ts('Memberships'),
),
'autodiscount' => array(
'name' => 'autodiscount',
'type' => CRM_Utils_Type::T_TEXT,
'title' => ts('Autodiscount'),
'title' => E::ts('Autodiscount'),
),
'organization_id' => array(
'name' => 'organization_id',
......@@ -303,12 +305,12 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'active_on' => array(
'name' => 'active_on',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'title' => ts('Activation Date'),
'title' => E::ts('Activation Date'),
),
'expire_on' => array(
'name' => 'expire_on',
'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
'title' => ts('Expiration Date'),
'title' => E::ts('Expiration Date'),
),
'is_active' => array(
'name' => 'is_active',
......@@ -321,7 +323,7 @@ class CRM_CiviDiscount_DAO_Item extends CRM_Core_DAO {
'discount_msg' => array(
'name' => 'discount_msg',
'type' => CRM_Utils_Type::T_STRING,
'title' => ts('Discount Message'),
'title' => E::ts('Discount Message'),
'maxlength' => 255,
'size' => CRM_Utils_Type::HUGE,
),
......
......@@ -30,6 +30,7 @@
*/
require_once 'CRM/CiviDiscount/DAO/Item.php';
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* Page for displaying list of discount codes
......@@ -63,38 +64,38 @@ class CRM_CiviDiscount_Page_List extends CRM_Core_Page_Basic {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::VIEW => array(
'name' => ts('View'),
'name' => E::ts('View'),
'url' => 'civicrm/cividiscount/discount/view',
'qs' => 'id=%%id%%&reset=1',
'title' => ts('View Discount Code')
'title' => E::ts('View Discount Code')
),
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'name' => E::ts('Edit'),
'url' => 'civicrm/cividiscount/discount/edit',
'qs' => '&id=%%id%%&reset=1',
'title' => ts('Edit Discount Code')
'title' => E::ts('Edit Discount Code')
),
CRM_Core_Action::COPY => array(
'name' => ts('Copy'),
'name' => E::ts('Copy'),
'url' => 'civicrm/cividiscount/discount/copy',
'qs' => '&cloneID=%%id%%&reset=1',
'title' => ts('Clone Discount Code')
'title' => E::ts('Clone Discount Code')
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'name' => E::ts('Disable'),
'class' => 'crm-enable-disable',
'title' => ts('Disable Discount Code')
'title' => E::ts('Disable Discount Code')
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'name' => E::ts('Enable'),
'class' => 'crm-enable-disable',
'title' => ts('Enable Discount Code')
'title' => E::ts('Enable Discount Code')
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'name' => E::ts('Delete'),
'url' => 'civicrm/cividiscount/discount/delete',
'qs' => '&id=%%id%%',
'title' => ts('Delete Discount Code')
'title' => E::ts('Delete Discount Code')
)
);
}
......@@ -116,7 +117,7 @@ class CRM_CiviDiscount_Page_List extends CRM_Core_Page_Basic {
* @return string name of this page.
*/
function editName() {
return ts('Discount Code');
return E::ts('Discount Code');
}
/**
......
......@@ -30,6 +30,7 @@
*/
require_once 'CRM/CiviDiscount/DAO/Item.php';
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* Page for displaying discount code details
......@@ -70,26 +71,26 @@ class CRM_CiviDiscount_Page_View extends CRM_Core_Page {
if (!(self::$_links)) {
self::$_links = array(
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'name' => E::ts('Edit'),
'url' => 'civicrm/cividiscount/discount/edit',
'qs' => '&id=%%id%%&reset=1',
'title' => ts('Edit Discount')
'title' => E::ts('Edit Discount')
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
'name' => E::ts('Disable'),
'class' => 'crm-enable-disable',
'title' => ts('Disable Discount')
'title' => E::ts('Disable Discount')
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
'name' => E::ts('Enable'),
'class' => 'crm-enable-disable',
'title' => ts('Enable Discount')
'title' => E::ts('Enable Discount')
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'name' => E::ts('Delete'),
'url' => 'civicrm/cividiscount/discount/delete',
'qs' => '&id=%%id%%&reset=1',
'title' => ts('Delete Discount')
'title' => E::ts('Delete Discount')
)
);
}
......
......@@ -56,7 +56,11 @@ function civicrm_api3_discount_code_create($params) {
*/
function _civicrm_api3_discount_code_create_spec(&$params) {
$params['is_active']['api.default'] = 1;
$params['multi_valued']['api.default'] = array();
$params['multi_valued']['api.default'] = array(
'events' => NULL,
'memberships' => NULL,
'pricesets' => NULL,
);
$params['multi_valued']['title'] = 'List of discount types being passed in';
}
......
<?php
require_once 'cividiscount.civix.php';
use CRM_CiviDiscount_ExtensionUtil as E;
/**
* Implements hook_civicrm_install().
......@@ -23,15 +24,6 @@ function cividiscount_civicrm_config(&$config) {
_cividiscount_civix_civicrm_config($config);
}
/**
* Implements hook_civicrm_perm().
*
* Module extensions dont implement this hook as yet, will need to add for 4.2
*/
function cividiscount_civicrm_perm() {
return array('view CiviDiscount', 'administer CiviDiscount');
}
/**
* Implements hook_civicrm_xmlMenu().
*/
......@@ -89,7 +81,7 @@ function cividiscount_civicrm_tabs(&$tabs, $cid) {
$tabs[] = array(
'id' => 'discounts',
'count' => $count,
'title' => ts('Codes Assigned'),
'title' => E::ts('Codes Assigned'),
'weight' => '98',
'url' => CRM_Utils_System::url('civicrm/cividiscount/usage', "reset=1&oid={$cid}", false, null, false),
);
......@@ -99,7 +91,7 @@ function cividiscount_civicrm_tabs(&$tabs, $cid) {
$tabs[] = array(
'id' => 'discounts',
'count' => $count,
'title' => ts('Codes Redeemed'),
'title' => E::ts('Codes Redeemed'),
'weight' => '99',
'url' => CRM_Utils_System::url('civicrm/cividiscount/usage', "reset=1&cid={$cid}", false, null, false),
);
......@@ -238,7 +230,7 @@ function cividiscount_civicrm_validateForm($name, &$fields, &$files, &$form, &$e
if ((!$discountInfo || !$discountInfo['autodiscount']) && trim($code) != '') {
if (!$discountInfo) {
$errors['discountcode'] = ts('The discount code you entered is invalid.');
$errors['discountcode'] = E::ts('The discount code you entered is invalid.');
return;
}
......@@ -252,7 +244,7 @@ function cividiscount_civicrm_validateForm($name, &$fields, &$files, &$form, &$e
$apcount += $sv['additional_participants'];
}
if (($discount['count_use'] + $apcount) > $discount['count_max']) {
$errors['discountcode'] = ts('There are not enough uses remaining for this code.');
$errors['discountcode'] = E::ts('There are not enough uses remaining for this code.');
}
}
}
......@@ -340,7 +332,7 @@ function cividiscount_civicrm_buildAmount($pageType, &$form, &$amounts) {
$discounts = $discountCalculator->getDiscounts();
if (!empty($code) && empty($discounts)) {
$form->set( 'discountCodeErrorMsg', ts('The discount code you entered is invalid.'));
$form->set( 'discountCodeErrorMsg', E::ts('The discount code you entered is invalid.'));
}
// here we check if discount is configured for events or for membership types.
......@@ -419,6 +411,8 @@ function cividiscount_civicrm_buildAmount($pageType, &$form, &$amounts) {
$option['amount'] = $amount;
$option['label'] = $label;
$option['discount_applied'] = $discountAmount;
$option['discount_code'] = $discount['code'];
$option['discount_description'] = $discount['description'];
/*
* Priyanka Karan @ Veda NFP Consulting Ltd
* Re-calculate VAT/Sales TAX on discounted amount.
......@@ -432,15 +426,19 @@ function cividiscount_civicrm_buildAmount($pageType, &$form, &$amounts) {
}
}
}
$appliedDiscountID = $discountID;
$discountApplied = TRUE;
}
}
}
}
if ($autodiscount) {
break;
}
}
// Display discount message if one is available
if ($pageType == 'event') {
if ($pageType == 'event' && !$autodiscount) {
foreach ($discounts as $code => $discount) {
if (isset($discount['events']) && array_key_exists($eid, $discount['events']) &&
$discount['discount_msg_enabled'] && (!isset($discountApplied) || !$discountApplied) && !empty($discount['autodiscount'])) {
......@@ -449,15 +447,14 @@ function cividiscount_civicrm_buildAmount($pageType, &$form, &$amounts) {
}
}
// this seems to incorrectly set to only the last discount but it seems not to matter in the way it is used
if (isset($discountApplied) && $discountApplied) {
if (isset($discountApplied) && $discountApplied && !empty($discounts[$appliedDiscountID])) {
if (!empty($ps['fields'])) {
$ps['fields'] = $amounts;
$form->setVar('_priceSet', $ps);
}
$form->set('_discountInfo', array(
'discount' => $discount,
'discount' => $discounts[$appliedDiscountID],
'autodiscount' => $autodiscount,
'contact_id' => $contact_id,
));
......@@ -497,7 +494,7 @@ function _cividiscount_checkEventDiscountMultipleParticipants($pageType, &$form,
$apcount += $sv['additional_participants'];
}
if (($discount['count_use'] + $apcount) > $discount['count_max']) {
$form->set('discountCodeErrorMsg', ts('There are not enough uses remaining for this code.'));
$form->set('discountCodeErrorMsg', E::ts('There are not enough uses remaining for this code.'));
return FALSE;
}
}
......@@ -580,11 +577,12 @@ function cividiscount_civicrm_membershipTypeValues(&$form, &$membershipTypeValue
$form->set('_discountInfo', NULL);
$code = CRM_Utils_Request::retrieve('discountcode', 'String', $form, false, null, 'REQUEST');
$discountCalculator = new CRM_CiviDiscount_DiscountCalculator('membership_type', NULL, $contact_id, $code, FALSE);
if (!empty($code)) {
$discounts = $discountCalculator->getDiscounts();
$discounts = $discountCalculator->getDiscounts();
if (empty($code)) {
$discounts = $discountCalculator->autoDiscounts;
}
if(!empty($code) && empty($discounts)) {
$form->set( 'discountCodeErrorMsg', ts('The discount code you entered is invalid.'));
$form->set( 'discountCodeErrorMsg', E::ts('The discount code you entered is invalid.'));
}
if (empty($discounts)) {
return;
......@@ -893,7 +891,7 @@ function _cividiscount_filter_membership_discounts($discounts, $membershipTypeVa
* Calculate either a monetary or percentage discount.
*/
function _cividiscount_calc_discount($amount, $label, $discount, $autodiscount, $currency = 'USD') {
$title = $autodiscount ? ts('Includes automatic member discount of') : ts('Includes applied discount code %1', array(1 => $discount['code']));
$title = $autodiscount ? E::ts('Includes automatic member discount of') : E::ts('Includes applied discount code %1', array(1 => $discount['code']));
if ($discount['amount_type'] == '2') {
$newamount = CRM_Utils_Rule::cleanMoney($amount) - CRM_Utils_Rule::cleanMoney($discount['amount']);
$fmt_discount = CRM_Utils_Money::format($discount['amount'], $currency);
......@@ -1042,14 +1040,14 @@ function _cividiscount_add_discount_textfield(&$form) {
_cividiscount_add_button_before_priceSet($form);
return;
}
$form->addElement('text', 'discountcode', ts('If you have a discount code, enter it here'));
$form->addElement('text', 'discountcode', E::ts('If you have a discount code, enter it here'));
$errorMessage = $form->get('discountCodeErrorMsg');
if ($errorMessage) {
$form->setElementError('discountcode', $errorMessage);
}
$form->set('discountCodeErrorMsg', null);
$buttonName = $form->getButtonName('reload');
$form->addElement('submit', $buttonName, ts('Apply'), array('formnovalidate' => 1));
$form->addElement('submit', $buttonName, E::ts('Apply'), array('formnovalidate' => 1));
$template = CRM_Core_Smarty::singleton();
$bhfe = $template->get_template_vars('beginHookFormElements');
if (!$bhfe) {
......@@ -1100,7 +1098,7 @@ function _cividiscount_add_button_before_priceSet(&$form) {
$form->add(
'text',
'discountcode',
ts('If you have a discount code, enter it here'),
E::ts('If you have a discount code, enter it here'),
array('class' => 'description')
);
$errorMessage = $form->get('discountCodeErrorMsg');
......@@ -1109,7 +1107,7 @@ function _cividiscount_add_button_before_priceSet(&$form) {
}
$form->set('discountCodeErrorMsg', null);
$buttonName = $form->getButtonName('reload');
$form->addElement('submit', $buttonName, ts('Apply'), array('formnovalidate' => 1));
$form->addElement('submit', $buttonName, E::ts('Apply'), array('formnovalidate' => 1));
$form->assign('discountElements', array(
'discountcode',
$buttonName
......@@ -1156,6 +1154,16 @@ function cividiscount_civicrm_navigationMenu( &$params ) {
)
);
}
foreach (array('Events', 'Contributions') as $header) {
_cividiscount_civix_insert_navigation_menu($params, $header, array(
'label' => ts('CiviDiscount', array('domain' => 'org.civicrm.module.cividiscount')),
'name' => 'CiviDiscount',
'url' => 'civicrm/cividiscount',
'permission' => 'administer CiviCRM,administer CiviDiscount',
'operator' => 'OR',
'separator' => 2,
));
}
}
/**
......@@ -1174,3 +1182,9 @@ function cividiscount_civicrm_entityTypes(&$entityTypes) {
);
}
function cividiscount_civicrm_permission(&$permissions) {
$permissions += array(
'administer CiviDiscount' => ts('administer CiviDiscount', array('domain' => 'org.civicrm.module.cividiscount')),
);
}
# Automatic discounts
Anyone with the selected memberships or contact attributes will automatically have the discount code applied provided they are logged in to the website. Autodiscount is generally used with a randomly-generated code which is not given out to users. Cividiscount will apply the discount with no code required.
![Screenshot of automatic discount setup](/images/autodiscount.png)
* Automatic discounts can be applied based on membership status and/or type.
* Automatic discounts can be applied to contacts based on type, age (minimum or maximum) and/or country
### Advanced Filters
CiviDiscount now allows you to specify your own criteria for who should get automatic discounts. This is a powerful feature but does require some technical skill and thorough testing is recommended. Use the api explorer (on your site at the url civicrm/api/explorer) to help you discover the api options you could pass.
You need to specify an API Entity that you want to query and a query string. If you specify contact then the logged in contact id will be passed in as 'id'. For all other api it will be passed in as 'contact_id'
In this image you can see that contacts with a value of 1 in custom id field 65 (which happens to be 'are you retired' in this case) will get an automatic discount if they meet other criteria above - ie a minimum age of 65)
![Screenshot of advanced filter example](/images/advancedFilters.jpg)
# Setup discount codes
Under **Administer > CiviDiscount** click **New Discount Code.**
![Screenshot of discount code setup](/images/codesetup.png)
**Discount Code:** Create a custom code or click the random code button. Codes can only consist of alphanumeric characters. Do not use spaces. Once created discount codes cannot be changed.
**Description:** Description of code for reference purposes. This description is displayed as part of amounts it is applied too in front end forms and receipts.
**Active:** Check to make code active
**Discount Amount:** Enter the amount of discount. Either a percentage or a set monetary amount.
### Additional Options:
* Usage Limit: The maximum number of times this discount code can be used. Leave blank for no limit.
* Activation Date: This discount will not be usable before this date. Leave blank to have it be enabled right away.
* Expiration Date: This discount will not be usable after this date. Leave blank to have it never expire.
* Organization: Used to associate this discount code with an organization. Every time this code is used it will be recorded on that organization's contact record.
* Price Field Options: If your form uses a price set, the discount will be applied to all options in the set by default. However, if you want the discount to be applied only to specific price options - select those options here.
* Message to non-eligible users: Check box and enter the message you'd like users to see if they are not receiving a discount. The message will appear above the form.
* Events: This discount can be used on the selected event(s). Only active, public and current/future events are listed.
* Event Type: This discount can be used on any event of the select type(s).
* Memberships: Discount the price of purchasing memberships. Only active memberships with start and end dates defined will appear in this list.
\ No newline at end of file
# CiviDiscount
CiviDiscount provides the ability to add discounts to event registrations and membership contributions within CiviCRM.
CiviDiscount is designed to allow discounts of a set percentage or dollar amount through the use of a custom discount code or applied automatically based on specific criteria.
### Features
* Custom or randomly generated discount codes.
* Usage limit
* Schedule start and end dates the code is valid.
* Support for price sets and individual items in a price set
* Custom message for invalid codes
* Option to apply discounts to additional participants
* Discounts valid for specific events or event types
* Discounts valid for specific membership types
* Automatic discounts applied for specific members types or statuses
* Automatic discounts applied to contacts based on type, age, country or custom fields.
* Code summary screen displays usage for a given discount code
* Usage and assigned code tabs on a contact record
# Installation
Use the following steps to install CiviDiscount.
* **Administer > System Settings > Extensions**
* **Add New**
* Find, download, and install CiviDiscount
To access the CiviDiscount dashboard to setup and manage codes go to **Administer > CiviDiscount**.
\ No newline at end of file
......@@ -5,25 +5,23 @@
<description>Enables discount codes and automatic discounts for events and memberships.</description>
<urls>
<url desc="Main Extension Page">
http://civicrm.org/extension/cividiscount-extension
https://civicrm.org/extensions/cividiscount
</url>
<url desc="Documentation">
https://github.com/dlobo/org.civicrm.module.cividiscount/
https://github.com/civicrm/org.civicrm.module.cividiscount
</url>
<url desc="Support">http://civicrm.stackexchange.com</url>
<url desc="Licensing">http://civicrm.org/licensing</url>
<url desc="Support">https://civicrm.stackexchange.com</url>
<url desc="Licensing">https://civicrm.org/license</url>
</urls>
<license>AGPL-3.0</license>
<maintainer>
<author>CiviCRM LLC</author>
<email>info@civicrm.org</email>
</maintainer>
<releaseDate>2016-10-20</releaseDate>
<version>3.3</version>
<releaseDate>2018-07-30</releaseDate>
<version>3.5</version>
<compatibility>
<ver>4.5</ver>
<ver>4.6</ver>
<ver>4.7</ver>
<ver>5.3</ver>
</compatibility>
<comments>
For support, please ask on chat.civicrm.org
......
......@@ -9,6 +9,19 @@ CRM.$(function($) {
}
}
/**
* Function copied from templates/CRM/Price/Form/Calculate.tpl - calculateTotalFee() (in case it gets changed somewhere along the way)
* This Calculates the total fee on CiviCRM
*/
function discountCalculateTotalFee() {
var totalFee = 0;
$('#priceset [price]').each(function () {
totalFee = totalFee + $(this).data('line_raw_total');
});
return totalFee;
}
function skipPaymentMethod() {
var flag = false;
$('.price-set-option-content input').each( function(){
......@@ -18,7 +31,7 @@ CRM.$(function($) {
}
});
$('.price-set-option-content input').change( function () {
if ($(this).attr('data-amount').replace(/[^\/\d]/g,'') == 0 ) {
if (discountCalculateTotalFee() == 0) {
flag = true;
} else {
flag = false;
......@@ -29,4 +42,3 @@ CRM.$(function($) {
}
}
});
site_name: CiviDiscount
repo_url: https://github.com/dlobo/org.civicrm.module.cividiscount
theme: material
pages:
- Home: index.md
- Installation: install.md
- Setup Codes: codesetup.md
- Automatic Discounts: autodiscount.md
markdown_extensions:
- attr_list
- admonition
- def_list
- codehilite
- toc(permalink=true)
- pymdownx.superfences
- pymdownx.inlinehilite
- pymdownx.tilde
- pymdownx.betterem
- pymdownx.mark
......@@ -41,6 +41,7 @@
<th>{ts}Usage{/ts}</th>
<th>{ts}Start Date{/ts}</th>
<th>{ts}End Date{/ts}</th>
<th>{ts}Enabled?{/ts}</th>
<th></th>
</tr>
</thead>
......@@ -52,6 +53,7 @@
/ {if $row.count_max eq 0}{ts}Unlimited{/ts}{else}{$row.count_max}{/if}</td>
<td>{if $row.active_on neq '0000-00-00 00:00:00'}{$row.active_on|truncate:10:''|crmDate}{/if}</td>
<td>{if $row.expire_on neq '0000-00-00 00:00:00'}{$row.expire_on|truncate:10:''|crmDate}{/if}</td>
<td>{if $row.is_active eq 1}Yes{else}No{/if}</td>
<td>{$row.action|replace:'xx':$row.id}</td>
</tr>
{/foreach}
......
......@@ -29,12 +29,12 @@
<div class="action-link">
<div class="crm-submit-buttons">
{if call_user_func(array('CRM_Core_Permission','check'), 'administer CiviCRM')}
{if call_user_func(array('CRM_Core_Permission','check'), 'administer CiviCRM') OR call_user_func(array('CRM_Core_Permission','check'), 'administer CiviDiscount')}
<a class="button" href='{crmURL p='civicrm/cividiscount/discount/edit' q="reset=1&id=$id"}' accesskey="e">
<span><span class="icon ui-icon-pencil"></span>{ts}Edit{/ts}</span>
</a>
{/if}
{if call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute')}
{if call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') OR call_user_func(array('CRM_Core_Permission','check'), 'administer CiviDiscount')}
<a class="button" href='{crmURL p='civicrm/cividiscount/discount/delete' q="reset=1&id=$id"}'>
<span><span class="icon delete-icon"></span>{ts}Delete{/ts}</span>
</a>
......@@ -121,11 +121,11 @@
<div class="action-link">
<div class="crm-submit-buttons">
{assign var='urlParams' value="reset=1&id=$id"}
{if call_user_func(array('CRM_Core_Permission','check'), 'administer CiviCRM')}
{if call_user_func(array('CRM_Core_Permission','check'), 'administer CiviCRM') OR call_user_func(array('CRM_Core_Permission','check'), 'administer CiviDiscount')}
<a class="button" href="{crmURL p='civicrm/cividiscount/discount/edit' q=$urlParams}" accesskey="e">
<span><span class="icon ui-icon-pencil"></span>{ts}Edit{/ts}</span></a>
{/if}
{if call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute')}
{if call_user_func(array('CRM_Core_Permission','check'), 'delete in CiviContribute') OR call_user_func(array('CRM_Core_Permission','check'), 'administer CiviDiscount')}
<a class="button" href="{crmURL p='civicrm/cividiscount/discount/delete' q=$urlParams}">
<span><span class="icon delete-icon"></span>{ts}Delete{/ts}</span></a>
{/if}
......
<table class="form-layout-compressed cividiscount">
<div class="crm-public-form-item crm-section cividiscount-section cividiscount">
{foreach from=$discountElements item=discountElement}
<tr><td class="label nowrap">{$form.$discountElement.label}</td><td>{$form.$discountElement.html}</td></tr>
<div class="label">{$form.$discountElement.label}</div>
<div class="content">{$form.$discountElement.html}</div>
{/foreach}
</table>
<div class="clear"></div>
</div>
......@@ -4,52 +4,52 @@
<item>
<path>civicrm/cividiscount</path>
<page_callback>CRM_CiviDiscount_Page_List</page_callback>
<access_arguments>administer CiviCRM</access_arguments>
<access_arguments>administer CiviCRM;administer CiviDiscount</access_arguments>
<title>Discounts</title>
</item>
<item>
<path>civicrm/cividiscount/discount/add</path>
<page_callback>CRM_CiviDiscount_Form_Admin</page_callback>
<page_arguments>mode=1</page_arguments>
<access_arguments>administer CiviCRM</access_arguments>
<access_arguments>administer CiviCRM;administer CiviDiscount</access_arguments>
</item>
<item>
<path>civicrm/cividiscount/discount/edit</path>