Skip to content

Commit c9f8199

Browse files
committed
Refs #24400, Change receiptLogo field to image upload.
1 parent ddc1666 commit c9f8199

File tree

4 files changed

+53
-9
lines changed

4 files changed

+53
-9
lines changed

CRM/Admin/Form/Setting/Receipt.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CRM_Admin_Form_Setting_Receipt extends CRM_Admin_Form_Setting {
1313
*/
1414
public function buildQuickForm() {
1515
CRM_Utils_System::setTitle(ts('Settings - Contribution Receipt'));
16-
$this->addElement('text', 'receiptLogo', ts('Logo'));
16+
$this->addElement('file', 'receiptLogo', ts('Logo'));
1717
$this->addElement('text', 'receiptPrefix', ts('Prefix of Receipt ID'));
1818
$this->addElement('textarea', 'receiptDescription', ts('Description of Receipt Footer'));
1919
$this->addElement('textarea', 'receiptOrgInfo', ts('Organization info'));
@@ -59,18 +59,28 @@ public function buildQuickForm() {
5959
$this->add('file', 'uploadBigStamp', ts('The stamp of organization.'));
6060
$this->add('file', 'uploadSmallStamp', ts('The stamp of the person in charge.'));
6161
$config = CRM_Core_Config::singleton();
62-
$this->controller->addActions($config->imageUploadDir, array('uploadBigStamp', 'uploadSmallStamp'));
62+
$this->controller->addActions($config->imageUploadDir, array('uploadBigStamp', 'uploadSmallStamp', 'receiptLogo'));
6363

6464
if($config->imageBigStampName){
6565
$this->assign('imageBigStampUrl', $config->imageUploadURL . $config->imageBigStampName);
6666
}
6767
if($config->imageSmallStampName){
6868
$this->assign('imageSmallStampUrl', $config->imageUploadURL . $config->imageSmallStampName);
6969
}
70+
$receiptLogo = $config->receiptLogo;
71+
if ($receiptLogo) {
72+
if (substr($receiptLogo, 0, 7) == 'http://' || substr($receiptLogo, 0, 8) == 'https://') {
73+
$this->assign('receiptLogoUrl', $receiptLogo);
74+
}
75+
else if ($receiptLogo) {
76+
$this->assign('receiptLogoUrl', $config->imageUploadURL . $receiptLogo);
77+
}
78+
}
7079

7180
$this->assign('stampDocUrl', CRM_Utils_System::docURL2('Receipt Stamp', TRUE));
7281
$this->add('hidden', 'deleteBigStamp');
7382
$this->add('hidden', 'deleteSmallStamp');
83+
$this->add('hidden', 'deleteReceiptLogo');
7484

7585
$displayLegalIDOptions = array('complete' => ts('Complete display'), 'partial' => ts('Partial hide'), 'hide' => ts('Complete hide'));
7686
$this->addRadio('receiptDisplayLegalID', ts('The way displays legal ID in receipt.'), $displayLegalIDOptions);
@@ -92,6 +102,7 @@ function setDefaultValues() {
92102
$defaults = parent::setDefaultValues();
93103
$defaults['deleteBigStamp'] = '';
94104
$defaults['deleteSmallStamp'] = '';
105+
$defaults['deleteReceiptLogo'] = '';
95106
if (empty($defaults['receiptDisplayLegalID'])) {
96107
$defaults['receiptDisplayLegalID'] = 'complete';
97108
}
@@ -125,17 +136,25 @@ public function postProcess() {
125136
$uploadSmallStamp = CRM_Utils_Array::value('uploadSmallStamp', $params);
126137
$uploadSmallStamp = $uploadSmallStamp['name'];
127138

139+
$uploadReceiptLogo = CRM_Utils_Array::value('receiptLogo', $params);
140+
$uploadReceiptLogo = $uploadReceiptLogo['name'];
141+
128142
$deleteBigStamp = CRM_Utils_Array::value('deleteBigStamp', $params);
129143
$deleteSmallStamp = CRM_Utils_Array::value('deleteSmallStamp', $params);
144+
$deleteReceiptLogo = CRM_Utils_Array::value('deleteReceiptLogo', $params);
130145
unset($params['deleteBigStamp']);
131146
unset($params['deleteSmallStamp']);
147+
unset($params['deleteReceiptLogo']);
132148

133149
if($deleteBigStamp){
134150
$params['imageBigStampName'] = '';
135151
}
136152
if($deleteSmallStamp){
137153
$params['imageSmallStampName'] = '';
138154
}
155+
if($deleteReceiptLogo){
156+
$params['receiptLogo'] = '';
157+
}
139158

140159
// to check wether GD is installed or not
141160
$gdSupport = CRM_Utils_System::getModuleSetting('gd', 'GD Support');
@@ -148,6 +167,10 @@ public function postProcess() {
148167
$error = false;
149168
$params['imageSmallStampName'] = $this->_resizeImage($uploadSmallStamp, "_full", 800, 200);
150169
}
170+
if ($uploadReceiptLogo) {
171+
$error = false;
172+
$params['receiptLogo'] = $this->_resizeImage($uploadReceiptLogo, "_full", 800, 200);
173+
}
151174
}else{
152175
$error = true;
153176
}
@@ -257,5 +280,4 @@ private function _resizeImage($filename, $resizedName, $width, $height ) {
257280
return basename($newFilename);
258281
}
259282

260-
}
261-
283+
}

CRM/Contribute/BAO/Contribution.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2060,6 +2060,9 @@ static function getReceipt(&$input, &$ids, &$objects, &$values, &$template = NUL
20602060
$sic_code = self::getFormatLegalID($sic_code);
20612061
$template->assign('serial_id', $sic_code);
20622062
}
2063+
if ($receipt_logo && !(substr($receipt_logo, 0, 7) == 'http://' || substr($receipt_logo, 0, 8) == 'https://')) {
2064+
$receipt_logo = $config->imageUploadDir . $receipt_logo;
2065+
}
20632066

20642067
$addressee = !empty($contact->addressee_custom) ? $contact->addressee_custom : (!empty($contact->addressee_display) ? $contact->addressee_display : $contact->sort_name);
20652068
$template->assign('id' , $contribution->id);
@@ -2178,6 +2181,9 @@ static function getAnnualReceipt($contact_id, $option, &$template = NULL) {
21782181
$sort_name = $contact['sort_name'];
21792182
$addressee = !empty($contact['addressee_custom']) ? $contact['addressee_custom'] : (!empty($contact['addressee_display']) ? $contact['addressee_display'] : $sort_name);
21802183
$receipt_logo = $config->receiptLogo;
2184+
if ($receipt_logo && !(substr($receipt_logo, 0, 7) == 'http://' || substr($receipt_logo, 0, 8) == 'https://')) {
2185+
$receipt_logo = $config->imageUploadURL . $receipt_logo;
2186+
}
21812187

21822188
$addrParams = array('contact_id' => $contact_id);
21832189
$addresses = CRM_Core_BAO_Address::getValues($addrParams);
@@ -2704,6 +2710,10 @@ static function getInvoice($contributionId, $paymentInfo, $message, $sendMail =
27042710
}
27052711

27062712
$config = CRM_Core_Config::singleton();
2713+
$receipt_logo = $config->receiptLogo;
2714+
if ($receipt_logo && !(substr($receipt_logo, 0, 7) == 'http://' || substr($receipt_logo, 0, 8) == 'https://')) {
2715+
$receipt_logo = $config->imageUploadDir . $receipt_logo;
2716+
}
27072717
$tplParams = array(
27082718
'contact_id' => $contribution->contact_id,
27092719
'contribution' => (array)$contribution,
@@ -2712,7 +2722,7 @@ static function getInvoice($contributionId, $paymentInfo, $message, $sendMail =
27122722
'component' => !empty($ids['component']) ? $ids['component'] : '',
27132723
'page' => $pageValues,
27142724
'title' => $pageValues['title'],
2715-
'logo' => !empty($config->receiptLogo) ? $config->receiptLogo : '',
2725+
'logo' => !empty($receipt_logo) ? $receipt_logo : '',
27162726
);
27172727

27182728
// use either the contribution or membership receipt, based on whether it’s a membership-related contrib or not

CRM/Event/Badge/Logo.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ function __construct() {
2222
);
2323
$this->lMarginLogo = 20;
2424
$this->tMarginName = 20;
25-
$this->logo = $config->receiptLogo;
25+
$receipt_logo = $config->receiptLogo;
26+
if ($receipt_logo && !(substr($receipt_logo, 0, 7) == 'http://' || substr($receipt_logo, 0, 8) == 'https://')) {
27+
$receipt_logo = $config->imageUploadDir . $receipt_logo;
28+
}
29+
$this->logo = $receipt_logo;
2630
}
2731

2832
public function generateLabel($participant) {

templates/CRM/Admin/Form/Setting/Receipt.tpl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@
2727
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
2828
<table class="form-layout-compressed">
2929
<tr class="crm-form-block-receiptLogo">
30-
<td class="label">{$form.receiptLogo.label}</td><td>{$form.receiptLogo.html}<br />
31-
<span class="description">{ts}Paste logo url. Start with http://{/ts}</span></td>
30+
<td class="label">{$form.receiptLogo.label}</td>
31+
<td class="value">
32+
{if $receiptLogoUrl}
33+
<img style="max-height: 103px;" src="{$receiptLogoUrl}">
34+
<a class="delete-image" href="javascript:void(0);" data-field="deleteReceiptLogo">{ts}Delete{/ts}</a>
35+
<br/>
36+
{/if}
37+
{$form.receiptLogo.html}<br />
38+
<span class="description">{ts}Upload a logo image to appear on the receipt.{/ts}</span>
39+
</td>
3240
</tr>
3341
<tr class="crm-form-block-receiptPrefix">
3442
<td class="label">{$form.receiptPrefix.label}</td><td>{$form.receiptPrefix.html}<br />
@@ -198,4 +206,4 @@
198206
}
199207
</style>
200208
{/literal}
201-
</div>
209+
</div>

0 commit comments

Comments
 (0)